Skip to content

bug: Cannot delete AWS::ApiGateway::BasePathMapping #13503

@Garethp

Description

@Garethp

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

If you attempt to remove a BasePathMapping from a deployed ApiGateway when redeploying CDK, you will get the error

Failed to delete resource with id RestApiCustomDomainMapapigatewayRestApi11F5025C245D95DA of type AWS::ApiGateway::BasePathMapping

Expected Behavior

The BasePathMapping should be successfully deleted

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker compose up
services:
  localstack:
    container_name: "localstack-testing"
    image: localstack/localstack-pro:4.11.1
    network_mode: bridge
    ports:
      - "4566:4566"
      - "4510-4559:4510-4559"
      - "127.0.0.1:53:53"
      - "127.0.0.1:53:53/udp"
      - "4571:4571"
    environment:
      - DOCKER_HOST=unix:///var/run/docker.sock
      - TEST_AWS_ACCOUNT_ID=000000000000
      - LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN}
      - NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt
      - CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
      - REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/etc/ssl/certs/:/etc/ssl/certs/"

CDK Stack

export class ApiGatewayStack extends Stack {
  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

    if (!!process.env.SECOND_DEPLOY) return;

    const certificate = new Certificate(this, "Certificate", {
      domainName: "example.localhost.localstack.cloud",
    });

    const api = new RestApi(this, "RestApi", {
      restApiName: "test-api",
      domainName: {
        domainName: "example.localhost.localstack.cloud",
        certificate,
      },
    });
    api.root.addMethod("GET");
  }
}

Commands

yarn cdklocal bootstrap
yarn cdklocal deploy --all --require-approval never
SECOND_DEPLOY=true yarn cdklocal deploy --all --require-approval never

Environment

- OS: Ubuntu 24.04
- LocalStack: 4.11.1
  LocalStack version: 4.11.1
  LocalStack Docker image sha: 5e04a5c0b207
  LocalStack build date: 2025-11-26
  LocalStack build git hash: 600b61ad7

Anything else?

I've reproduced the issue here: https://github.com/Garethp/localstack-testing/tree/base-path-mapping-deletion. When I clone down the branch base-path-mapping-deletion, run yarn install, and then ./start.sh I see the message

Failed to delete resource with id RestApiCustomDomainMapapigatewayRestApi11F5025C245D95DA of type AWS::ApiGateway::BasePathMapping

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions