forked from aws-samples/aws-refarch-drupal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws-refarch-drupal-03-elasticache.yaml
128 lines (119 loc) · 3.7 KB
/
aws-refarch-drupal-03-elasticache.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
AWSTemplateFormatVersion: 2010-09-09
Description: Reference Architecture to host Drupal on AWS - Creates ElastiCache cache cluster
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Cache Parameters
Parameters:
- ElastiCacheNodeType
- ElastiCacheClusterName
- ElastiCacheSecurityGroup
- DataSubnet0
- DataSubnet1
- DataSubnet2
ParameterLabels:
DataSubnet0:
default: DataSubnet0
DataSubnet1:
default: DataSubnet1
DataSubnet2:
default: DataSubnet2
ElastiCacheClusterName:
default: Cache Cluster Name
ElastiCacheNodeType:
default: Cache Cluster Node Type
ElastiCacheSecurityGroup:
default: ElastiCache Security Group
Parameters:
DataSubnet0:
Description: Select an existing database subnet for AZ 0.
Type: AWS::EC2::Subnet::Id
DataSubnet1:
Description: Select an existing database subnet for AZ 1.
Type: AWS::EC2::Subnet::Id
DataSubnet2:
Description: Select an existing database subnet for AZ 2.
Type: AWS::EC2::Subnet::Id
ElastiCacheClusterName:
AllowedPattern: ^([a-zA-Z0-9]*)$
Description: The ElastiCache cluster name. Defaults to the Amazon RDS database name.
Type: String
ElastiCacheNodeType:
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.m3.medium
- cache.m3.large
- cache.m3.xlarge
- cache.m3.2xlarge
- cache.r3.large
- cache.r3.xlarge
- cache.r3.2xlarge
- cache.r3.4xlarge
- cache.r3.8xlarge
ConstraintDescription: Must be a valid Amazon ElastiCache node type.
Default: cache.t2.medium
Description: The Amazon ElastiCache cluster node type.
Type: String
ElastiCacheSecurityGroup:
Description: Select the ElastiCache security group.
Type: AWS::EC2::SecurityGroup::Id
Conditions:
MoreThan2AZ:
!Or [
!Equals [ !Ref 'AWS::Region', us-east-1 ],
!Equals [ !Ref 'AWS::Region', us-east-2 ],
!Equals [ !Ref 'AWS::Region', us-west-2 ],
!Equals [ !Ref 'AWS::Region', eu-west-1 ],
!Equals [ !Ref 'AWS::Region', sa-east-1 ],
!Equals [ !Ref 'AWS::Region', ap-northeast-1 ],
!Equals [ !Ref 'AWS::Region', ap-southeast-2 ]
]
Resources:
ElastiCacheCluster:
Type: AWS::ElastiCache::CacheCluster
Properties:
AZMode: cross-az
CacheNodeType: !Ref ElastiCacheNodeType
CacheSubnetGroupName: !Ref ElastiCacheSubnetGroup
ClusterName: !Ref ElastiCacheClusterName
Engine: memcached
NumCacheNodes:
!If [
MoreThan2AZ,
3,
2
]
PreferredAvailabilityZones:
!If [
MoreThan2AZ,
[ !Select [ 0, !GetAZs '' ], !Select [ 1, !GetAZs '' ], !Select [ 2, !GetAZs '' ] ],
[ !Select [ 0, !GetAZs '' ], !Select [ 1, !GetAZs '' ] ]
]
Tags:
- Key: Name
Value: !Join [ '', [ 'Drupal / ', !Ref 'AWS::StackName' ] ]
VpcSecurityGroupIds:
- !Ref ElastiCacheSecurityGroup
ElastiCacheSubnetGroup:
Type: AWS::ElastiCache::SubnetGroup
Properties:
CacheSubnetGroupName: !Join [ '', [ !Ref ElastiCacheClusterName, SubnetGroup ] ]
Description: ElastiCache Subnet Group for Drupal
SubnetIds:
!If [
MoreThan2AZ,
[ !Ref DataSubnet0, !Ref DataSubnet1, !Ref DataSubnet2 ],
[ !Ref DataSubnet0, !Ref DataSubnet1 ]
]
Outputs:
ElastiCacheClusterEndpointAddress:
Value: !GetAtt ElastiCacheCluster.ConfigurationEndpoint.Address