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

API Gateway: api.node.defaultResource does not work #3234

Closed
1 task done
RomainMuller opened this issue Jul 8, 2019 · 1 comment · Fixed by #4318
Closed
1 task done

API Gateway: api.node.defaultResource does not work #3234

RomainMuller opened this issue Jul 8, 2019 · 1 comment · Fixed by #4318
Assignees
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug.

Comments

@RomainMuller
Copy link
Contributor

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

  • I'm submitting a ...

    • 🪲 bug report
  • What is the current behavior?
    If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce

const api: RestApi = /* ... */;
api.node.defaultResouce; // Throws an exception
  • What is the expected behavior (or behavior of feature suggested)?

I expected api.node.defaultResource to return the CfnRestApi resource.

It turns out the RestApi construct registers the CfnRestApi as Resource and a virtual construct for the root resource (in the REST sense) as Default. This is surprising, as the CfnRestApi should be what is named Default, and the root REST resource should probably be called something like Root.

  • Please tell us about your environment:

    • CDK CLI Version: 0.37.0
    • Module Version: 0.37.0
    • OS: all
    • Language: all
@RomainMuller RomainMuller added needs-triage This issue or PR still needs to be triaged. @aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug. labels Jul 8, 2019
@eladb eladb self-assigned this Aug 12, 2019
@eladb eladb assigned nija-at and unassigned eladb Sep 3, 2019
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Sep 11, 2019
@nija-at
Copy link
Contributor

nija-at commented Oct 1, 2019

Confirmed this still occurs in CDK version 1.10.0

Call to api.node.defaultChild on the RestApi resource throws the exception Cannot determine default child for FirstStack/BooksApi. There is both a child with id "Resource" and id "Default"

nija-at pushed a commit that referenced this issue Oct 1, 2019
Current calls to defaultChild would throw an exception since it
contains children named 'Resource' and 'Default'.
Explicitly setting the defaultChild value to the CfnRestApi construct.

fixes #3234
@mergify mergify bot closed this as completed in #4318 Oct 2, 2019
mergify bot pushed a commit that referenced this issue Oct 2, 2019
…4318)

* fix(apigateway): defaultChild on RestApi returns the underlying L1

Current calls to defaultChild would throw an exception since it
contains children named 'Resource' and 'Default'.
Explicitly setting the defaultChild value to the CfnRestApi construct.

fixes #3234

* Add tests and fixup documentation

* Add period

* PR feedback
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants