-
Notifications
You must be signed in to change notification settings - Fork 59
Support setting AWS_ROLE_ARN via env var for aws-cli/setup #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Support setting AWS_ROLE_ARN via env var for aws-cli/setup #237
Conversation
|
To approve this, add information about the default value in the description. It's important to tell this is going to be a default, specially because the existence of that parameter decides whether or not to use OIDC auth. If someone doesn't want to use OIDC and they have that environment variable, they would have to set it manually to an empty string. |
|
Good feedback, thanks! I tried to document the new behavior as explicitly as possible and added an additional |
| Installs aws-cli and then configure and store AWS credentials in | ||
| ~/.aws/credentials and ~/.aws/config. | ||
| If role_session_name and role_arn are provided, it will attempt to use OIDC auth. | ||
| If role_arn is set, either explicitly or by the value of $AWS_ROLE_ARN, this command will attempt to use OIDC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dropped the reference to role_session_name here because it's being provided by default already (default value is $CIRCLE_JOB with unsupported chars replaced and truncated to 64 chars)
|
With the tests I realized something, the role ARN is going to be empty only on the script. For the workflow this implementation is always setting a value, making the parameter you created the only way to decide if the OIDC is being used. So by default this will try to always use OIDC, unless the parameter is set. |
|
Sorry for the slow reply. I was trying to make sense of what was going on. It's odd to me because the error message for all of the failed integration tests is That surprises me because the CircleCI docs on logic statements has empty strings being considered falsy. I added an additional condition to check that the param is explicitly not equal to an empty string to try to resolve this. Unfortunately I'm lacking the referenced I might still try to sort through replicating those contexts on my end, though. I agree that I don't want this change to cause any material issues for anyone else. |
|
The role_arn will never be an empty string, because the condition is evaluated before the value is expanded. For the when, |
Ahhh, so it's evaluation timing. Thanks for that clarification! |
|
I think the latest commit would technically address this issue. However, I understand entirely if you'd prefer to forgo this change altogether. I'll admit that this feels a little fiddly at this point. The behavior overall does match the updated description ("If role_arn is set, either explicitly or by the value of $AWS_ROLE_ARN, this command will attempt to use OIDC auth..."), but it's kind of wonky to still attempt to execute the role assumption step and then exit from the script. |
Checklist
Motivation, issues
Reduce boilerplate config when using OIDC roles. We set AWS_ROLE_ARN but currently have to set the following where OIDC roles are used:
With this change, it would be possible to use
aws-cli/setupdirectly as below, assuming $AWS_ROLE_ARN is set.At a glance, it looks like this orb tries to support many of the same aws-cli ENV vars where it makes sense. In this case, AWS_ROLE_ARN is also an AWS CLI env var, so that aspect matches existing behavior.
That said, the AWS_ROLE_ARN param is usually used in conjunction with AWS_WEB_IDENTITY_TOKEN_FILE env var to implicitly use web identity creds, whereas the orb explicitly assumes the web identity and pulls the resulting access key/creds from it. So the behavior diverges a bit there.
Supporting AWS_ROLE_ARN would be a nice touch for usability/DRYing config, though.
Description
For the
aws-cli/setupcommand, default the role_arn param to $AWS_ROLE_ARN.