以下代码片段:
AWSTemplateFormatVersion: '2010-09-09'
Description: Some CloudFormation template
Resources:
MyResourceName:
Type: AWS::SSM::Parameter
Properties:
Name: myParameterName
Type: String
Value: "somevalue"
Tags:
- Key: firstTagName
Value: firstTagValue
- Key: secondTagName
Value: secondTagValue
Run Code Online (Sandbox Code Playgroud)
在 CloudFormation 中生成以下错误:
我应该如何正确构建 Tags 属性?
如何使用 CloudFormation 模板在以下资源上添加标签:
对于通用 AWS::ApiGatewayV2::Api 资源,我在 CloudFormation 模板的资源部分尝试了以下操作:
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
Run Code Online (Sandbox Code Playgroud)
在 Amazon 管理控制台的 CloudFormation Events 视图中,资源失败,原因如下:
属性验证失败:[属性值 {/Tags} 与类型 {Map} 不匹配]
我查找了类型,它似乎在文档Json中:
Run Code Online (Sandbox Code Playgroud)Tags The collection of tags. Each tag element is associated with a given resource. Required: No Type: Json Update requires: No interruption Required: No
这让我尝试了以下方法:
Run Code Online (Sandbox Code Playgroud)Tags: !Sub "{ \"TagKey1\" : …