@@ -78,6 +78,54 @@ Conditions:
7878 - !Not [!Equals [!Ref AdditionalIngressCIDR3, !Ref AdditionalIngressCIDR2]]
7979
8080Resources :
81+ # =============================================================================
82+ # KMS KEY
83+ # =============================================================================
84+ ElastiCacheKMSKey :
85+ Type : AWS::KMS::Key
86+ Properties :
87+ Description : KMS key for ElastiCache secrets encryption
88+ EnableKeyRotation : true
89+ KeyPolicy :
90+ Version : ' 2012-10-17'
91+ Statement :
92+ - Sid : Enable IAM User Permissions
93+ Effect : Allow
94+ Principal :
95+ AWS : !Sub "arn:aws:iam::${AWS::AccountId}:root"
96+ Action : kms:*
97+ Resource : ' *'
98+ Tags :
99+ - Key : Name
100+ Value : !Sub "${ProjectName}-elasticache-kms"
101+ - Key : Environment
102+ Value : !Ref EnvironmentName
103+
104+ ElastiCacheKMSKeyAlias :
105+ Type : AWS::KMS::Alias
106+ Properties :
107+ AliasName : !Sub "alias/${ProjectName}-elasticache"
108+ TargetKeyId : !Ref ElastiCacheKMSKey
109+
110+ # =============================================================================
111+ # SECRETS
112+ # =============================================================================
113+ ElastiCacheAuthSecret :
114+ Type : AWS::SecretsManager::Secret
115+ Properties :
116+ Name : !Sub "${ProjectName}/elasticache-auth-token"
117+ Description : ElastiCache Auth Token for transit encryption
118+ KmsKeyId : !GetAtt ElastiCacheKMSKey.Arn
119+ GenerateSecretString :
120+ PasswordLength : 64
121+ ExcludeCharacters : ' "@/\!'
122+ ExcludePunctuation : false
123+ Tags :
124+ - Key : Name
125+ Value : !Sub "${ProjectName}-elasticache-auth-secret"
126+ - Key : Environment
127+ Value : !Ref EnvironmentName
128+
81129 # =============================================================================
82130 # SECURITY GROUP
83131 # =============================================================================
@@ -185,7 +233,8 @@ Resources:
185233 AutomaticFailoverEnabled : true
186234 MultiAZEnabled : true
187235 TransitEncryptionEnabled : true
188- TransitEncryptionMode : preferred
236+ TransitEncryptionMode : required
237+ AuthToken : !Sub "{{resolve:secretsmanager:${ElastiCacheAuthSecret}:SecretString}}"
189238 AtRestEncryptionEnabled : true
190239 AutoMinorVersionUpgrade : true
191240 PreferredMaintenanceWindow : " mon:00:00-mon:03:00"
@@ -212,6 +261,10 @@ Outputs:
212261 Description : ElastiCache Reader Endpoint
213262 Value : !GetAtt ElastiCacheReplicationGroup.ReaderEndPoint.Address
214263
264+ AuthSecretArn :
265+ Description : ElastiCache Auth Token Secret ARN
266+ Value : !Ref ElastiCacheAuthSecret
267+
215268 SecurityGroupId :
216269 Description : ElastiCache Security Group ID
217270 Value : !Ref ElastiCacheSecurityGroup
0 commit comments