-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yaml
129 lines (120 loc) · 3.85 KB
/
config.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
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
EnvironmentName:
Description: An environment name that will be prefixed to resource names
Type: String
Resources:
WebACL:
Type: AWS::WAFv2::WebACL
Properties:
DefaultAction:
Allow: {}
Scope: CLOUDFRONT
VisibilityConfig:
CloudWatchMetricsEnabled: true
MetricName: webACL
SampledRequestsEnabled: true
Rules:
- Name: ExampleRule
Priority: 1
Action:
Block: {}
Statement:
RateBasedStatement:
Limit: 2000
AggregateKeyType: IP
VisibilityConfig:
CloudWatchMetricsEnabled: true
MetricName: exampleRule
SampledRequestsEnabled: true
#GuardDuty
GuardDutyDetector:
Type: AWS::GuardDuty::Detector
Properties:
Enable: true
# Create S3 Bucket for CloudTrail logs
CloudTrailS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${AWS::AccountId}-cloudtrail-logs
VersioningConfiguration:
Status: Enabled
CloudTrailBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref CloudTrailS3Bucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: cloudtrail.amazonaws.com
Action: s3:PutObject
Resource: !Sub arn:aws:s3:::${AWS::AccountId}-cloudtrail-logs/AWSLogs/${AWS::AccountId}/*
Condition:
StringEquals:
s3:x-amz-acl: bucket-owner-full-control
- Effect: Allow
Principal:
Service: cloudtrail.amazonaws.com
Action: s3:GetBucketAcl
Resource: !Sub arn:aws:s3:::${AWS::AccountId}-cloudtrail-logs
CloudTrailRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: cloudtrail.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: CloudTrailPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- s3:PutObject
- s3:GetBucketAcl
- 's3:GetBucketLocation'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
- 'logs:CreateLogGroup'
- 'logs:DescribeLogGroups'
- 'logs:DescribeLogStreams'
Resource:
- !Sub 'arn:aws:s3:::${AWS::AccountId}-cloudtrail-logs/*'
- !Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:CloudTrail/LogGroup'
- !Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:CloudTrail/LogGroup:*'
CloudWatchLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: CloudTrail/LogGroup
CloudTrail:
Type: AWS::CloudTrail::Trail
Properties:
TrailName: CloudTrail
S3BucketName: !Ref CloudTrailS3Bucket
IncludeGlobalServiceEvents: true
IsMultiRegionTrail: true
EnableLogFileValidation: true
CloudWatchLogsLogGroupArn: !GetAtt CloudWatchLogGroup.Arn
CloudWatchLogsRoleArn: !GetAtt CloudTrailRole.Arn
IsLogging: true
DependsOn:
- CloudTrailRole
- CloudTrailBucketPolicy
# Create SecurityHub
SecurityHub:
Type: AWS::SecurityHub::Hub
Properties:
EnableDefaultStandards: true
ControlFindingGenerator: SECURITY_CONTROL
Outputs:
WebACLArn:
Value: !GetAtt WebACL.Arn
Description: The ARN of the Web ACL
SecurityHubArn:
Value: !Ref SecurityHub