feat: aws region is optional, use global sts endpoint when not set

This commit is contained in:
peterwoodworth
2023-03-15 14:12:01 -07:00
parent f9f25e69f5
commit f6fdf0cdbd
4 changed files with 18 additions and 10 deletions
+10 -4
View File
@@ -14,7 +14,10 @@ export async function run() {
const SecretAccessKey = core.getInput('aws-secret-access-key', { required: false });
const sessionTokenInput = core.getInput('aws-session-token', { required: false });
const SessionToken = sessionTokenInput === '' ? undefined : sessionTokenInput;
const region = core.getInput('aws-region', { required: true });
const region =
core.getInput('aws-region', { required: false }) ||
process.env['AWS_REGION'] ||
process.env['AWS_DEFAULT_REGION'];
const roleToAssume = core.getInput('role-to-assume', { required: false });
const audience = core.getInput('audience', { required: false });
const maskAccountId = core.getInput('mask-aws-account-id', { required: false });
@@ -54,10 +57,13 @@ export async function run() {
};
// Validate and export region
if (!region.match(REGION_REGEX)) {
throw new Error(`Region is not valid: ${region}`);
if (region) {
core.info('Using global STS endpoint');
if (!region.match(REGION_REGEX)) {
throw new Error(`Region is not valid: ${region}`);
}
exportRegion(region);
}
exportRegion(region);
// Instantiate credentials client
const credentialsClient = new CredentialsClient({ region, proxyServer });