Skip to content

(aws-apigatewayv2): Validation of apiMappingKey in ApiMappingProps is too strict #15948

@dan-lind

Description

@dan-lind

I currently have a an API mapping key in the form of common-rest-api. Using the API mapping CDK construct to create a mapping like this results in an error message: An ApiMapping key may contain only letters, numbers and one of $-_.+!*'()

Reproduction Steps

const mapping = new ApiMapping(this, 'api-mapping', {
      api: this.api,
      domainName: this.domainName,
      apiMappingKey: 'key-with-multiple-hyphens',
    });

What did you expect to happen?

The API mapping should be created without an error. In the console, there is in fact nothing that stops me from creating a mapping key with the string -test-.

What actually happened?

I get an error message saying An ApiMapping key may contain only letters, numbers and one of $-_.+!*'()

Other

The issue is the regex on this line, which only permits a single character of the ones mentioned above.

const paramRe = '^[a-zA-Z0-9]*[-_.+!,$]?[a-zA-Z0-9]*$';

CDK version: 1.117.0


This is 🐛 Bug Report

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-apigatewayv2Related to Amazon API Gateway v2bugThis issue is a bug.effort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions