Skip to content

Multi-domain config causes "Error: Multiple API types detected in CloudFormation template: HTTP, REST" #13329

@stade

Description

@stade

Issue description

According to the serverless documentation you should be able to create a stack with both http and rest ApiGateways with custom domains configured for both.

When trying to setup config similar to:

myTestfuction:
  handler: src/functions/myfunction.handler
  events:
    - httpApi:
        path: /test
        method: post
        authorizer:
          type: aws_iam
    - http:
        path: test
        method: post
        authorizer: aws_iam
provider:
  domains:
    - name: http.api.example.com
      apiType: httpApi
    - name: rest.api.example.com
      apiType: rest

We get this error:

✖ Error: Multiple API types detected in CloudFormation template: HTTP, REST.
Please explicitly specify the apiType for each domain configuration.
Example:
domains:
  - domainName: api.example.com
    apiType: rest
  - domainName: ws.example.com
    apiType: websocket
    at ServerlessCustomDomain.getDefaultApiType (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:1819:1958)
    at ServerlessCustomDomain.initializeVariables (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:1826:403)
    at ServerlessCustomDomain.hookWrapper (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:1819:1301)
    at PluginManager.runHooks (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:1923:11252)
    at async PluginManager.invoke (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:1923:11956)
    at async PluginManager.run (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:1923:12754)
    at async Serverless.run (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:1930:10564)
    at async runFramework (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:1957:1781)
    at async TraditionalRunner.run (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:1953:28245)
    at async route (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:2167:2848)
    at async Object.run (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:2168:3893)
    at async run2 (file:///home/tatutahv/.serverless/releases/4.31.2/package/dist/sf-core.js:2168:5047)

Without the domain config I can deploy the stack successfully.

The issue seems to be related to similar issue that this pull request is trying to fix:

#13310

We would want to see this bug fixed as we have cases where we want to evaluate both rest and http api Apigateways and enabling them both makes it also easier to migrate between them.

Context

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions