Skip to content

Instantly share code, notes, and snippets.

@anibalsolon
Created June 19, 2018 20:15
Show Gist options
  • Save anibalsolon/f7586a85942792432e98470c512588b9 to your computer and use it in GitHub Desktop.
Save anibalsolon/f7586a85942792432e98470c512588b9 to your computer and use it in GitHub Desktop.
Instance profile w/ role to access all S3 buckets
#!/bin/bash
echo '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "ec2.amazonaws.com"},
"Action": "sts:AssumeRole"
}
]
}' > /tmp/ec2-role-trust-policy.json
aws iam create-role --role-name nipype-pol --assume-role-policy-document /tmp/ec2-role-trust-policy.json
echo '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:*"],
"Resource": ["*"]
}
]
}' > /tmp/ec2-role-access-policy.json
aws iam put-role-policy --role-name nipype-pol --policy-name nipype-pol --policy-document /tmp/ec2-role-access-policy.json
aws iam create-instance-profile --instance-profile-name nipype-pol-profile
aws iam add-role-to-instance-profile --instance-profile-name nipype-pol-profile --role-name nipype-pol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment