I am writing a CF template to create an Elasticache Replication group. In that, I have a parameter called Snapshots
of CommaDelimitedList
type, which is used to pass RDB snapshot files stored in s3 as a list of ARNs –
Snapshots:
Description: >-
List of ARNs of Redis RDB snapshot files to populate the Elasticache
cluster (optional)
Type: CommaDelimitedList
I’m trying to have a Condition like below, which is going to check if Snapshots
is empty or not –
Conditions:
HasSnapshots: !Not
- !Equals
- !Ref Snapshots
- ''
When I try to validate my template in CloudFormation Designer, it throws an error –
29/07/2020, 22:50:33 - Template contains errors.: Template error: every Fn::Equals object requires a list of 2 string parameters.
What would be the correct way to do this? Do I have to use String type for Snapshots
instead of CommaDelimitedList? Or any other better approach?
I need this parameter for a Resource
of type AWS::ElastiCache::ReplicationGroup
as shown below, to populate the ElastiCache cluster with snapshot files given as a list of ARNs in Snapshots
parameter, if provided so –
RedisReplicationGroup:
Type: 'AWS::ElastiCache::ReplicationGroup'
Properties:
...
...
SnapshotArns: !If
- HasSnapshots
- !Ref Snapshots
- !Ref 'AWS::NoValue'
2
Answers
You can do the following using Join:
Not sure if you were able to figure this out, but this might work