forked from aws-samples/startup-kit-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vpc-elasticache.cfn.yml
181 lines (156 loc) · 4.9 KB
/
vpc-elasticache.cfn.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
---
AWSTemplateFormatVersion: 2010-09-09
Description: SASKV5 VPC + ElastiCache
Parameters:
TemplateBucket:
Type: String
Default: awslabs-startup-kit-templates-deploy-v5
Description: The template bucket for the CloudFormation templates
# vpc.cfn.yml parameters
AvailabilityZone1:
Description: The first availability zone in the region
Type: AWS::EC2::AvailabilityZone::Name
ConstraintDescription: Must be a valid availability zone
AvailabilityZone2:
Description: The second availability zone in the region
Type: AWS::EC2::AvailabilityZone::Name
ConstraintDescription: Must be a valid availability zone
SSHFrom:
Description: Limit SSH access to bastion hosts to a CIDR IP block
Type: String
MinLength: 9
MaxLength: 18
Default: 0.0.0.0/0
ELBIngressPort:
Description: The ELB ingress port used by security groups
Type: Number
MinValue: 0
MaxValue: 65535
ConstraintDescription: TCP ports must be between 0 - 65535
Default: 80
AppIngressPort:
Description: The application ingress port used by security groups
Type: Number
MinValue: 0
MaxValue: 65535
ConstraintDescription: TCP ports must be between 0 - 65535
Default: 80
# elasticache.cfn.yml parameters
ClusterName:
Description: Custom name of the cluster. Auto generated if you don't supply your own.
Type: String
CacheNodeType:
Description: Cache node instance class, e.g. cache.t2.micro(free tier). See https://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/CacheNodes.SelectSize.html
Type: String
Default: cache.t2.micro
ConstraintDescription: Node instance class not supported
AllowedValues:
- cache.t2.micro
- cache.t2.small
- cache.t2.medium
- cache.m4.large
- cache.m4.xlarge
- cache.m4.2xlarge
- cache.m4.4xlarge
- cache.m4.10xlarge
- cache.r4.large
- cache.r4.xlarge
- cache.r4.2xlarge
- cache.r4.4xlarge
- cache.r4.8xlarge
- cache.r4.16xlarge
CacheEngine:
Description: The underlying cache engine, either Redis or Memcached
Type: String
Default: redis
ConstraintDescription: Node instance class not supported
AllowedValues:
- redis
- memcached
CacheNodeCount:
Description: Number of nodes in the cluster. Only used with memcached engine, for redis this value will be set to 1.
Type: Number
MinValue: 1
MaxValue: 15
ConstraintDescription: Node count must be between 1 and 15
Default: 1
AutoMinorVersionUpgrade:
Description: Whether or not minor version upgrades to the cache engine should be applied automatically during the maintenance window.
Type: String
Default: true
AllowedValues:
- true
- false
EnvironmentName:
Type: String
Description: Environment name - dev or prod
Default: dev
AllowedValues:
- dev
- prod
ConstraintDescription: Specify either dev or prod
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Environment
Parameters:
- EnvironmentName
- Label:
default: Region Availability Zones
Parameters:
- AvailabilityZone1
- AvailabilityZone2
- Label:
default: Ingress Ports
Parameters:
- ELBIngressPort
- AppIngressPort
ParameterLabels:
AvailabilityZone1:
default: Availability Zone 1
AvailabilityZone2:
default: Availability Zone 2
ELBIngressPort:
default: Load Balancer Port
AppIngressPort:
default: Application Port
SSHFrom:
default: Bastion SSH Whitelist
TemplateBucket:
default: CloudFormation Bucket
EnvironmentName:
default: Environment
SSHFrom:
default: SSH Whitelist
Conditions:
IsProd: !Equals [ !Ref EnvironmentName, prod ]
Resources:
VpcStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub https://s3.amazonaws.com/${TemplateBucket}/templates/vpc.cfn.yml
Parameters:
AvailabilityZone1: !Ref AvailabilityZone1
AvailabilityZone2: !Ref AvailabilityZone2
SSHFrom: !Ref SSHFrom
ELBIngressPort: !Ref ELBIngressPort
AppIngressPort: !Ref AppIngressPort
SingleNatGateway: !If [ IsProd, false, true ]
ElastiCacheStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub https://s3.amazonaws.com/${TemplateBucket}/templates/elasticache.cfn.yml
Parameters:
NetworkStackName: !GetAtt VpcStack.Outputs.Name
ClusterName: !Ref ClusterName
DependsOn: VpcStack
Outputs:
VpcStackName:
Value: !GetAtt VpcStack.Outputs.Name
Export:
Name: !Sub ${AWS::StackName}-VpcStackName
ElastiCacheStackName:
Value: !GetAtt ElastiCacheStack.Outputs.ElastiCacheStackName
Export:
Name: !Sub ${AWS::StackName}-ElastiCacheStackName