我已在 SAM 中使用 AWS::Serverless::API 创建了一个 API 网关,现在我想向网关添加标签,以便对具有相同标签的每个网关实施安全约束。
Type: AWS::Serverless::Api
Properties:
Name: PrivateApi
StageName: v1
Tags:
- Key: TagName
Value: TagValue
MethodSettings:
...
Run Code Online (Sandbox Code Playgroud)
查看文档后,我想出了上面的代码。正如文档所述,它以上面所示的方式支持标签,但是当我部署时,出现以下错误。
samcli.commands.validate.lib.exceptions.InvalidSamDocumentException: [InvalidResourceException('PrivateApi', "Type of property 'Tags' is invalid.")] ('PrivateApi', "Type of property 'Tags' is invalid.")
有关标签的文档链接:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html
任何对此的帮助将不胜感激!
原始问题:如何从 SAM Cloud-formation 中的 AWS APIGateway 域名中获取区域域名
编辑:我改变了这个问题,希望能获得更多流量到这个答案,因为它回答了几个问题,而不仅仅是我原来的问题。
当我尝试部署我的堆栈时出现以下错误:
resource DomainName does not support attribute type regionalDomainName in Fn::GetAtt
我的 yml 文件如下所示:
PublicApi:
Type: AWS::Serverless::Api
Properties:
Name: PublicApi
...
EndpointConfiguration: REGIONAL
DomainName:
Type: AWS::ApiGateway::DomainName
Properties:
RegionalCertificateArn: "arn:aws:acm:${Region}:XXXXXXXXXXX:certificate/XXXXXXXXXXXXX"
DomainName: !Sub ${Stage}.${name}
EndpointConfiguration:
Types:
- REGIONAL
myDNSRecord:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneId : Z1UJRXOUMOOFQ8
Name: !Sub ${Stage}.${name}
AliasTarget:
HostedZoneId: Z1UJRXOUMOOFQ8
DNSName: !GetAtt DomainName.regionalDomainName
Type: A
UrlMapping:
Type: AWS::ApiGateway::BasePathMapping
DependsOn:
- PublicApi
Properties:
DomainName: !Ref DomainName
RestApiId: !Ref PublicApi
Stage: !Ref Stage
Run Code Online (Sandbox Code Playgroud)
以下内容来自域名文档 …
yaml amazon-web-services aws-cloudformation serverless aws-sam