Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aws-apigateway] BasePathMapping does not configure stage for SpecRestApi with domainName #10300

Closed
marcogrcr opened this issue Sep 11, 2020 · 1 comment · Fixed by #10749
Closed
Assignees
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug. effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p2

Comments

@marcogrcr
Copy link

When I create a RestApi specifying a value for domainName the underlying CfnBasePathMapping gets configured correctly:

{
  "DomainName": { "Ref": "..." },
  "RestApiId": { "Ref": "..." },
  "Stage": { "Ref": "..." }
}

However, when I use SpecRestApi with domainName, the underlying CfnBasePathMapping omits the stage field:

{
  "DomainName": { "Ref": "..." },
  "RestApiId": { "Ref": "..." }
}

Reproduction Steps

import { RestApi, SpecRestApi } from "@aws-cdk/aws-apigateway";
import { Stack } from "@aws-cdk/core";

const stack = new Stack();

new RestApi(stack, "MyRestApi", {
  // (...)
  domainName: { /* (...) */ }
}).api.root.addMethod("GET");;

new SpecRestApi(stack, "MySpecRestApi", {
  // (...)
  domainName: { /* (...) */ }
});

What did you expect to happen?

The AWS::ApiGateway::BasePathMapping resource generated by SpecRestApi is equivalent to the one generated by RestApi.

What actually happened?

The AWS::ApiGateway::BasePathMapping resource generated by SpecRestApi omits the Stage field.

Environment

  • CLI Version: v1.62.0
  • Framework Version: v1.62.0
  • Node.js Version: v12.13.0
  • OS: Mac OS v10.14.6
  • Language (Version): TypeScript v3.9.6

Other

I believe the root cause of this bug is here:

const stage = props.stage ?? (props.restApi instanceof RestApi
? props.restApi.deploymentStage
: undefined);
new CfnBasePathMapping(this, 'Resource', {
basePath: props.basePath,
domainName: props.domainName.domainName,
restApiId: props.restApi.restApiId,
stage: stage && stage.stageName,
});

I believe props.restApi instanceof RestApi should be replaced with props.restApi instanceof RestApiBase.


This is 🐛 Bug Report

@marcogrcr marcogrcr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 11, 2020
@github-actions github-actions bot added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Sep 11, 2020
@nija-at nija-at added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Sep 17, 2020
alvyn279 added a commit to alvyn279/aws-cdk that referenced this issue Oct 7, 2020
- Expects generic `RestApiBase` instead of `RestApi` at `BasePathMapping` creation
- Fixes aws#10300
@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Oct 7, 2020
alvyn279 added a commit to alvyn279/aws-cdk that referenced this issue Oct 16, 2020
- Expects generic `RestApiBase` instead of `RestApi` at `BasePathMapping` creation
- Fixes aws#10300
@mergify mergify bot closed this as completed in #10749 Oct 19, 2020
mergify bot pushed a commit that referenced this issue Oct 19, 2020
- Expects generic `RestApiBase` instead of `RestApi` at `BasePathMapping` creation
- Fixes #10300


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug. effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants