-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbaseline-log.yaml
153 lines (142 loc) · 4.34 KB
/
baseline-log.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
AWSTemplateFormatVersion: 2010-09-09
Description: Baseline IAM resources for new account
Parameters:
s3cloudtrailbucketName:
Type: String
Description: Bucket Name for cloudtrail
s3configbucketName:
Type: String
Description: Bucket Name for config
s3loggingBucketName:
Type: String
Description: Logging Bucket name
NewRoleArn:
Type: String
Description: ARN of the NewRole
SSEAlgorithm:
Type: 'String'
Default: 'AES256'
Description: S3 bucket SSE Algorithm.
AllowedValues:
- 'AES256'
Resources:
# Create buckets using S3-SSE keys for default encryption
S3LoggingBucket:
DeletionPolicy: Retain
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref s3loggingBucketName
AccessControl: LogDeliveryWrite
VersioningConfiguration:
Status: Enabled
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: !Ref SSEAlgorithm
S3CloudtrailBucket:
DeletionPolicy: Retain
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref s3cloudtrailbucketName
VersioningConfiguration:
Status: Enabled
LoggingConfiguration:
DestinationBucketName: !Ref S3LoggingBucket
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: !Ref SSEAlgorithm
S3ConfigBucket:
DeletionPolicy: Retain
DependsOn:
- S3CloudtrailBucket
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref s3configbucketName
VersioningConfiguration:
Status: Enabled
LoggingConfiguration:
DestinationBucketName: !Ref S3LoggingBucket
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: !Ref SSEAlgorithm
S3CloudtrailBucketPolicy:
Type: AWS::S3::BucketPolicy
DependsOn:
- S3CloudtrailBucket
Properties:
Bucket: !Ref s3cloudtrailbucketName
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: AWSBucketPermissionsCheck
Effect: Allow
Principal:
Service:
- cloudtrail.amazonaws.com
Action: s3:GetBucketAcl
Resource:
- !Sub "arn:aws:s3:::${s3cloudtrailbucketName}"
- Sid: AWSBucketDelivery
Effect: Allow
Principal:
Service:
- cloudtrail.amazonaws.com
Action: s3:PutObject
Resource:
- Fn::Join:
- ""
-
- "arn:aws:s3:::"
- !Ref "s3cloudtrailbucketName"
- "/AWSLogs/*/*"
S3ConfigBucketPolicy:
Type: AWS::S3::BucketPolicy
DependsOn:
- S3ConfigBucket
Properties:
Bucket: !Ref s3configbucketName
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: AWSBucketPermissionsCheck
Effect: Allow
Principal:
Service:
- config.amazonaws.com
Action: s3:GetBucketAcl
Resource:
- !Sub "arn:aws:s3:::${ s3configbucketName}"
- Sid: AWSBucketDelivery
Effect: Allow
Principal:
Service:
- config.amazonaws.com
Action: s3:PutObject
Resource:
- Fn::Join:
- ""
-
- "arn:aws:s3:::"
- !Ref "s3configbucketName"
- "/AWSLogs/*/*"
SecurityHub:
Type: AWS::SecurityHub::Hub
Properties:
Tags:
key1: landingzone
key2: true
Outputs:
CloudtrailBucketName:
Description: AWS Landing Zone logging bucket name
Value: !Ref S3CloudtrailBucket
ConfigBucketName:
Description: AWS Landing Zone logging bucket name
Value: !Ref S3ConfigBucket
LoggingBucketName:
Description: AWS Landing Zone s3 access logs bucket name
Value: !Ref S3LoggingBucket
Role:
Description: Role Arn
Value: !Ref NewRoleArn