forked from org-formation/org-formation-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
guardduty.yml
111 lines (94 loc) · 3.13 KB
/
guardduty.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
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
AWSTemplateFormatVersion: '2010-09-09-OC'
# Include file that contains Organization Section.
# The Organization Section describes Accounts, Organizational Units, etc.
Organization: !Include ../organization.yml
# Any Binding that does not explicitly specify a region will default to this.
# Value can be either string or list
DefaultOrganizationBindingRegion: eu-central-1
# Section contains a named set of Bindings.
# Bindings determine what resources are deployed where
# These bindings can be !Ref'd from the Resources in the resource section
OrganizationBindings:
# Binding for: Detector (needs to be MasterAccount + MemberAccounts)
GuardDutyAllBinding:
Account: '*'
IncludeMasterAccount: true
# Binding for: Master
GuardDutyMemberBinding:
Account: '*'
# Binding for: Member, FindingRule, FindingTopic, FindingTopicPolicy
GuardDutyMasterBinding:
IncludeMasterAccount: true
Parameters:
resourcePrefix:
Type: String
Default: my
findingSubscriptionProtocol:
Type: String
Default: email
findingSubscriptionEndpoint:
Type: String
Default: !GetAtt AWSAccount.RootEmail
Resources:
Detector:
Type: AWS::GuardDuty::Detector
OrganizationBinding: !Ref GuardDutyAllBinding
Properties:
Enable: true
FindingPublishingFrequency: FIFTEEN_MINUTES
Master:
DependsOnAccount: !Ref MasterAccount
Type: AWS::GuardDuty::Master
OrganizationBinding: !Ref GuardDutyMemberBinding
Properties:
DetectorId: !Ref Detector
MasterId: !Ref MasterAccount
# be aware that changing the logicalName for a AWS::GuardDuty::Master resource
# might result in an error. workaround is to remove the resource and then add it.
Member:
Type: AWS::GuardDuty::Member
OrganizationBinding: !Ref GuardDutyMasterBinding
ForeachAccount: !Ref GuardDutyMemberBinding
Properties:
DetectorId: !Ref Detector
Email: !GetAtt CurrentAccount.RootEmail
MemberId: !Ref CurrentAccount
Status: Invited
DisableEmailNotification: true
FindingRule:
Type: AWS::Events::Rule
DependsOn: FindingsTopicPolicy
OrganizationBinding: !Ref GuardDutyMasterBinding
Properties:
Name: !Sub '${resourcePrefix}-guardduty-findings-rule'
EventPattern:
source:
- aws.guardduty
Targets:
- Id: FindingsTopic
Arn: !Ref FindingsTopic
State: ENABLED
FindingsTopic:
Type: AWS::SNS::Topic
OrganizationBinding: !Ref GuardDutyMasterBinding
Properties:
DisplayName: GuardDuty Findings
TopicName: !Sub '${resourcePrefix}-guardduty-findings-notification'
Subscription:
- Protocol: !Ref findingSubscriptionProtocol
Endpoint: !Ref findingSubscriptionEndpoint
FindingsTopicPolicy:
Type: AWS::SNS::TopicPolicy
OrganizationBinding: !Ref GuardDutyMasterBinding
Properties:
Topics:
- !Ref FindingsTopic
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: AllowEventsPublish
Effect: Allow
Principal:
Service: events.amazonaws.com
Action: sns:Publish
Resource: !Ref FindingsTopic