-
Notifications
You must be signed in to change notification settings - Fork 9
/
vault-core-security.json
275 lines (242 loc) · 8.22 KB
/
vault-core-security.json
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Hashicorp Vault Reference: Core Security Infrastructure: This template creates a Private and Public Security Group and 1 Test EC2 instance.",
"Metadata" :
{
},
"Parameters" :
{
"VaultStackName":
{
"Description": "Name of the stack containing the vault networking",
"Type": "String"
}
},
"Mappings" :
{
},
"Conditions" :
{
},
"Resources" :
{
"NetworkInfo":
{
"Type": "Custom::NetworkInfo",
"Properties":
{
"ServiceToken": {"Fn::GetAtt": ["LookupStackOutputs","Arn"]},
"StackName": {"Ref": "VaultStackName"}
}
},
"LookupStackOutputs":
{
"Type": "AWS::Lambda::Function",
"Properties": {
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"LambdaExecutionRole",
"Arn"
]
},
"Code": {
"ZipFile": {
"Fn::Join": [
"\n",
[
"var response = require('cfn-response');",
"exports.handler = function(event, context) {",
" console.log('REQUEST RECEIVED:\\n', JSON.stringify(event));",
" if (event.RequestType == 'Delete') {",
" response.send(event, context, response.SUCCESS);",
" return;",
" }",
" var stackName = event.ResourceProperties.StackName;",
" var responseData = {};",
" if (stackName) {",
" var aws = require('aws-sdk');",
" var cfn = new aws.CloudFormation();",
" cfn.describeStacks({StackName: stackName}, function(err, data) {",
" if (err) {",
" responseData = {Error: 'DescribeStacks call failed'};",
" console.log(responseData.Error + ':\\n', err);",
" response.send(event, context, response.FAILED, responseData);",
" }",
" else {",
" data.Stacks[0].Outputs.forEach(function(output) {",
" responseData[output.OutputKey] = output.OutputValue.toLowerCase();",
" });",
" response.send(event, context, response.SUCCESS, responseData);",
" }",
" });",
" } else {",
" responseData = {Error: 'Stack name not specified'};",
" console.log(responseData.Error);",
" response.send(event, context, response.FAILED, responseData);",
" }",
"};"
]
]
}
},
"Runtime": "nodejs4.3",
"Timeout": "30"
}
},
"LambdaExecutionRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Path": "/",
"Policies": [
{
"PolicyName": "root",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"cloudformation:DescribeStacks",
"ec2:DescribeImages"
],
"Resource": "*"
}
]
}
}
]
}
},
"VaultPublicInstanceSecurityGroup" :
{
"Type" : "AWS::EC2::SecurityGroup",
"Properties" :
{
"GroupDescription" : "Allow http to client host",
"VpcId" : { "Fn::GetAtt" : ["NetworkInfo","VaultRefVPC"] },
"SecurityGroupIngress" : [{
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : { "Fn::GetAtt" : ["NetworkInfo","VaultCIDRBastionAccess"] }
}],
"SecurityGroupEgress" : [{
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : "0.0.0.0/0"
}]
}
},
"VaultPrivateInstanceSecurityGroup" :
{
"Type" : "AWS::EC2::SecurityGroup",
"Properties" :
{
"GroupDescription" : "Allow http to client host",
"VpcId" : { "Fn::GetAtt" : ["NetworkInfo","VaultRefVPC"] },
"SecurityGroupIngress" : [{
"IpProtocol" : "tcp",
"FromPort" : "22",
"ToPort" : "22",
"CidrIp" : "0.0.0.0/0"
}],
"SecurityGroupEgress" : [{
"IpProtocol" : "tcp",
"FromPort" : "443",
"ToPort" : "443",
"CidrIp" : "0.0.0.0/0"
}]
}
}
},
"Outputs" :
{
"VaultRefVPC":
{
"Value": { "Fn::GetAtt" : ["NetworkInfo","VaultRefVPC"] },
"Description": "VPC ID"
},
"VaultPublicSubnet1" :
{
"Description": "ID of Public Subnet 1",
"Value" : { "Fn::GetAtt" : ["NetworkInfo","VaultPublicSubnet1"] }
},
"VaultPublicSubnet2" :
{
"Description": "ID of Public Subnet 2",
"Value" : { "Fn::GetAtt" : ["NetworkInfo","VaultPublicSubnet2"] }
},
"VaultPublicSubnet3" :
{
"Description": "ID of Public Subnet 3",
"Value" : { "Fn::GetAtt" : ["NetworkInfo","VaultPublicSubnet3"] }
},
"VaultPrivateSubnet1" :
{
"Description": "ID of Private Subnet 1",
"Value" : { "Fn::GetAtt" : ["NetworkInfo","VaultPrivateSubnet1"] }
},
"VaultPrivateSubnet1Toggle" :
{
"Description": "Should we Deploy Private Subnet 1? yes/no",
"Value" : { "Fn::GetAtt" : ["NetworkInfo","VaultPrivateSubnet1Toggle"] }
},
"VaultPrivateSubnet2" :
{
"Description": "ID of Private Subnet 2",
"Value" : { "Fn::GetAtt" : ["NetworkInfo","VaultPrivateSubnet2"] }
},
"VaultPrivateSubnet2Toggle" :
{
"Description": "Should we Deploy Private Subnet 2? yes/no",
"Value" : { "Fn::GetAtt" : ["NetworkInfo","VaultPrivateSubnet2Toggle"] }
},
"VaultPrivateSubnet3" :
{
"Description": "ID of Private Subnet 3",
"Value" : { "Fn::GetAtt" : ["NetworkInfo","VaultPrivateSubnet3"] }
},
"VaultPrivateSubnet3Toggle" :
{
"Description": "Should we Deploy Private Subnet 3? yes/no",
"Value" : { "Fn::GetAtt" : ["NetworkInfo","VaultPrivateSubnet3Toggle"] }
},
"VaultPublicSG" :
{
"Description": "Vault Public Instance Security Group",
"Value" : { "Ref" : "VaultPublicInstanceSecurityGroup"}
},
"VaultPrivateSG" :
{
"Description": "Vault Private Instance Security Group",
"Value" : { "Ref" : "VaultPrivateInstanceSecurityGroup"}
}
}
}