Skip to content
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

Make region optional #431

Closed
wants to merge 2 commits into from
Closed

Conversation

nitrocode
Copy link

Issue #, if available:

Description of changes:

This will continue retrieving the region using the aws-region but if it is not provided, it will retrieve it from the AWS_REGION environment variable.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@@ -13,6 +13,7 @@ const MAX_TAG_VALUE_LENGTH = 256;
const SANITIZATION_CHARACTER = '_';
const ROLE_SESSION_NAME = 'GitHubActions';
const REGION_REGEX = /^[a-z0-9-]+$/g;
const AWS_CURRENT_REGION = process.env.AWS_REGION
Copy link
Author

Choose a reason for hiding this comment

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

or should this be AWS_DEFAULT_REGION ?

Choose a reason for hiding this comment

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

I don't think so; you want to be able to override the default region, which is what AWS_REGION is for

Copy link
Contributor

@peterwoodworth peterwoodworth left a comment

Choose a reason for hiding this comment

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

Thanks a bunch for the submission @nitrocode!

In addition to my comments, could we be sure to update the README? I'd like to document that you don't have to supply this parameter anymore in the README, and explaining the functionality of the environment variables AWS_REGION and AWS_DEFAULT_REGION

@@ -13,6 +13,7 @@ const MAX_TAG_VALUE_LENGTH = 256;
const SANITIZATION_CHARACTER = '_';
const ROLE_SESSION_NAME = 'GitHubActions';
const REGION_REGEX = /^[a-z0-9-]+$/g;
const AWS_CURRENT_REGION = process.env.AWS_REGION
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't set this as a global variable - instead use process.env where the value is needed.

@@ -264,7 +265,7 @@ async function run() {
// Get inputs
const accessKeyId = core.getInput('aws-access-key-id', { required: false });
const secretAccessKey = core.getInput('aws-secret-access-key', { required: false });
const region = core.getInput('aws-region', { required: true });
const region = core.getInput('aws-region', { required: false }) || AWS_CURRENT_REGION;
Copy link
Contributor

Choose a reason for hiding this comment

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

Like I mentioned above, we should use process.env.XXX instead of a global variable (after all you're only using it on this line)

To add on to the discussion above regarding AWS_REGION vs AWS_DEFAULT_REGION... why not both? Action input > AWS_REGION > AWS_DEFAULT_REGION should work here no?

Copy link
Contributor

@peterwoodworth peterwoodworth left a comment

Choose a reason for hiding this comment

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

We will also need to add a test to verify that this works 🙂

@peterwoodworth
Copy link
Contributor

Closing this as stale. If you wish to reopen, please submit a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supplying region should be optional
3 participants