Skip to content

(aws-apigatewayv2): apiEndpoint returns incomplete URL #16638

@moltar

Description

@moltar

https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigatewayv2.HttpApi.html#apiendpointspan-classapi-icon-api-icon-experimental-titlethis-api-element-is-experimental-it-may-change-without-noticespan

Get the default endpoint for this API.

Not sure if this is intentional, as the docs aren't clear.

But calling apiEndpoint on an API that has a domainName and mappingKey set will produce a wrong URL.

Reproduction Steps

const api = new HttpApi(scope, 'api', {
  domainName: properties.domainName, // example.com
  mappingKey: properties.mappingKey, // foo
})

new CfnOutput(this, 'url', {
  value: api.apiEndpoint,
})

What did you expect to happen?

To have the following resolved value:

https://example.com/foo

What actually happened?

The value resolves to the following:

https://xyz.execute-api.ap-northeast-1.amazonaws.com

Note that the domain name is not applied, and the mapping key is not present.

Environment

  • CDK CLI Version : 1.123.0
  • Framework Version: 1.123.0
  • Node.js Version: v14.17.5
  • OS : macOS
  • Language (Version): TS

Other

Docs state:

https://docs.aws.amazon.com/cdk/api/latest/docs/aws-apigatewayv2-readme.html#defining-http-apis

You can retrieve the full domain URL with mapping key using the domainUrl property as so -

screenshot-20210924T144249-hV0QdIDI

However, I don't have this prop on the defaultStage.

screenshot-20210924T144334-z2DNRfUX


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-apigatewayv2Related to Amazon API Gateway v2bugThis 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