Skip to content

Instantly share code, notes, and snippets.

@john-g-g
Last active August 29, 2015 14:06
Show Gist options
  • Save john-g-g/c543ef45353ed9050aa4 to your computer and use it in GitHub Desktop.
Save john-g-g/c543ef45353ed9050aa4 to your computer and use it in GitHub Desktop.
/*
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