-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
197 lines (184 loc) · 5.23 KB
/
template.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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
AWSTemplateFormatVersion: 2010-09-09
Description: Cloud infrastructure for the safe data tech validation server
Parameters:
BackendMasterUserPassword:
Type: String
Description: Admin password for backend database
DBPrivateSubnet:
Type: String
Description: VPC Subnet for RDS instance
DBSecurityGroup:
Type: String
EC2PublicSubnet:
Type: String
EC2SecurityGroup:
Type: String
TagName:
Type: String
TagProjectName:
Type: String
TagProjectCode:
Type: String
TagTechTeam:
Type: String
TagCenter:
Type: String
TagRequestedBy:
Type: String
TagCreatedBy:
Type: String
TagPlatform:
Type: String
Description: Either Linux or Windows
Resources:
KmsKey:
Type: AWS::KMS::Key
Properties:
Description: KMS Key for encryption
Enabled: true
KeySpec: SYMMETRIC_DEFAULT
KeyUsage: ENCRYPT_DECRYPT
KeyPolicy:
Version: '2012-10-17'
Id: key-default-1
Statement:
- Sid: Enable IAM User Permissions
Effect: Allow
Principal:
AWS:
!Join
- ''
- - 'arn:aws:iam::'
- Ref: AWS::AccountId
- :root
Action: kms:*
Resource: '*'
- Sid: Enable Lambda Permissions
Effect: Allow
Principal:
Service:
- "lambda.amazonaws.com"
AWS:
!Join
- ''
- - 'arn:aws:iam::'
- Ref: AWS::AccountId
- ':role/sdt-validation-server-engine-role-stg'
Action:
- kms:Decrypt
Resource: "*"
- Sid: Enable IAM User Permissions
Effect: Allow
Principal:
AWS:
!Join
- ''
- - 'arn:aws:iam::'
- Ref: AWS::AccountId
- ':user/sdt-validation-server-lambda-user'
Action:
- kms:Decrypt
Resource: '*'
Tags:
- Key: "Name"
Value: !Sub '${TagName}'
- Key: "Project-Name"
Value: !Sub '${TagProjectName}'
- Key: "Project-Code"
Value: !Sub '${TagProjectCode}'
- Key: "Tech-Team"
Value: !Sub '${TagTechTeam}'
- Key: "Center"
Value: !Sub '${TagCenter}'
- Key: "Requested-By"
Value: !Sub '${TagRequestedBy}'
- Key: "Created-By"
Value: !Sub '${TagCreatedBy}'
- Key: "Platform"
Value: !Sub '${TagPlatform}'
S3KeyAlias:
Type: AWS::KMS::Alias
Properties:
AliasName: alias/sdt-validation-server
TargetKeyId: !Ref KmsKey
Database:
Type: AWS::RDS::DBInstance
Properties:
AllocatedStorage: "100"
BackupRetentionPeriod: 0
CopyTagsToSnapshot: true
DBInstanceIdentifier: "sdt-validation-server"
DBInstanceClass: "db.t4g.micro"
DBSubnetGroupName: !Sub '${DBPrivateSubnet}'
DeletionProtection: false
EnablePerformanceInsights: false
Engine: "mysql"
EngineVersion: "8.0.31"
KmsKeyId: !Ref KmsKey
MasterUsername: "root"
MasterUserPassword: !Sub '${BackendMasterUserPassword}'
MonitoringInterval: 0
MultiAZ: false
PubliclyAccessible: false
StorageEncrypted: true
StorageType: "gp2"
VPCSecurityGroups:
- !Sub '${DBSecurityGroup}'
Tags:
- Key: "Name"
Value: !Sub '${TagName}'
- Key: "Project-Name"
Value: !Sub '${TagProjectName}'
- Key: "Project-Code"
Value: !Sub '${TagProjectCode}'
- Key: "Tech-Team"
Value: !Sub '${TagTechTeam}'
- Key: "Center"
Value: !Sub '${TagCenter}'
- Key: "Requested-By"
Value: !Sub '${TagRequestedBy}'
- Key: "Created-By"
Value: !Sub '${TagCreatedBy}'
- Key: "Platform"
Value: !Sub '${TagPlatform}'
WebServer:
Type: AWS::EC2::Instance
Properties:
AdditionalInfo: "EC2 instance for web application"
AvailabilityZone: "us-east-1a"
EbsOptimized: true
ImageId: "ami-044af7680fb646471"
InstanceType: "t3.small"
KeyName: "InformationTechnology"
SecurityGroupIds:
- !Sub '${EC2SecurityGroup}'
SubnetId: !Sub '${EC2PublicSubnet}'
Tags:
- Key: "Name"
Value: !Sub '${TagName}'
- Key: "Project-Name"
Value: !Sub '${TagProjectName}'
- Key: "Project-Code"
Value: !Sub '${TagProjectCode}'
- Key: "Tech-Team"
Value: !Sub '${TagTechTeam}'
- Key: "Center"
Value: !Sub '${TagCenter}'
- Key: "Requested-By"
Value: !Sub '${TagRequestedBy}'
- Key: "Created-By"
Value: !Sub '${TagCreatedBy}'
- Key: "Platform"
Value: !Sub '${TagPlatform}'
LambdaUser:
Type: AWS::IAM::User
Properties:
UserName: sdt-validation-server-lambda-user
Policies:
- PolicyName: sdt-validation-server-trigger-lambda
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action: lambda:InvokeFunction
Resource: "arn:aws:lambda:us-east-1::function:sdt-validation-server-*"