LoginSignup
2
2

More than 5 years have passed since last update.

特定バケットの読み取り権限のみを与えるIAMポリシーを作りたい

Last updated at Posted at 2018-02-15

S3の決められたバケットのみ読み込めるIAMユーザが必要になったので、ポリシーを作った。

s3-my-bucket-ro.json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::my-bucket/*"
        },
        {
            "Effect": "Allow",
            "Action": "s3:ListBucket",
            "Resource": "arn:aws:s3:::my-bucket"
        }
    ]
}

与える権限は以下の3つで良さそう:

  • GetObject
    • オブジェクトをダウンロードしたりできるやつ
    • リソース指定はオブジェクト単位
  • ListBucket
    • 指定したリソースのオブジェクトを読み込めるやつ
    • リソース指定はバケット単位

これを権限の通った場所から投げればOK

PROFILE=default
POLICY=s3-my-bucket-ro
aws --profile ${PROFILE} iam create-policy \
  --policy-name ${POLICY} \
  --policy-document file://${POLICY}.json
2
2
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
2
2