0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

S3のアクセスを特定のサービスロールに制限する

Posted at

概要

AWSのS3に設定するバケットポリシーのお話です。
2パターン用意したので好きな方使うとよいです。

特定のサービスロールのみを許可する方法

{
    "Version": "2012-10-17",
    "Id": "{POLICY_ID}",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::{ACCOUNT_ID}:role/{ROLE_NAME}"
                ]
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::{REPOSITORY_NAME}/*"
        }
    ]
}

特定のAWSアカウントからのサービスロールを全て許可する方法

{
    "Version": "2012-10-17",
    "Id": "{POLICY_ID}",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "*"
                ]
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::{REPOSITORY_NAME}/*",
            "Condition": {
                "ArnLike": {
                    "aws:PrincipalArn": [
                        "arn:aws:iam::{ACCOUNT_ID}:role/*"
                    ]
                }
            }
        }
    ]
}

備考

1個目で{ROLE_NAME}にワイルドカード設定すればいけそうなもんだけどダメでした。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?