mirror of
https://github.com/yeslayla/aws-redis-cluster.git
synced 2025-01-13 12:33:29 +01:00
100 lines
2.6 KiB
YAML
100 lines
2.6 KiB
YAML
AWSTemplateFormatVersion: '2010-09-09'
|
|
Description: General use Redis Cluster
|
|
Parameters:
|
|
VpcId:
|
|
Type: AWS::EC2::VPC::Id
|
|
Description: The id of the VPC the cluster will be in
|
|
ConstraintDescription: VPC Id must begin with 'vpc-'
|
|
SubnetIds:
|
|
Type: List<AWS::EC2::Subnet::Id>
|
|
Description: Comma seperated list of subnets for ECS instances to run in
|
|
Project:
|
|
Type: String
|
|
Description: Project used in naming in tagging to associate with cluster
|
|
Environment:
|
|
Type: String
|
|
Description: Environment used in naming and tagging to associate with cluster
|
|
NodeType:
|
|
Type: String
|
|
Default: cache.t3.micro
|
|
RedisVersion:
|
|
Type: String
|
|
Default: 5.0.6
|
|
RedisPort:
|
|
Type: Number
|
|
Default: 6379
|
|
NumOfNodes:
|
|
Type: Number
|
|
Default: 2
|
|
ReadNodesPerNode:
|
|
Type: Number
|
|
Default: 1
|
|
|
|
Resources:
|
|
|
|
CacheSecurityGroup:
|
|
Type: AWS::EC2::SecurityGroup
|
|
Properties:
|
|
GroupDescription: Redis Allowed Ports
|
|
VpcId: !Ref VpcId
|
|
SecurityGroupIngress:
|
|
- IpProtocol: icmp
|
|
FromPort: '-1'
|
|
ToPort: '-1'
|
|
CidrIp: 0.0.0.0/0
|
|
- IpProtocol: tcp
|
|
FromPort: !Ref RedisPort
|
|
ToPort: !Ref RedisPort
|
|
CidrIp: 0.0.0.0/0
|
|
SecurityGroupEgress:
|
|
- IpProtocol: icmp
|
|
FromPort: '-1'
|
|
ToPort: '-1'
|
|
CidrIp: 0.0.0.0/0
|
|
- IpProtocol: tcp
|
|
FromPort: '0'
|
|
ToPort: '65535'
|
|
CidrIp: 0.0.0.0/0
|
|
- IpProtocol: udp
|
|
FromPort: '0'
|
|
ToPort: '65535'
|
|
CidrIp: 0.0.0.0/0
|
|
|
|
SubnetGroup:
|
|
Type: AWS::ElastiCache::SubnetGroup
|
|
Properties:
|
|
CacheSubnetGroupName: !Sub "${Project}-Cache-${Environment}"
|
|
Description: String
|
|
SubnetIds: !Ref SubnetIds
|
|
|
|
|
|
RedisCluster:
|
|
Type: AWS::ElastiCache::ReplicationGroup
|
|
Properties:
|
|
CacheParameterGroupName: default.redis5.0.cluster.on
|
|
CacheNodeType: !Ref NodeType
|
|
CacheSubnetGroupName: !Ref SubnetGroup
|
|
Engine: redis
|
|
EngineVersion: !Ref RedisVersion
|
|
NumNodeGroups: !Ref NumOfNodes
|
|
Port: !Ref RedisPort
|
|
ReplicasPerNodeGroup: !Ref ReadNodesPerNode
|
|
ReplicationGroupDescription: Redis group for scaling
|
|
SecurityGroupIds:
|
|
- !Ref CacheSecurityGroup
|
|
Tags:
|
|
- Key: Project
|
|
Value: !Ref Project
|
|
- Key: Environment
|
|
Value: !Ref Environment
|
|
|
|
Outputs:
|
|
Cluster:
|
|
Description: Arn of the Redis Cluster
|
|
Value: !Ref RedisCluster
|
|
Port:
|
|
Description: Port
|
|
Value: !GetAtt RedisCluster.ConfigurationEndPoint.Port
|
|
Endpoint:
|
|
Description: Endpoint
|
|
Value: !GetAtt RedisCluster.ConfigurationEndPoint.Address |