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-lambda): Error: No child with id: 'InvokeServicePrincipal(apigateway.amazonaws.com)' #12263

Closed
devendra-kumar1 opened this issue Dec 29, 2020 · 7 comments
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made.

Comments

@devendra-kumar1
Copy link

I have a stack where i have resources called api gateway and lambda.
Also i am importing one lambda which is part of different stack and attaching it to once resource of api gateway.

I am facing below issues.

  1. API GW resource is giving 500 error while invocation due to invalid permission for imported lambda however it is not for lambda created as part of stack.
    Note : Later on I learnt from issue that this is as per design due to variable canCreatePermissions
  2. So to avoid the above issue i thought to add below line of code to grantInvoke but it is also throwing error while trying to synth
    Code : this.importedLambda.grantInvoke(new ServicePrincipal('apigateway.amazonaws.com'));

Reproduction Steps

  • **CDK CLI Version :1.62.0
  • **Framework Version:1.62.0
  • Node.js Version: 12.0
  • **OS :Windows
  • Language (Version): TypeScript (3.8.3)

Reffered issue #8240 but no luck.

Please guide me in right direction

@devendra-kumar1 devendra-kumar1 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 29, 2020
@NGL321 NGL321 changed the title aws-lambda: Error: No child with id: 'InvokeServicePrincipal(apigateway.amazonaws.com)' (aws-lambda): Error: No child with id: 'InvokeServicePrincipal(apigateway.amazonaws.com)' Jan 28, 2021
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Jan 28, 2021
@nija-at
Copy link
Contributor

nija-at commented Feb 2, 2021

Hi @devendra-kumar1 - where is this imported lambda? Is it part of the same account and region or elsewhere?

Please provide a code that reproduces this issue.

@nija-at nija-at added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Feb 2, 2021
@devendra-kumar1
Copy link
Author

@nija-at Imported lambda in same account and region.
Sample code i am using .
const importedLambda = Function.fromFunctionArn(scope, 'importedLambda', 'Arn of imported lambda');
this.importedLambda.grantInvoke(new ServicePrincipal('apigateway.amazonaws.com'));

@devendra-kumar1
Copy link
Author

as a workaround i used below code to sort this issue.

new CfnPermission(scope, 'ImportedLambdaPermission', {
action: 'lambda:InvokeFunction',
functionName: importedLambda.functionArn,
principal: 'apigateway.amazonaws.com'
})

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Feb 3, 2021
@nija-at
Copy link
Contributor

nija-at commented Feb 4, 2021

We support this use case starting from CDK version 1.75.0 - 715a030.

You need to set the sameEvironment property.

@nija-at nija-at added closing-soon This issue will automatically close in 4 days unless further comments are made. and removed needs-triage This issue or PR still needs to be triaged. labels Feb 4, 2021
@devendra-kumar1
Copy link
Author

Thanks @nija-at . Will give a try and update the ticket accordingly

@devendra-kumar1
Copy link
Author

@nija-at It is working fine :)

@github-actions
Copy link

github-actions bot commented Feb 4, 2021

⚠️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-lambda Related to AWS Lambda bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made.
Projects
None yet
Development

No branches or pull requests

2 participants