【问题标题】:Custom domain for API Gateway using CloudFormation使用 CloudFormation 的 API Gateway 自定义域
【发布时间】:2018-06-20 06:18:59
【问题描述】:

我正在尝试使用 CloudFormation 为 API 网关定义自定义域(实际上是子域)。根据我能够找到的所有文档,以下内容应该可以工作,但是当我部署它时,我得到Invalid domain name identifier specifiedBasePathMapping

aws cloudformation deploy --template-file packaged-prompt.yaml --capabilities CAPABILITY_IAM --stack-name prompt-stack

prompt.yaml

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Resources:

  ...

  Certificate:
    Type: 'AWS::CertificateManager::Certificate'
    Properties:
      DomainName: example.mydomain.com

  DomainName:
    Type: 'AWS::ApiGateway::DomainName'
    Properties:
      CertificateArn: !Ref Certificate
      DomainName: example.mydomain.com

  Mapping:
    Type: 'AWS::ApiGateway::BasePathMapping'
    Properties:
      DomainName: !Ref DomainName
      RestApiId: !Ref Api

  Api:
    Type: AWS::Serverless::Api
    Properties:
      StageName: prod
      DefinitionBody:
        swagger: 2.0
        info:
          title:
            Ref: AWS::StackName
        paths:

          ....

【问题讨论】:

  • 您在 CloudFormation 中部署堆栈或在 API Gateway 中部署 API 时是否收到错误?如果在 BasePathMapping 中指定阶段,是否得到相同的结果?
  • 当我在 CloudFormation 中部署时。当我设置舞台时,CloudFormation 挂在CREATE_IN_PROGRESS 上。距离上次活动已经一个多小时了。
  • 使用 EDGE endpointConfigurationType 的域名一般需要 40 分钟左右。您可以尝试使用 REGIONAL endpointConfigurationType(创建只需几秒钟)。可以从 cfn docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/… 做到这一点?
  • 另外,当您在此堆栈中创建证书时,它会挂起,直到您验证它为止。您为其注册证书的域的所有者将receive an email 要求验证。另一种方法是使用DNS verification。如果您确实尝试注册mydomain.com,除非您拥有它并且可以验证它,否则堆栈最终会失败。有兴趣知道最终的失败消息是什么。
  • 您确定您输入的域名格式有效且不包含任何字符吗?例如,您是否不小心输入了 HTTP 或 domaincom 忘记了一个点?

标签: aws-api-gateway amazon-cloudformation


【解决方案1】:

BasePathMapping 中的属性缺失

BasePath: ""

【讨论】:

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