【问题标题】:How to create AWS API Gateway Custom Domain using CloudFormation?如何使用 CloudFormation 创建 AWS API Gateway 自定义域?
【发布时间】:2020-01-06 22:39:14
【问题描述】:

我正在尝试为 API 网关创建自定义域,
我已经在 ACM 中导入了 SSL。

我正在尝试运行以下模板,
但出现错误 -

AWSTemplateFormatVersion: 2010-09-09
Transform: 'AWS::Serverless-2016-10-31'
Description: Test Custom Domain

Resources:
  Type: AWS::ApiGateway::DomainName
  Properties: 
    CertificateArn: !Sub 'arn:aws:acm:${AWS::Region}:${AWS::AccountId}:certificate/xxxx-xxx-xxx-xxxx-xxxx'
    DomainName: 'test-api.example.com'
    EndpointConfiguration: 
      Types: 
        - 'EDGE'

错误 -

Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Structure of the SAM template is invalid. All 'Resources' must be Objects. If you're using YAML, this may be an indentation issue.. Rollback requested by user.

参考 ->
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-domainname.html

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    错误告诉您问题所在。您正在使用 YAML,但您的缩进不正确。

    要解决您的问题,请修复Properties 属性的缩进,使其比TypeProperties 属性缩进一个制表符。

    【讨论】:

    • 嗨,仍然出现同样的错误,更新了我正在尝试运行的模板
    【解决方案2】:

    问题是缺少logicalId,
    每个要创建的资源都需要属于一个logicalId -

    AWSTemplateFormatVersion: 2010-09-09
    Transform: 'AWS::Serverless-2016-10-31'
    Description: Test Custom Domain
    
    Resources:
      test:
        Type: AWS::ApiGateway::DomainName
        Properties: 
          CertificateArn: !Sub 'arn:aws:acm:${AWS::Region}:${AWS::AccountId}:certificate/xxxx-xxx-xxx-xxxx-xxxx'
          DomainName: 'test-api.example.com'
          EndpointConfiguration: 
            Types: 
              - 'EDGE'
    

    【讨论】:

      猜你喜欢
      • 2018-06-20
      • 1970-01-01
      • 1970-01-01
      • 2019-07-30
      • 2018-12-26
      • 2021-10-14
      • 2018-07-02
      • 2020-10-04
      • 2020-01-16
      相关资源
      最近更新 更多