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

fix(apigateway): cross-stack lambda integration causes a cyclic reference #4010

Merged
merged 2 commits into from
Sep 12, 2019

Conversation

nija-at
Copy link
Contributor

@nija-at nija-at commented Sep 10, 2019

  1. Token resolution of Deployment construct must not resolve the entire
    stack, specifically during the prepare phase.

    stack.resolve() works only after the CDK app has been fully prepared.
    During the 'prepare' phase, token resolution should instead resolve
    the token partially and within the local context.

  2. Scope the lambda.CfnPermission construct closer to the consumer of
    the permission rather than being closer to the lambda function.

    For instance, when a lambda function is being consumed by an
    APIGateway RestApi Method as a cross-stack reference, placing the
    lambda.CfnPermission construct closer to the RestApi Method reduces
    the possibility of cyclic dependencies.

fixes #3705, #3000


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@mergify
Copy link
Contributor

mergify bot commented Sep 10, 2019

Thanks so much for taking the time to contribute to the AWS CDK ❤️

We will shortly assign someone to review this pull request and help get it
merged. In the meantime, please take a minute to make sure you follow this
checklist
:

  • PR title type(scope): text
    • type: fix, feat, refactor go into CHANGELOG, chore is hidden
    • scope: name of module without aws- or cdk- prefix or postfix (e.g. s3 instead of aws-s3-deployment)
    • text: use all lower-case, do not end with a period, do not include issue refs
  • PR Description
    • Rationale: describe rationale of change and approach taken
    • Issues: indicate issues fixed via: fixes #xxx or closes #xxx
    • Breaking?: last paragraph: BREAKING CHANGE: <describe what changed + link for details>
  • Testing
    • Unit test added. Prefer to add a new test rather than modify existing tests
    • CLI or init templates change? Re-run/add CLI integration tests
  • Documentation
    • README: update module README to describe new features
    • API docs: public APIs must be documented. Copy from official AWS docs when possible
    • Design: for significant features, follow design process

@mergify
Copy link
Contributor

mergify bot commented Sep 10, 2019

Continuous integration build failed

eladb
eladb previously requested changes Sep 10, 2019
packages/@aws-cdk/aws-apigateway/lib/deployment.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-apigateway/lib/deployment.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/lib/function-base.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-lambda/lib/function-base.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/core/lib/token.ts Show resolved Hide resolved
@mergify mergify bot dismissed eladb’s stale review September 11, 2019 13:37

Pull request has been modified.

@nija-at nija-at requested a review from eladb September 12, 2019 10:08
eladb
eladb previously approved these changes Sep 12, 2019
@mergify mergify bot dismissed eladb’s stale review September 12, 2019 10:58

Pull request has been modified.

@eladb eladb changed the title fix(apigateway): Bug fixes for cross-stack use of APIGateway and Lambda fix(apigateway): cross-stack lambda integration causes a cyclic reference Sep 12, 2019
@eladb
Copy link
Contributor

eladb commented Sep 12, 2019

Make a couple of tweaks (with "@default" if there is concrete default value, we just use "-") and the title of a "fix" PR should describe the bug, not the fix. The changelog will show "fixes" and then a list of bugs that were fixed.

…n and/or creates cyclic references

1. Token resolution of Deployment construct must not resolve the entire
   stack, specifically during the prepare phase.

   stack.resolve() works only after the CDK app has been fully prepared.
   During the 'prepare' phase, token resolution should instead resolve
   the token partially and within the local context.

2. Scope the lambda.CfnPermission construct closer to the consumer of
   the permission rather than being closer to the lambda function.

   For instance, when a lambda function is being consumed by an
   APIGateway RestApi Method as a cross-stack reference, placing the
   lambda.CfnPermission construct closer to the RestApi Method reduces
   the possibility of cyclic dependencies.

fixes #3705, #3000
eladb
eladb previously approved these changes Sep 12, 2019
@nija-at nija-at merged commit 17fc967 into master Sep 12, 2019
@nija-at nija-at deleted the nija-at/apig-token-resolve branch September 12, 2019 13:09
@NGL321 NGL321 added the contribution/core This is a PR that came from AWS. label Sep 27, 2019
@ashwgupt
Copy link
Contributor

ashwgupt commented Oct 2, 2019

Can someone please share the release version carrying this fix?

We are still seeing this issue when using v 1.10.0

@nija-at
Copy link
Contributor Author

nija-at commented Oct 2, 2019

It was released in 1.9.0. You can usually find this information in our CHANGELOG.md.

Make sure your application is using CDK packages >=1.9.0 and not just a later CLI version (for typescript, by checking package-lock.json).

If you think this is still occurring, feel free to open a new issue with repro steps.

@wywarren
Copy link

wywarren commented May 8, 2020

Has this been resolved for python? We're seeing similar cyclic problems with API Gateway and Lambda being separated into two stacks and passing the reference of the API gateway into the Lambda stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

APIGateway and Lambdas in separate stacks fails
5 participants