How to put Tags on the following Resources using a CloudFormation Template:
- AWS::ApiGatewayV2::Api
- AWS::ApiGatewayV2::DomainName
- AWS::ApiGatewayV2::Stage
For a generic AWS::ApiGatewayV2::Api Resource I have tried the following in the Resources section of the CloudFormation Template:
MyApi:
Type: 'AWS::ApiGatewayV2::Api'
Properties:
Name: MyApi
ProtocolType: WEBSOCKET
RouteSelectionExpression: $request.body.action
ApiKeySelectionExpression: $request.header.x-api-key
Tags:
- Key: TagKey1
Value: MyFirstTag
- Key: TagKey2
Value: !Ref MySecondTagAsParameter
In the CloudFormation Events view of Amazon Management Console, The Resource failed with the following reason:
Property validation failure: [Value of property {/Tags} does not match type {Map}]
I looked up the Type, which appeared to be Json in the documentation:
Tags The collection of tags. Each tag element is associated with a given resource. Required: No Type: Json Update requires: No interruption Required: No
Which made me try the following:
Tags: !Sub "{ \"TagKey1\" : \"MyFirstTag\", \"TagKey2\" : \"${MySecondTagAsParameter}\"}"
That also did not work, prompting me to try YAML literals:
Tags: !Sub | { "TagKey1": "MyFirstTag", "TagKey2": "${MySecondTagAsParameter}" }
That did not work either.