-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.yaml
111 lines (104 loc) · 3.35 KB
/
template.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
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Metadata:
AWS::ServerlessRepo::Application:
Name: cloudone-application-security-sns-to-aws-securityhub
Description: >-
Serverless application to publish findings from Trend Micro's Cloud One Application Security to AWS Security Hub
Author: Tom Ryan
SpdxLicenseId: MIT
LicenseUrl: LICENSE
ReadmeUrl: README.md
Labels:
[trendmicro, cloudone, applicationsecurity, securityhub, findings, plugin]
HomePageUrl: https://github.com/TomRyan-321/Cloud-One-Application-Security-SNS-to-Security-Hub
SemanticVersion: 1.0.0
SourceCodeUrl: https://github.com/TomRyan-321/Cloud-One-Application-Security-SNS-to-Security-Hub
Parameters:
ExternalID:
Description: External ID from Application Security console
Default: ""
Type: String
UseExistingSNSTopic:
Description: 'Use existing SNS Topic or Create New. Allowed Values: "true" / "false"'
Type: String
AllowedValues:
- "true"
- "false"
Default: "false"
ExistingSNSTopicARN:
Description: Optional, input the ARN of your existing Application Security SNS Topic or leave as None
Type: String
Default: "None"
Conditions:
UseExistingTopic:
!Equals [true, !Ref UseExistingSNSTopic]
CreateTopicResources:
!Equals [false, !Ref UseExistingSNSTopic]
Resources:
C1AStoSecurityHubFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./src
Handler: handler.lambda_handler
Runtime: python3.8
MemorySize: 128
Timeout: 300
Tracing: Active
Policies:
- Statement:
- Sid: SecurityHubBatchImportFindingsPolicy
Effect: Allow
Action:
- securityhub:BatchImportFindings
Resource: "arn:aws:securityhub:*:*:*"
Events:
ScanResult:
Type: SNS
Properties:
Topic: !If [UseExistingTopic, !Ref ExistingSNSTopicARN, !Ref C1AStoSecurityHubSNSTopic]
C1AStoSecurityHubSNSTopic:
Type: AWS::SNS::Topic
Condition: CreateTopicResources
CrossAccountIAMRole:
Type: AWS::IAM::Role
Condition: CreateTopicResources
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
AWS: arn:aws:iam::800880067056:root
Action: sts:AssumeRole
Condition:
StringEquals:
sts:ExternalId: !Ref ExternalID
ManagedPolicyArns:
- !Ref CrossAccountIAMPolicy
CrossAccountIAMPolicy:
Type: AWS::IAM::ManagedPolicy
Condition: CreateTopicResources
Properties:
Description: Permissions required for Cloud One Application Security to publish to SNS
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: sns:Publish
Resource: !Ref C1AStoSecurityHubSNSTopic
Outputs:
SNSTopicName:
Condition: CreateTopicResources
Value: !GetAtt C1AStoSecurityHubSNSTopic.TopicName
IAMRoleName:
Condition: CreateTopicResources
Value: !Ref CrossAccountIAMRole
AWSRegion:
Condition: CreateTopicResources
Value: !Sub '${AWS::Region}'
AWSAccountID:
Condition: CreateTopicResources
Value: !Sub '${AWS::AccountId}'
FunctionARN:
Value: !GetAtt C1AStoSecurityHubFunction.Arn