Skip to content

Commit b8319bc

Browse files
djnalluridekobon
authored andcommitted
Support for regional STS endpoint detection
1 parent 8a5a950 commit b8319bc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

common/etc/nginx/include/s3gateway.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,22 @@ async function _fetchEC2RoleCredentials() {
10421042
async function _fetchWebIdentityCredentials(r) {
10431043
var arn = process.env['AWS_ROLE_ARN'];
10441044
var name = process.env['HOSTNAME'] || 'nginx-s3-gateway';
1045-
var sts_endpoint = process.env['STS_ENDPOINT'] || 'https://sts.amazonaws.com';
1045+
1046+
var sts_endpoint = process.env['STS_ENDPOINT'];
1047+
if (!sts_endpoint) {
1048+
var sts_regional = process.env['AWS_STS_REGIONAL_ENDPOINTS'] || 'global';
1049+
if (sts_regional === 'regional') {
1050+
var region = process.env['AWS_REGION'];
1051+
if (region) {
1052+
sts_endpoint = 'https://sts.' + region + '.amazonaws.com';
1053+
} else {
1054+
throw 'Missing required AWS_REGION env variable';
1055+
}
1056+
} else {
1057+
sts_endpoint = 'https://sts.amazonaws.com';
1058+
}
1059+
}
1060+
10461061
var token = fs.readFileSync(process.env['AWS_WEB_IDENTITY_TOKEN_FILE']);
10471062

10481063
var params = "Version=2011-06-15&Action=AssumeRoleWithWebIdentity&RoleArn=" + arn + "&RoleSessionName=" + name + "&WebIdentityToken=" + token;

0 commit comments

Comments
 (0)