Aws-cdk: [aws-apigateway] Creating RestApi creates default BasePathMapping preventing creation of others with addBasePathMapping

Created on 11 Aug 2020  路  3Comments  路  Source: aws/aws-cdk

When creating a new RestApi, when a user tries to add a domain and configure that domain according to the documentation the process will fail due to an issue with BasePathMapping (Only one base path mapping is allowed if the base path is empty). However, the user is not given an opportunity to supply a basepath for the domain before the default 'empty' base path is created which results in an error

Reproduction Steps

    api = new apigw.LambdaRestApi( this, "proxy_api", {
        handler: props.function.lambdaFn,
        restApiName: 'apiname',
        proxy: true,
        endpointTypes: [ apigw.EndpointType.EDGE ]
    } );

    var domainName = this.api.addDomainName("domain_name", {
        domainName: "example.com",
        certificate: certificate,
        endpointType: apigw.EndpointType.EDGE, // default is REGIONAL,
        securityPolicy: apigw.SecurityPolicy.TLS_1_2,
    });

    domainName.addBasePathMapping( api, { basePath: 'foo'});

What did you expect to happen?

I expected to be able to add the basePath foo

What actually happened?

Only one base path mapping is allowed if the base path is empty. (Service: AmazonApiGateway; Status Code: 409; Error Code: ConflictException; Request ID: a2d4de69-74d0-4870-90f4-78d7d4017925)

Environment

  • CLI Version :
  • Framework Version: 1.57
  • Node.js Version:
  • OS : Windows, MacOS
  • Language (Version): Typescript

Other


This is :bug: Bug Report

@aws-cdaws-apigateway bug efforsmall p1

Most helpful comment

Also ran into this issue. Documentation is misleading.

All 3 comments

I managed to document the process for successfully creating a domain using CDK:

https://medium.com/@gregorypierce/cdk-restapi-custom-domains-554175a4b1f6?sk=197a9e2df62fd27c865e34951d8efad2

But one thing you'll notice if you follow the steps is that you will end up with a spare customdomain that is pointed to "nothing". There doesn't appear to be any way to avoid it. Since the A record is pointing to the appropriate location it works, so if you just never create the associated A record things will be okay - but that extra DomainName really shouldn't be there.

Encountered the same issue.

| CREATE_IN_PROGRESS   | AWS::ApiGateway::BasePathMapping  | api/CustomDomain/Map:--=> default apigw base_path
| CREATE_IN_PROGRESS   | AWS::ApiGateway::BasePathMapping  | api/CustomDomain/Map:foo=> user define base_path

Maybe we can have base_path parameter in DomainNameOptions to override the default base path mapping when defining DomainName via DomainNameOptions .

Or addBasePathMapping should override the default base_path.

Also ran into this issue. Documentation is misleading.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abelmokadem picture abelmokadem  路  3Comments

pepastach picture pepastach  路  3Comments

v-do picture v-do  路  3Comments

nzspambot picture nzspambot  路  3Comments

cybergoof picture cybergoof  路  3Comments