Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save groundcat/8778016a8afdaf4aab801864be79719e to your computer and use it in GitHub Desktop.

Select an option

Save groundcat/8778016a8afdaf4aab801864be79719e to your computer and use it in GitHub Desktop.
IAM Users - Allows Read and Write Access to S3 Bucket

Step 1. Create IAM user

https://console.aws.amazon.com/iam/home#/users

For example, user is arn:aws:iam::AccountA-ID:user/Dave.

Step 2. Create IAM user policy

Add as JSON, under permission tab:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ListObjectsInBucket",
            "Effect": "Allow",
            "Action": ["s3:ListBucket"],
            "Resource": ["arn:aws:s3:::bucket-name"]
        },
        {
            "Sid": "AllObjectActions",
            "Effect": "Allow",
            "Action": "s3:*Object",
            "Resource": ["arn:aws:s3:::bucket-name/*"]
        }
    ]
}

Step 3. Create bucket

Bucket policy:

{
   "Version": "2012-10-17",
   "Statement": [
      {
         "Sid": "statement1",
         "Effect": "Allow",
         "Principal": {
            "AWS": "arn:aws:iam::AccountA-ID:user/Dave"
         },
         "Action": [
            "s3:GetBucketLocation",
            "s3:ListBucket"
         ],
         "Resource": [
            "arn:aws:s3:::examplebucket"
         ]
      },
      {
         "Sid": "statement2",
         "Effect": "Allow",
         "Principal": {
            "AWS": "arn:aws:iam::AccountA-ID:user/Dave"
         },
         "Action": [
             "s3:GetObject"
         ],
         "Resource": [
            "arn:aws:s3:::examplebucket/*"
         ]
      }
   ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment