Last active
August 29, 2015 14:06
-
-
Save john-g-g/c543ef45353ed9050aa4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
S3 Bucket Naming Scheme: | |
myBucket/Google/app1/user1 | |
*/ | |
// AWS S3 Policy With Variables | |
var $policy = ' | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": ["s3:ListBucket"], | |
"Resource": ["arn:aws:s3:::herodotus"], | |
"Condition": {"StringLike": {"s3:prefix": ["google/${accounts.google.com:sub/*"]}} | |
}, | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"s3:GetObject", | |
"s3:PutObject" | |
], | |
"Resource": [ | |
"arn:aws:s3:::herodotus/google/${accounts.google.com:sub", | |
"arn:aws:s3:::herodotus/google/${accounts.google.com:sub}/*" | |
] | |
} | |
] | |
}' | |
// for login with google | |
var params = { | |
RoleArn: 'STRING_VALUE', /* required */ | |
RoleSessionName: 'STRING_VALUE', /* required */ | |
WebIdentityToken: 'STRING_VALUE', /* required */ | |
DurationSeconds: 3600, | |
Policy: $policy, | |
ProviderId: 'accounts.google.com' | |
}; | |
$data = sts.assumeRoleWithWebIdentity(params, function(err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment