0
0

More than 1 year has passed since last update.

aws_datasync_location_s3 で Ensure bucket access role has s3:ListBucket permission

Last updated at Posted at 2022-04-09

事象発生条件

  • terraform
  • AWS DataSync利用
  • クロスリージョンのs3が対象
  • DataSyncはコピー先にいる

事象

  • terraformでクロスリージョン間のs3で、aws_datasync_location_s3を利用した時に以下のエラーが発生しました。
could not perform s3:ListObjectsV2 on bucket xxxxxx.
Access denied. Ensure bucket access role has s3:ListBucket permission.

原因

単純にバケットに権限がないのですが、コピー先の場合は、bucket_access_role_arnに権限がないだけなのですが、コピー元の場合は、その限りではありません。

resource "aws_datasync_location_s3" "xxx" {
  s3_bucket_arn = xxxxx
  subdirectory  = "/"

  s3_config {
    bucket_access_role_arn = xxxxxxxx
  }
}

コピー元の場合は、バケットポリシーに権限がありません。
terraformの実行ユーザの権限がバケットポリシーに割り当てられていないと事象のエラーが発生します。
(試していないないですが、terraformの実行ユーザにバケットポリシーで設定した権限があれば大丈夫かと)
以下の部分のarn:aws:iam::1111222233334444:role/datasync-config-roleですね。

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::1111222233334444:role/datasync-config-role",
                    "arn:aws:iam::1111222233334444:role/datasync-transfer-role"
                ]
            },
            "Action": [
                "s3:GetBucketLocation",
                "s3:ListBucket",
                "s3:ListBucketMultipartUploads"
            ],
            "Resource": [
                "arn:aws:s3:::example-source-bucket"
            ]
        },

参考

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