-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployment-alt-region.cfn.yml
64 lines (58 loc) · 1.7 KB
/
deployment-alt-region.cfn.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Conditions:
# Lambda@Edge functions need to be created in us-east-1; in order for this to be redundant it must be somewhere else
WrongRegion: !Equals [!Ref 'AWS::Region', us-east-1]
Resources:
# ==============
# Region validation
# ==============
YouAreInTheWrongRegion:
Type: "AWS::SSM::Parameter"
Condition: WrongRegion
Properties:
Name: '' # Leave name empty to force a fail
Type: String
Value: ''
# ==============
# static frontend S3 / Cloudfront
# ==============
ReplicaBucket:
Type: "AWS::S3::Bucket"
Properties:
BucketName: !Sub ${AWS::StackName}-replica-bucket
VersioningConfiguration:
Status: "Enabled"
LifecycleConfiguration:
Rules:
- Id: MustHaveVersioningButDoNotWantOldVersions
NoncurrentVersionExpirationInDays: 1
Status: "Enabled"
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- '*'
AllowedMethods:
- GET
AllowedOrigins:
- '*'
WebsiteConfiguration:
IndexDocument: "doesnt-exist.html"
PublicAccessBlockConfiguration:
BlockPublicPolicy: false
ReplicaBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: PublicReadForGetBucketObjects
Effect: Allow
Principal: '*'
Action:
- s3:GetObject
Resource: !Sub arn:aws:s3:::${AWS::StackName}-replica-bucket/*
Bucket: !Ref ReplicaBucket
Outputs:
ReplicaBucketName:
Value: !Ref ReplicaBucket
ReplicaBucketWebsiteURL:
Value: !GetAtt ReplicaBucket.WebsiteURL