Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions redis.cfndsl.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
CloudFormation do

export = external_parameters.fetch(:export_name, external_parameters[:component_name])

redis_tags = []
redis_tags << { Key: 'Name', Value: FnSub("${EnvironmentName}-#{external_parameters[:component_name]}") }
redis_tags << { Key: 'Name', Value: FnSub("${EnvironmentName}-#{export}") }
redis_tags << { Key: 'Environment', Value: Ref(:EnvironmentName) }
redis_tags << { Key: 'EnvironmentType', Value: Ref(:EnvironmentType) }

tags = external_parameters.fetch(:tags, {})
tags.each do |key, value|
redis_tags << { Key: FnSub(key), Value: FnSub(value)}
end

ip_blocks = external_parameters.fetch(:ip_blocks, {})
security_group_rules = external_parameters.fetch(:security_group_rules, [])

EC2_SecurityGroup(:SecurityGroupRedis) {
VpcId Ref(:VPCId)
GroupDescription FnSub("${EnvironmentName}-#{external_parameters[:component_name]}")
GroupDescription FnSub("${EnvironmentName}-#{export}")

if security_group_rules.any?
SecurityGroupIngress generate_security_group_rules(security_group_rules,ip_blocks)
Expand All @@ -29,11 +36,11 @@

Output(:RedisSecurityGroupId) {
Value Ref(:SecurityGroupRedis)
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-RedisSecurityGroup")
Export FnSub("${EnvironmentName}-#{export}-RedisSecurityGroup")
}

ElastiCache_SubnetGroup(:SubnetGroupRedis) {
Description FnSub("${EnvironmentName}-#{external_parameters[:component_name]}")
Description FnSub("${EnvironmentName}-#{export}")
SubnetIds Ref(:Subnets)
}

Expand All @@ -53,7 +60,7 @@

ElastiCache_ParameterGroup(:ParameterGroupRedis) {
CacheParameterGroupFamily family
Description FnSub("${EnvironmentName}-#{external_parameters[:component_name]}")
Description FnSub("${EnvironmentName}-#{export}")
Properties final_parameters
}

Expand All @@ -73,7 +80,7 @@

ElastiCache_ReplicationGroup(:ReplicationGroupRedis) {

ReplicationGroupDescription FnSub("${EnvironmentName}-#{external_parameters[:component_name]}")
ReplicationGroupDescription FnSub("${EnvironmentName}-#{export}")

Engine 'redis'
EngineVersion engine_version unless engine_version.nil?
Expand Down Expand Up @@ -130,12 +137,12 @@

Output(:RedisHostEndpoint) {
Value(FnGetAtt(:ReplicationGroupRedis, record_endpoint))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-RedisHostEndpoint")
Export FnSub("${EnvironmentName}-#{export}-RedisHostEndpoint")
}

Output(:RedisReadAddresses) {
Value(FnGetAtt(:ReplicationGroupRedis, 'ReadEndPoint.Addresses'))
Export FnSub("${EnvironmentName}-#{external_parameters[:component_name]}-RedisReadAddresses")
Export FnSub("${EnvironmentName}-#{export}-RedisReadAddresses")
} unless cluster_enabled

end