Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
s3 cross region replication destination bucket
---
AWSTemplateFormatVersion: '2010-09-09'
Description: S3 Secondary bucket for cross region replication
Parameters:
Environment:
Type: String
Default: dev
AllowedValues:
- dev
- prod
- uat
ReplicationBucketName:
Type: String
Default: secondary-test-1
RepRegion:
Type: String
Default: us-east-1
AllowedValues:
- us-east-1
ReplicationBucketObjectVersioning:
Type: String
Default: Enabled
AllowedValues:
- Suspend
- Enabled
ReplicationBucketObjectVersioningLength:
Type: Number
Default: 21
Conditions:
ReplicationBucketObjectVersioningEnabled:
Fn::Equals:
- Ref: ReplicationBucketObjectVersioning
- Enabled
Resources:
ReplicationBucket:
Type: AWS::S3::Bucket
Properties:
VersioningConfiguration:
Status:
Ref: ReplicationBucketObjectVersioning
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
BucketName: !Sub "${ReplicationBucketName}-${Environment}-bucket"
LifecycleConfiguration:
Fn::If:
- ReplicationBucketObjectVersioningEnabled
- Rules:
- Id: Lifecycle for replication bucket
AbortIncompleteMultipartUpload:
DaysAfterInitiation: !Ref ReplicationBucketObjectVersioningLength
NoncurrentVersionExpirationInDays: !Ref ReplicationBucketObjectVersioningLength
Prefix: ''
Status: Enabled
- Ref: AWS::NoValue
Outputs:
ReplicationBucket:
Value: !Ref ReplicationBucket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment