Reputation: 321
I have created an API Gateway using AWS::Serverless::API in SAM and now I want to add Tags to Gateway in order to enforce security constraints on every Gateway with the same tag.
Type: AWS::Serverless::Api
Properties:
Name: PrivateApi
StageName: v1
Tags:
- Key: TagName
Value: TagValue
MethodSettings:
...
After looking at the documentation I have came up with the code above. As the documentation states it supports Tags in the way shown above but when I deploy I get the following error.
samcli.commands.validate.lib.exceptions.InvalidSamDocumentException: [InvalidResourceException('PrivateApi', "Type of property 'Tags' is invalid.")] ('PrivateApi', "Type of property 'Tags' is invalid.")
Link to Documentation about Tags: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html
Any help on this would be appreciated!
Upvotes: 5
Views: 1687
Reputation: 321
I figured out that the documentation on the AWS::Serverless::API page, and the Tags page is slightly wrong when using SAM.
The proper way of denoting a Tag in SAM is the following.
Type: AWS::Serverless::Api
Properties:
Name: PrivateApi
StageName: v1
Tags:
TagName: TagValue
MethodSettings:
...
This subtle difference makes SAM deploy properly. As a helpful aside, in the API Stage you can verify that the Tag has been deployed properly.
Upvotes: 8