Skip to content

feat(scripts): make tenant id more prominent and improve logging in setup scripts - #2280

Merged
EduVencovsky merged 4 commits into
mainfrom
feat/aws-setup-role-arn
Sep 10, 2026
Merged

EduVencovsky merged 4 commits into
mainfrom
feat/aws-setup-role-arn

Conversation

@EduVencovsky

Copy link
Copy Markdown
Contributor

Description of the issue

The onboarding setup scripts (scripts/) had two usability gaps in the Azure-to-AWS flow:

  1. Wrong-account failure mode. The Azure-side setup takes the full IAM role ARN, but aws/setup.sh only took a role name and trusted whatever account the shell was authenticated against. Running it in the wrong account's credential context created the role and trust there, and the failure only surfaced later — silently — on the assume-role side.

  2. Buried tenant ID. In the Azure VM flow, the tenant ID (the value the AWS trust step needs) was logged mid-output, after the minutes-long identity assignment, making it easy to miss and hard to copy. A mistyped VM name was also only discovered mid-run, via a raw CLI error from the identity step.

Description of changes

aws/setup.sh now also accepts CWAGENT_AWS_ROLE_ARN. When set, it validates the ARN format, fails fast when the ARN's partition or account does not match the shell's credentials (sts get-caller-identity), and derives the role name from the ARN. A CWAGENT_AWS_ROLE_NAME that disagrees with the ARN is rejected; an agreeing or default-valued one is allowed (the dispatcher always exports the default). The interactive prompt now asks for an ARN, still accepting a plain role name or empty input for the default. A warning is printed if the resulting role differs from the provided ARN (e.g. an existing EC2 instance-profile role takes precedence). Validation runs before any IAM mutation.

azure/setup.sh (azure_vm flow): the az vm show probe now fails fast with a clear message when the VM cannot be found (az's own stderr is preserved so permission or throttling errors are not misread as not-found); the tenant ID is emitted before the slow identity and install steps, so the user can start the AWS side in parallel; and it is repeated at the very end for easy copying — in the install-success message ("Agent installed on in tenant ") and above the next-steps text of the identity-only flow.

README.md: CWAGENT_AWS_ROLE_ARN documented in the common environment variable table.

No breaking changes: all existing inputs and flows behave as before when the new variable is unset.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

  1. Ran make fmt and make fmt-sh
  2. Ran make lint

@EduVencovsky
EduVencovsky requested a review from a team as a code owner September 8, 2026 13:30
MarcoDN
MarcoDN previously approved these changes Sep 8, 2026
Comment thread scripts/aws/setup.sh Outdated
Comment thread scripts/aws/setup.sh Outdated
Comment thread scripts/aws/setup.sh Outdated
Comment thread scripts/aws/setup.sh Outdated
Comment thread scripts/aws/setup.sh
Comment thread scripts/azure/setup.sh Outdated
Comment thread scripts/azure/setup.sh Outdated
@EduVencovsky
EduVencovsky force-pushed the feat/aws-setup-role-arn branch from 64e7565 to 778a087 Compare September 9, 2026 19:14
@EduVencovsky EduVencovsky changed the title Feat/aws setup role arn feat(scripts): make tenant id more prominent and improve logging in setup scripts Sep 9, 2026
Comment thread scripts/aws/setup.sh Outdated
@EduVencovsky
EduVencovsky force-pushed the feat/aws-setup-role-arn branch from 0fb3f90 to c1be627 Compare September 10, 2026 15:10
jefchien
jefchien previously approved these changes Sep 10, 2026
@EduVencovsky
EduVencovsky merged commit 604c66f into main Sep 10, 2026
26 checks passed
@EduVencovsky
EduVencovsky deleted the feat/aws-setup-role-arn branch September 10, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants