-
Notifications
You must be signed in to change notification settings - Fork 824
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
fix(amplify-provider-awscloudformation): Ensure the right profile is used with SSO and with credential_process #9095
Conversation
Note: The way the current fix works it assumes that if |
@sachscode Anything we can do to help get this merged? It's preventing me from moving to 8.x |
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.
The Change looks good. Could you please add a unit test for the update.
@sachscode If you can help point me in the right direction I can try, but not really sure where to start |
Hi @johnf
If this newly added code changes in the future or any new code branches are added, then the unit-test hopefully breaks and future devs can update the unit-test accordingly. Please let me know if you have any other questions. |
…SO and credential_process Make sure the right profile is used when using credential_process When using credential_process in the AWS profile (to get SSO to work for example) the ProcessCredentials Provider is used. When using the default chain from the aws-sdk no options are passed to it and it default to using AWS_PROFILE. With this change, we detect ```credential_process``` and specifically pass the profile name into the credential chain to ensure it gets used. re aws-amplify#4488
861c6f6
to
8165834
Compare
@sachscode thanks for the pointers. I've added some extra assertions. We know it's the last one so I could mock ProcessCredentials and call the last entry in the array and ensure it's called. BUt that felt a bit brittle. |
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.
LGTM
Description of changes
When using credential_process in the AWS profile (to get SSO to work for example) the ProcessCredentials Provider is used.
When using the default chain from the aws-sdk no options are passed to it and it default to using AWS_PROFILE.
With this change, we detect
credential_process
and specifically pass the profile name into the credential chain to ensure it gets used.The problem this solves for me is when using multiple environments.
When adding an environment with
aws env add
even though a profile is picked, if it is using credential_process it won't be used.In my patrticular use case the environments are in multiple accounts.
I suspect most people are using environments in the same account and have an AWS_PROFILE set so the default fallback works.
I haven't added any tests but could attempt it given some guidance.
Issue
#4488 is an example where the workaround suggest setting AWS_PROFILE, which should be unnecessary.
Description of how you validated changes
Both environments are created without any auth errors
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.