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): permission error in lambda integration when function name is modified #8813

Merged
merged 6 commits into from Jul 2, 2020

Conversation

nija-at
Copy link
Contributor

@nija-at nija-at commented Jun 30, 2020

Changing function name triggers a resource replacement - the old
function is removed and replaced with a new function.
However, the RestApi deployment remains untouched and is still pointing
at the ARN of the, now stale, function.

The fix is to trigger a new deployment if the function name changes.

fixes #5306


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

… name is modified

Changing function name triggers a resource replacement - the old
function is removed and replaced with a new function.
However, the RestApi deployment remains untouched and is still pointing
at the ARN of the, now stale, function.

The fix is to trigger a new deployment if the function name changes.

fixes #5306
@nija-at nija-at added the pr-linter/exempt-test The PR linter will not require test changes label Jun 30, 2020
@nija-at nija-at self-assigned this Jun 30, 2020
@nija-at nija-at requested a review from a team June 30, 2020 15:12
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jun 30, 2020
nija-at pushed a commit that referenced this pull request Jun 30, 2020
Currently, the Method construct reaches into the internals of the
Integration class to construct itself, via the _props() internal method.

Change to a more recent pattern where the bind() returns a result that
contains all of the information that the Method class requires to
finalize the bind.

Motivation for the change
This change - #8813 - requires a
property returned to the Method that is not user specified. The change
already introduces this pattern. This PR takes it a bit further and
applies the same logic to existing properties, so that there is now only
one way for the Method to get the result of the bind.
@nija-at nija-at removed the pr-linter/exempt-test The PR linter will not require test changes label Jun 30, 2020
@nija-at nija-at requested a review from eladb June 30, 2020 15:56
* This value is included in computing the Deployment's fingerprint. When the fingerprint
* changes a new deployment is triggered.
* This property should carry a different value when the Deployment needs to be refreshed.
* @default - deployments are not triggered for any change of this integration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a note that it can be an arbitrary string and does not have to be a hash.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to index type <string, string> so the user doesn't have to do JSON.stringify() unless they're adding a nested struct. The input to the hash gen will also be a bit nicer without the serialized objects.

@nija-at nija-at requested review from eladb and a team July 1, 2020 14:15
@nija-at nija-at requested a review from eladb July 1, 2020 17:31
@mergify
Copy link
Contributor

mergify bot commented Jul 1, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@nija-at nija-at added the pr/do-not-merge This PR should not be merged at this time. label Jul 1, 2020
@nija-at nija-at removed the pr/do-not-merge This PR should not be merged at this time. label Jul 1, 2020
@mergify
Copy link
Contributor

mergify bot commented Jul 1, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 00eca44
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Jul 2, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit f1b37ef into master Jul 2, 2020
@mergify mergify bot deleted the nija-at/apigateway-functionName-triggerDeployment branch July 2, 2020 09:02
mergify bot pushed a commit that referenced this pull request Jul 2, 2020
Currently, the Method construct reaches into the internals of the
Integration class to construct itself, via the _props() internal method.

Change to a more recent pattern where the bind() returns a result that
contains all of the information that the Method class requires to
finalize the bind.

Motivation for the change
This change - #8813 - requires a
property returned to the Method that is not user specified. The change
already introduces this pattern. This PR takes it a bit further and
applies the same logic to existing properties, so that there is now only
one way for the Method to get the result of the bind.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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.

API Gateway proxy Lambda loses permissions when functionName is changed
3 participants