-
Notifications
You must be signed in to change notification settings - Fork 9
/
log_bucket.yaml
59 lines (52 loc) · 1.49 KB
/
log_bucket.yaml
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
AWSTemplateFormatVersion: 2010-09-09
Description: "Creates an S3 bucket to store logs."
Parameters:
BucketPrefix:
Type: String
Description: The name of the Application or Project using this bucket.
MinLength: 2
ConstraintDescription: "use only lower case letters or numbers"
AllowedPattern: '[a-z0-9\-]+'
KeepBucket:
Type: String
Description: Keep the bucket if the stack is deleted.
AllowedValues:
- 'TRUE'
- 'FALSE'
Default: 'FALSE'
Conditions:
RetainBucket: !Equals [ !Ref KeepBucket, "TRUE" ]
DeleteBucket: !Equals [ !Ref KeepBucket, "FALSE" ]
AlwaysTrue: !Or [!Condition RetainBucket, !Condition DeleteBucket]
AlwaysFalse: !Not [!Condition AlwaysTrue]
Resources:
LogsBucket:
Condition: DeleteBucket
Type: AWS::S3::Bucket
Properties:
BucketName:
!Sub ${BucketPrefix}-logs-${AWS::Region}
RetainLogsBucket:
Condition: RetainBucket
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
BucketName:
!Sub ${BucketPrefix}-logs-${AWS::Region}
DeadLetterQueue:
Condition: AlwaysTrue
Type: AWS::SQS::Queue
# Used for testng
TestBucket:
Condition: AlwaysFalse
Type: AWS::S3::Bucket
Properties:
BucketName:
!Sub "${Foo}-logs-${AWS::Region}"
Outputs:
LogsBucketName:
Condition: AlwaysTrue
Description: Name of the logs bucket.
Value: !If [RetainBucket, !Ref RetainLogsBucket, !Ref LogsBucket]
Export:
Name: !Sub ${BucketPrefix}-LogsBucket