redis.yaml
---

Redis CloudFormation Deployment

This CloudFormation template will deploy a Redis based ElastiCache instance.

AWSTemplateFormatVersion: "2010-09-09" Description: "A Redis based ElastiCache Cluster"

Parameters

These are the input parameters for this template. All of these parameters must be supplied for this template to be deployed.

Parameters:

The name of this caching service.

ServiceName: Type: String Description: "Enter the name of the service, ie 'UITS Cloud Services Redis Cache', etc."

VPCID is the ID of the VPC where this template will be deployed.

VPCID: Description: Target VPC Type: AWS::EC2::VPC::Id InstanceSubnet: Description: Private Subnet Type: AWS::EC2::Subnet::Id

Default Node Type for cache instances.

CacheNodeType: Description: "Cache Instance Type" Type: String Default: "cache.t2.micro" AllowedValues: - "cache.t2.micro"

Tags

The following tags are applied to all resources created by this template.

ServiceTag: Type: String Description: Exact name of the Service as defined in the service catalog. EnvironmentTag: Type: String Description: Used to distinguish between development, test, production,etc. environment types. AllowedValues: [dev, tst, prd, trn, stg, cfg, sup, rpt] Default: dev ContactNetidTag: Type: String Description: Used to identify the netid of the person most familiar with the usage of the resource. AccountNumberTag: Type: String Description: Identifies the financial system account number. SubaccountTag: Type: String Description: Identifies the financial system subaccount. TicketNumberTag: Type: String Description: Used to identify the Jira, Cherwell, or other ticketing system ticket number to link to more information about the need for the resource.

Metadata

Metadata is mostly for organizing and presenting Parameters in a better way when using CloudFormation in the AWS Web UI.

Metadata: AWS::CloudFormation::Interface: ParameterGroups: - Label: default: Cache Settings Parameters: - ServiceName - CacheNodeType - VPCID - InstanceSubnet - Label: default: Tags Parameters: - ServiceTag - EnvironmentTag - ContactNetidTag - AccountNumberTag - SubaccountTag - TicketNumberTag ParameterLabels: ServiceTag: default: "Service Name:" EnvironmentTag: default: 'Environment Type:' ContactNetidTag: default: 'Contact NetID:' AccountNumberTag: default: 'Financial Account Number:' SubaccountTag: default: 'Financial Subaccount:' TicketNumberTag: default: 'Ticket Number:'

Resources

This is the EC2 instance deployed by the template.

Resources:

Cache Subnet Group

CacheSubnetGroup: Type: "AWS::ElastiCache::SubnetGroup" Properties: Description: !Sub "${ServiceName}-subnetgroup" SubnetIds: - !Ref InstanceSubnet

Cache Security Group

The security group assigned to this redis cache. Note there are no ingress rules defined here. They must be added be subsequent templates from the values exported from this template.

CacheSecurityGroup: Type: "AWS::EC2::SecurityGroup" Properties: GroupDescription: !Sub "${ServiceName}-securitygroup" VpcId: !Ref VPCID SecurityGroupIngress: - IpProtocol: "tcp" FromPort: "6379" ToPort: "6379" CidrIp: "128.196.135.0/24" # CC 317 Wired Ports

ElastiCache Redis Cluster

ElasticacheCluster: Type: "AWS::ElastiCache::CacheCluster" Properties: AutoMinorVersionUpgrade: "true" Engine: "redis" CacheNodeType: !Ref CacheNodeType NumCacheNodes: "1" CacheSubnetGroupName: !Ref CacheSubnetGroup VpcSecurityGroupIds: - !GetAtt CacheSecurityGroup.GroupId Tags: - Key: "Name" Value: !Ref ServiceName - Key: service Value: !Ref ServiceTag - Key: environment Value: !Ref EnvironmentTag - Key: contactnetid Value: !Ref ContactNetidTag - Key: accountnumber Value: !Ref AccountNumberTag - Key: subaccount Value: !Ref SubaccountTag - Key: ticketnumber Value: !Ref TicketNumberTag

Outputs

Output values that can be viewed from the AWS CloudFormation console.

Outputs: ElasticacheCluster: Description: "The Redis Cluster ID" Value: !Ref ElasticacheCluster Export: Name: !Sub "${AWS::StackName}-clusterid" RedisEndpoint: Description: "The Redis Endpoint" Value: !GetAtt ElasticacheCluster.RedisEndpoint.Address Export: Name: !Sub "${AWS::StackName}-endpoint" RedisPort: Description: "The Redis Port" Value: !GetAtt ElasticacheCluster.RedisEndpoint.Port Export: Name: !Sub "${AWS::StackName}-port" RedisCacheSecurityGroup: Description: "The security group for this Redis cache" Value: !Ref CacheSecurityGroup Export: Name: !Sub "${AWS::StackName}-securitygroup"