Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Last active November 6, 2020 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuyasugano/e3943b8d6f636b415132ecb6ac2627ac to your computer and use it in GitHub Desktop.
Save yuyasugano/e3943b8d6f636b415132ecb6ac2627ac to your computer and use it in GitHub Desktop.
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