Skip to content

[aws-apigateway] Creating RestApi creates default BasePathMapping preventing creation of others with addBasePathMapping #9581

@gregorypierce

Description

@gregorypierce

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 Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-apigatewayRelated to Amazon API GatewaybugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions