指定的域名标识符无效

Jac*_*ert 1 amazon-web-services aws-cloudformation aws-api-gateway

在尝试创建AWS::ApiGateway::BasePathMapping通过CloudFormation时,我收到以下错误:

Invalid domain name identifier specified
Run Code Online (Sandbox Code Playgroud)

以下是我的CloudFormation模板应该创建的部分AWS::ApiGateway::BasePathMapping:

{
    "Parameters": {
        "ApiDomainName": {
            "Description": "The domain name for the API",
            "Type": "String"
        }
    },
    "Resources": {
        "ApiBasePathMapping": {
            "Type": "AWS::ApiGateway::BasePathMapping",
            "Properties": {
                "DomainName": {
                    "Ref": "ApiDomainName"   
                },
                "RestApiId": {
                    "Ref": "RepositoryApi"
                },
                "Stage": {
                    "Ref": "ApiProductionStage"
                }
            },
            "DependsOn": [
                "ApiProductionStage"
            ]
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

文件并没有提及,它需要什么特别的DomainName,但该资源的文档似乎缺乏一些信息(它没有列出,例如产出,即使是有Distribution Domain Name作为例子创建).

堆栈的其余部分按预期工作.我试图将此资源添加为更改集.我拥有我想要使用的域名,并且我已在ACM中为此域创建了证书.

Adi*_*tya 7

从AWS论坛引用:

在将域名添加到API网关后,您只能创建或修改基本路径映射.当找不到基本路径映射中给出的域名时,将返回此"指定的无效域名标识符"错误消息,表明尚未添加该域名.

此外,截至2017年3月,通过CloudFormation将域名添加到API网关的唯一方法是通过CloudFormation提供的自定义资源.

参考:https://forums.aws.amazon.com/message.jspa? messageID = 769627


Rod*_*goM 5

现在可以这样做了。您只需要在 CFN 模板上明确说明存在依赖关系 ( DependsOn):

...
ApiDevMapping:
  Type: 'AWS::ApiGateway::BasePathMapping'
  Properties:
    BasePath: v1.0
    Stage: dev
    DomainName: my-api.example.com
    RestApiId: !Ref MobileApiDev
DependsOn:
  - MobileApiDevDomain
...
Run Code Online (Sandbox Code Playgroud)