Reputation: 1993
I am trying to apply a set of tags to a SNS topic and one of the tags refer to a parameter. Given below is an extract of the template I have (I have reduced the tags to highlight my problem)
AWSTemplateFormatVersion: 2010-09-09
Description: Deploys resources
Parameters:
MyParameter:
Type: String
Default: "testEnvironment"
Mappings:
Mp1:
Mp1-1:
tags:
- Key: key1
Value: !Ref MyParameter
Resources:
snsTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: snsTopic
TopicName: snsTopic
Tags: !FindInMap [Mp1, Mp1-1, tags]
Now when I run this on CloudFormation I get the following error:
Every entry in list for property Tags must be a map of String
Does someone know how to fix this or what I am doing wrong?
Upvotes: 2
Views: 4439
Reputation: 238747
You can't define Mappings in this way. Docs clearly say that:
You cannot include parameters, pseudo parameters, or intrinsic functions in the Mappings section.
So your Mapping should be
Mappings:
Mp1:
Mp1-1:
tags:
- Key: key1
Value: MyValue # <-- No !Ref here, just fixed string
If you want to !Ref
MyParameter, then you should put it in the AWS::SNS::Topic
resource.
Resources:
snsTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: snsTopic
TopicName: snsTopic
Tags:
- Key: key1
Value: !Ref MyParameter
Upvotes: 1