-
-
Save jorgetovar/6420046bcd91836d383c185eac674e0b to your computer and use it in GitHub Desktop.
AWS S3 Replication (Cross-Region / Cross-Account)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: 'AWS::Serverless-2016-10-31' | |
Resources: | |
ReplicationRole: | |
Type: 'AWS::IAM::Role' | |
Properties: | |
AssumeRolePolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
- Effect: 'Allow' | |
Principal: | |
Service: 's3.amazonaws.com' | |
Action: 'sts:AssumeRole' | |
Policies: | |
- PolicyName: 'ReplicationPolicy' | |
PolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
- Effect: 'Allow' | |
Action: | |
- 's3:GetBucketVersioning' | |
- 's3:ListBucket' | |
- s3:GetReplicationConfiguration | |
- s3:GetObjectVersionForReplication | |
- s3:GetObjectVersionAcl | |
- s3:GetObjectVersionTagging | |
- s3:GetObjectRetention | |
- s3:GetObjectLegalHold | |
Resource: '*' | |
- Effect: 'Allow' | |
Action: | |
- 's3:ReplicateObject' | |
- 's3:ReplicateDelete' | |
- 's3:ReplicateTags' | |
- 's3:GetObjectVersionTagging' | |
- 's3:ObjectOwnerOverrideToBucketOwner' | |
Resource: '*' | |
BucketSource: | |
Type: 'AWS::S3::Bucket' | |
Properties: | |
VersioningConfiguration: | |
Status: 'Enabled' | |
ReplicationConfiguration: | |
Role: !GetAtt ReplicationRole.Arn | |
Rules: | |
- Destination: | |
Bucket: !GetAtt BucketReplica.Arn | |
Prefix: '' | |
Status: 'Enabled' | |
BucketName: 'aws-community-builders-source' | |
BucketReplica: | |
Type: 'AWS::S3::Bucket' | |
Properties: | |
VersioningConfiguration: | |
Status: 'Enabled' | |
BucketName: 'aws-community-builders-replica' | |
BucketReplicaPolicy: | |
Type: AWS::S3::BucketPolicy | |
Properties: | |
Bucket: !Ref BucketReplica | |
PolicyDocument: | |
Version: 2012-10-17 | |
Statement: | |
- Sid: "Object Level Permissions" | |
Effect: "Allow" | |
Principal: | |
AWS: !GetAtt ReplicationRole.Arn | |
Action: | |
- "s3:ReplicateObject" | |
- "s3:ReplicateDelete" | |
Resource: !Sub "arn:aws:s3:::${BucketReplica}/*" | |
- Sid: "Bucket Level Permissions" | |
Effect: "Allow" | |
Principal: | |
AWS: !GetAtt ReplicationRole.Arn | |
Action: | |
- "s3:List*" | |
- "s3:GetBucketVersioning" | |
- "s3:PutBucketVersioning" | |
Resource: !Sub "arn:aws:s3:::${BucketReplica}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment