Had*_*ous 3 yaml amazon-web-services aws-cloudformation aws-api-gateway
如何使用 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\" : \"MyFirstTag\", \"TagKey2\" : \"${MySecondTagAsParameter}\"}"
这也不起作用,促使我尝试 YAML 文字:
Run Code Online (Sandbox Code Playgroud)Tags: !Sub | { "TagKey1": "MyFirstTag", "TagKey2": "${MySecondTagAsParameter}" }
那也不起作用。
下面的方法就成功了:
Run Code Online (Sandbox Code Playgroud)Tags: TagKey1: MyFirstTag TagKey2: !Ref MySecondTagAsParameter
| 归档时间: |
|
| 查看次数: |
1944 次 |
| 最近记录: |