question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

apigateway.Resource props.parent not accepting RestAPI

See original GitHub issue

The documentation about apigateway.Resource here: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.Resource.html has this to say about the parent prop:

parent Type: IResource The parent resource of this resource. You can either pass another Resource object or a RestApi object here.

The last part, in bold, is the problem as it does not seem that a restapi object is being accepted.

Reproduction Steps

const myapi = new apigateway.RestApi(this, 'apigatewayApi');
const resource = new apigateway.Resource(this, 'apigatewayResourceTest', {
    parent: myapi,
    pathPart: 'test'
});

Error Log

(removed my local and project paths)

xxx/@aws-cdk/aws-apigateway/lib/resource.js:163
            restApiId: props.parent.restApi.restApiId,
                                                                  ^
TypeError: Cannot read property 'restApiId' of undefined
    at new Resource (xxx/@aws-cdk/aws-apigateway/lib/resource.js:163:45)

Environment

  • **CLI Version :aws-cli/1.16.184 Python/3.7.3 Linux/5.0.0-32-generic botocore/1.12.174
  • **Framework Version: CDK 1.14.0
  • **OS : Ubuntu Linux.
  • **Language :english

This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
jogoldcommented, Oct 24, 2019

parent: myapi.root?

You can also use myapi.root.addResource('test') see README.

2reactions
strottoscommented, Jan 22, 2020

Might be worth thinking about updating the documentation, it’s misleading here:

parent (IResource) – The parent resource of this resource. You can either pass another Resource object or a RestApi object here.

https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_apigateway/ProxyResource.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

interface RestApiProps · AWS CDK
A name for the API Gateway RestApi resource. retainDeployments? boolean, Retains old deployment resources when the API changes. apiKeySourceType? Type ...
Read more >
aws ressource limit api - how to separate stacks on RestApi
Unfortunatly, creating an RestApi with fromRestApiId does return an IRestApi Object, which is not containing all necessary properties to use it ...
Read more >
Data resources in UI Builder
Data resources that are made through REST API requests. Inherited versus local data resources. Inherited data resources come from the parent ...
Read more >
REST API (API Gateway v1) - Serverless Framework
Serverless ships with default status codes you can use to e.g. signal that a resource could not be found (404) or that the...
Read more >
Querying Azure Cosmos DB resources using the REST API
Must be set to application/query+json. Accept, Optional. At the moment, Cosmos DB always returns the response payload in standard JSON format.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found