Skip to content

feat(aws): accept role name and resolve account ID at deploy time - #959

Merged
vladhsu merged 3 commits into
mainfrom
vhs/variable-role
Oct 8, 2026
Merged

vladhsu merged 3 commits into
mainfrom
vhs/variable-role

Conversation

@vladhsu

@vladhsu vladhsu commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Description

--aws-role (awsRole) now accepts a plain IAM role name in addition to a full ARN. If the value does not start with arn:, it is expanded at deploy time to arn:aws:iam::<accountId>:role/<name>, using the account ID already resolved via STS GetCallerIdentity (initAccountId()).

  • src/deploy/AWSDeployer.js: new roleArn getter, used for the Lambda Role and the "using lambda role" log line.
  • src/deploy/AWSConfig.js: updated the --aws-role help text.

How Has This Been Tested?

  • test/aws.deployer.test.js:
    • role name is expanded to arn:aws:iam::<accountId>:role/<name> (STS mocked via nock)
    • full ARN from a different account is passed through unchanged
  • test/cli.test.js: !important value containing ${env.X} is substituted and wins over a competing HLX_* env var

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Comment thread test/cli.test.js
process.env.CUSTOM_ENV_VAR = 'helix-generic-role';
const builder = await new CLI()
// eslint-disable-next-line no-template-curly-in-string
.prepare(['--test!important', '${env.CUSTOM_ENV_VAR}']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that we want to support
"aws-role!important": "$HLX_MY_ROLE" ??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with  ${env.VARIABLE}  because helix-deploy already supports it, so it was the smallest change, but I can add  $VARIABLE  support if that format is preferred.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the logic for "aws-role!important": "$HLX_MY_ROLE", please take a look when you have time @tripodsan @dominique-pfister

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

This PR will trigger a minor release when merged.

Comment thread src/cli.js Outdated
Comment on lines +110 to +119
const substitute = (value) => {
if (typeof value !== 'string') {
return value;
}
const match = value.match(/^\$([A-Za-z_][A-Za-z0-9_]*)$/);
if (match && match[1] in process.env) {
return process.env[match[1]];
}
return ActionBuilder.substitute(value, envVars);
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, sorry, I didn't remember that we already had this built in... so I guess the ${var} is not needed....

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just keep the existing. sorry again for the extra work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the commit, now it should be ready to merge

@vladhsu
vladhsu merged commit 827fad2 into main Oct 8, 2026
5 checks passed
@vladhsu
vladhsu deleted the vhs/variable-role branch October 8, 2026 07:41
@tripodsan

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 14.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants