Skip to content

Commit

Permalink
fix: read profile from env vars (AWS SDK v3 doesn't provide that info)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Jan 18, 2024
1 parent 5608424 commit df5049c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/cwp-template-aws/cli/aws/checkCredentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module.exports = {
const config = sts.config;
const region = await config.region();

// With AWS-SDK v3, we can no longer read the loaded profile. We try to read if from env var instead.
const profile = process.env.AWS_PROFILE || "default";

try {
await sts.getCallerIdentity({});
} catch (err) {
Expand Down Expand Up @@ -44,7 +47,7 @@ module.exports = {
// We assign the region to the appropriate ENV variable for easier access in the stack definition files.
process.env.AWS_REGION = region;

const { profile, accessKeyId } = await config.credentials();
const { accessKeyId } = await config.credentials();

if (profile) {
context.info(`Using profile ${green(profile)} in ${green(region)} region.`);
Expand Down

0 comments on commit df5049c

Please sign in to comment.