Last active
July 18, 2021 23:09
-
-
Save andrewp-as-is/a1b85e11c00630b995f9c51479681e08 to your computer and use it in GitHub Desktop.
AWS IAM put-user-policy
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
#!/usr/bin/env bash | |
USER_NAME="test-user" | |
POLICY_NAME="policy-name" | |
aws iam create-user --user-name "$USER_NAME" 2> /dev/null | |
# https://docs.aws.amazon.com/cli/latest/reference/iam/put-user-policy.html | |
# IAM -> Users -> User -> Permissions -> Add inline policy | |
aws iam put-user-policy --user-name "$USER_NAME" --policy-name "$POLICY_NAME" --policy-document file://user-policy.json | |
# User Policy Examples: | |
# https://docs.aws.amazon.com/AmazonS3/latest/dev/example-policies-s3.html#iam-policy-ex0 | |
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
{ | |
"Version":"2012-10-17", | |
"Statement":[ | |
{ | |
"Effect":"Allow", | |
"Action":[ | |
"s3:ListBucket", | |
"s3:GetBucketLocation" | |
], | |
"Resource":"arn:aws:s3:::BUCKET_NAME" | |
}, | |
{ | |
"Effect":"Allow", | |
"Action":[ | |
"*" | |
], | |
"Resource":"arn:aws:s3:::BUCKET_NAME/*" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment