what is wrong with this iam role to able to replicate s3 bucket to a remote region's bucket

0

Hello all,

I have the following iam role:

{
	"Statement": [
		{
			"Action": [
				"s3:GetReplicationConfiguration",
				"s3:ListBucket",
				"s3:PutInventoryConfiguration"
			],
			"Effect": "Allow",
			"Resource": [
				"arn:aws:s3::: sourcebucket"
			]
		},
		{
			"Action": [
				"s3:GetObjectVersion",
				"s3:GetObjectVersionAcl",
				"s3:GetObjectVersionForReplication",
				"s3:GetObjectVersionTagging",
				"s3:PutInventoryConfiguration"
			],
			"Effect": "Allow",
			"Resource": [
				"arn:aws:s3::: sourcebucket/*"
			]
		},
		{
			"Effect": "Allow",
			"Action": [
				"s3:GetObject",
				"s3:GetObjectVersion",
				"s3:GetObjectTagging",
				"s3:GetBucketLocation"
			],
			"Resource": [
				"arn:aws:s3:::destinationbucket/*"
			]
		},
		{
			"Effect": "Allow",
			"Action": [
				"s3:GetObject",
				"s3:GetObjectVersion",
				"s3:GetBucketLocation"
			],
			"Resource": [
				"arn:aws:s3:::reportbucket/*"
			]
		},
		{
			"Effect": "Allow",
			"Action": [
				"s3:PutObject",
				"s3:GetBucketLocation"
			],
			"Resource": [
				"arn:aws:s3:::reportbucket/*"
			]
		},
		{
			"Sid": "AllowS3ReplicationSourceRoleToUseTheKey",
			"Effect": "Allow",
			"Action": [
				"kms:GenerateDataKey",
				"kms:Encrypt",
				"kms:Decrypt"
			],
			"Resource": "*"
		},
		{
			"Action": [
				"s3:GetBucketVersioning",
				"s3:PutBucketVersioning",
				"s3:ReplicateObject",
				"s3:ReplicateTags",
				"s3:ReplicateDelete",
				"s3:PutObject",
				"s3:PutObjectAcl",
				"s3:PutObjectTagging",
				"s3:ObjectOwnerOverrideToBucketOwner"
			],
			"Effect": "Allow",
			"Resource": [
				"arn:aws:s3:::sourcebucket",
				"arn:aws:s3:::destinationbucket",
				"arn:aws:s3:::sourcebucket/*",
				"arn:aws:s3:::destinationbucket/*"
			]
		}
	],
	"Version": "2012-10-17"
}

I have velero backups in region A and I would like to replicate them to Region B. they are encrypted by a multi region kms key. Key exists on both region.

Thanks

질문됨 8달 전260회 조회
1개 답변
0

Hi Balazs,

Are you using versioning? (If NO, so skip this)

  • Configure versioning on both the source and destination buckets. This is mandatory for S3 replication.

About KMS:

  • Ensure the KMS key policy in both regions allows the necessary operations from the S3 service. The key policy should allow the IAM role and the S3 service itself to perform kms:Encrypt, kms:Decrypt, kms:ReEncrypt*, kms:GenerateDataKey*, and kms:DescribeKey actions.
{
    "Sid": "AllowS3AndRole",
    "Effect": "Allow",
    "Principal": {
        "Service": "s3.amazonaws.com",
        "AWS": "arn:aws:iam::ACCOUNT_ID:role/IAM_ROLE_NAME"
    },
    "Action": [
        "kms:Encrypt",
        "kms:Decrypt",
        "kms:ReEncrypt*",
        "kms:GenerateDataKey*",
        "kms:DescribeKey"
    ],
    "Resource": "*"
}

In your bucket policy:

  • You might need an S3 bucket policy that grants the source bucket permission to replicate objects to the destination bucket.
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "StmtAllowReplication",
            "Effect": "Allow",
            "Principal": {
                "Service": "s3.amazonaws.com",
                "AWS": "arn:aws:iam::ACCOUNT_ID:role/IAMRoleName"
            },
            "Action": [
                "s3:ReplicateObject",
                "s3:ReplicateDelete",
                "s3:ReplicateTags",
                "s3:GetObjectVersion",
                "s3:GetObjectVersionForReplication"
            ],
            "Resource": "arn:aws:s3:::destinationbucket/*"
        }
    ]
}

Extra checks:

  • Ensure there are no VPC endpoint policies or service control policies
profile picture
답변함 8달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠