LoginSignup
0
0

More than 5 years have passed since last update.

S3のバケットにアクセス権を設定する

Last updated at Posted at 2016-10-07

概要

IAMユーザーにS3バケットに対するユーザーポリシーを設定します。

特定のバケット(hoge1, hoge2)だけ読み書きを許可する

IAM_User_Policy
{
  "Statement": [
    {
      "Action": "s3:ListAllMyBuckets",
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::*"
    },
    {
      "Action": "s3:*",
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::hoge1",
        "arn:aws:s3:::hoge1/*",
        "arn:aws:s3:::hoge2",
        "arn:aws:s3:::hoge2/*"
      ]
    }
  ]
}

特定のバケット(hoge1, hoge2)以外読み書き許可する

IAM_User_Policy
{
  "Statement": [
    {
      "Action": "s3:ListAllMyBuckets",
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::*"
    },
    {
      "Action": "s3:*",
      "Effect": "Allow",
      "NotResource": [
        "arn:aws:s3:::hoge1",
        "arn:aws:s3:::hoge1/*",
        "arn:aws:s3:::hoge2",
        "arn:aws:s3:::hoge2/*"
      ]
    }
  ]
}

特定のバケット(hoge1, hoge2)だけ書き込みのみを許可する

IAM_User_Policy
{
  "Statement": [
    {
      "Action": "s3:ListAllMyBuckets",
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::*"
    },
    {
      "Action": [
        "s3:PutObject",
        "s3:PutObjectAcl"
      ],
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::hoge1",
        "arn:aws:s3:::hoge1/*",
        "arn:aws:s3:::hoge2",
        "arn:aws:s3:::hoge2/*"
      ]
    }
  ]
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0