File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -1042,7 +1042,22 @@ async function _fetchEC2RoleCredentials() {
1042
1042
async function _fetchWebIdentityCredentials ( r ) {
1043
1043
var arn = process . env [ 'AWS_ROLE_ARN' ] ;
1044
1044
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
+
1046
1061
var token = fs . readFileSync ( process . env [ 'AWS_WEB_IDENTITY_TOKEN_FILE' ] ) ;
1047
1062
1048
1063
var params = "Version=2011-06-15&Action=AssumeRoleWithWebIdentity&RoleArn=" + arn + "&RoleSessionName=" + name + "&WebIdentityToken=" + token ;
You can’t perform that action at this time.
0 commit comments