Skip to content

Commit

Permalink
fix(amplify-provider-awscloudformation): Ensure the right profile is …
Browse files Browse the repository at this point in the history
…used with SSO and with 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
  • Loading branch information
johnf committed Nov 26, 2021
1 parent 6e1494a commit 861c6f6
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ export async function getProfiledAwsConfig(context: $TSContext, profileName: str
...profileConfig,
...roleCredentials,
};

if (profileConfig.credential_process) {
const chain = new aws.CredentialProviderChain();
const processProvider = () => new aws.ProcessCredentials({ profile: profileName });
chain.providers.push(processProvider);

awsConfigInfo.credentialProvider = chain;
}
} else {
logger('getProfiledAwsConfig.getProfileCredentials', [profileName]);
const profileCredentials = getProfileCredentials(profileName);
Expand Down

0 comments on commit 861c6f6

Please sign in to comment.