This repository has been archived by the owner on Mar 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcf-resources.yml
218 lines (217 loc) · 5.22 KB
/
cf-resources.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
Resources:
IamRoleLambda:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
IamPolicyLambda:
Type: AWS::IAM::Policy
Properties:
PolicyName: "${opt:stage,self:provider.stage}-${self:service}-lambda"
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: arn:aws:logs:${self:provider.region}:*:*
- Effect: Allow
Action:
- ec2:CreateNetworkInterface
- ec2:DescribeNetworkInterfaces
- ec2:DeleteNetworkInterface
Resource: "*"
- Effect: Allow
Action:
- sns:Publish
Resource:
- Ref: SNSAuthRepTopic
- Ref: SNSCacheTokenTopic
Roles:
- Ref: IamRoleLambda
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
VpcId:
Ref: VPC
CidrBlock: 10.0.0.0/24
PrivateSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId:
Ref: VPC
CidrBlock: 10.0.1.0/24
PrivateSubnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId:
Ref: VPC
CidrBlock: 10.0.2.0/24
InternetGateway:
Type: AWS::EC2::InternetGateway
InternetGatewayAssociation:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId:
Ref: VPC
InternetGatewayId:
Ref: InternetGateway
IPAddress:
Type: AWS::EC2::EIP
DependsOn: InternetGatewayAssociation
Properties:
Domain: vpc
NAT:
Type: AWS::EC2::NatGateway
Properties:
AllocationId:
Fn::GetAtt:
- IPAddress
- AllocationId
SubnetId:
Ref: PublicSubnet
igRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId:
Ref: VPC
igRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId:
Ref: igRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId:
Ref: InternetGateway
PublicSubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId:
Ref: PublicSubnet
RouteTableId:
Ref: igRouteTable
natRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId:
Ref: VPC
natRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId:
Ref: natRouteTable
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId:
Ref: NAT
PrivateSubnetRouteTableAssociation1:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId:
Ref: PrivateSubnet1
RouteTableId:
Ref: natRouteTable
PrivateSubnetRouteTableAssociation2:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId:
Ref: PrivateSubnet2
RouteTableId:
Ref: natRouteTable
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Limits security group egress traffic
VpcId:
Ref: VPC
SecurityGroupIngress:
- IpProtocol: "-1"
SecurityGroupEgress:
- IpProtocol: "-1"
CidrIp: 0.0.0.0/0
InternalSecurityGroup2:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId:
Ref: VPC
GroupDescription: Allow the machines in this group to share all kinds of traffic
between each other
SecurityGroupIngress:
- IpProtocol: "-1"
FromPort: "-1"
ToPort: "-1"
SourceSecurityGroupId:
Ref: SecurityGroup
CacheSubnetGroup:
Type: AWS::ElastiCache::SubnetGroup
Properties:
Description: Cache Subnet Group
SubnetIds:
- Ref: PublicSubnet
elasticCache:
Type: AWS::ElastiCache::CacheCluster
Properties:
AutoMinorVersionUpgrade: 'true'
Engine: redis
CacheNodeType: cache.t2.micro
NumCacheNodes: '1'
CacheSubnetGroupName:
Ref: CacheSubnetGroup
VpcSecurityGroupIds:
- Ref: InternalSecurityGroup2
DependsOn:
- VPC
SNSAuthRepTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: "${opt:stage, self:provider.stage}-${self:service}-threescaleAuthRepAsync"
SNSCacheTokenTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: "${opt:stage, self:provider.stage}-${self:service}-threescaleCacheTokenAsync"
Outputs:
IamRoleArnLambda:
Description: ARN of the lambda IAM role
Value:
Fn::GetAtt:
- IamRoleLambda
- Arn
ElastiCacheEndpoint:
Description: Endpoint URL of the Elasticacache created
Value:
"Fn::GetAtt": [ elasticCache, RedisEndpoint.Address ]
vpcSecurityGroup:
Description: Id of the SecurityGroup
Value:
Fn::GetAtt:
- SecurityGroup
- GroupId
privateSubnetId1:
Description: Id of the PrivateSubnet1
Value:
Ref: PrivateSubnet1
privateSubnetId2:
Description: Id of the PrivateSubnet1
Value:
Ref: PrivateSubnet2
snsAuthRepTopic:
Description: ARN of SNS topic for AuthRrep Async
Value:
Ref: SNSAuthRepTopic
snsCacheTokenTopic:
Description: ARN of SNS topic for CacheToken Async
Value:
Ref: SNSCacheTokenTopic