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

feat(custom-resources): provider framework #4572

Merged
merged 36 commits into from
Nov 6, 2019

Conversation

eladb
Copy link
Contributor

@eladb eladb commented Oct 17, 2019

The @aws-cdk/custom-resources.Provider construct is a "mini-framework" for
implementing providers for AWS CloudFormation custom resources. The framework offers a high-level API which makes it easier to implement robust
and powerful custom resources and includes the following capabilities:

  • Handles responses to AWS CloudFormation and protects against blocked
    deployments
  • Validates handler return values to help with correct handler implementation
  • Supports asynchronous handlers to enable long operations which can exceed the AWS Lambda timeout

See README file for details.

Fixes #4711
Related #4147


  • Update README
  • Support reusing the same handler for onEvent and isComplete.
  • Add a few more samples

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

`AsyncCustomResource` is a framework for defining robust custom resources. It makes it easy to implement providers for resources that require waiting for the resource to be ready, potentially for time period longer than the AWS Lambda timeout (15min at the moment). When a resource is created, the "begin" operation is invoked, and a state machine is triggered to wait for "complete" to indicate that it's done. It can also indicate that it's still waiting, in which case, Step Functions retry logic will kick in and "complete" will be called thereafter. If retries are exhausted, the resource operation will fail with a timeout. Any exceptions thrown from "begin" or "complete" will be reported as an operation failure to ensure that the custom resource does not hang the stack operation.
@mergify
Copy link
Contributor

mergify bot commented Oct 17, 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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

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

@SomayaB SomayaB added the contribution/core This is a PR that came from AWS. label Oct 18, 2019
- change semantics to "onEvent" and "isComplete"
- use Lambda layers to load user code
- reorg project files
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

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

@eladb eladb removed their assignment Oct 27, 2019
Elad Ben-Israel added 4 commits October 28, 2019 21:17
* support specifying execution role for each resource instance (very powerful)
* always require that on-event will return a physical resource id (to avoid errors)
* emit entire stack trace on errors
* implement an integration test/sample (S3File)
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

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

Elad Ben-Israel added 4 commits October 31, 2019 10:43
* use RequestId as the name of the state machine execution due to limitations in the name
* make handler names required to make sure users are aware that they have to implement them
* implement another custom resource in the integration test which "waits" for the object to contain certain contents (tests async resources).
@eladb eladb changed the title feat(custom-resources): async custom resources feat(custom-resources): custom resources provider framework Nov 4, 2019
@eladb eladb marked this pull request as ready for review November 4, 2019 20:25
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

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

@eladb eladb changed the title feat(custom-resources): custom resources provider framework feat(custom-resources): provider framework Nov 4, 2019
@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 6, 2019

Are we marking this @experimental?

@eladb
Copy link
Contributor Author

eladb commented Nov 6, 2019

Are we marking this @experimental?

The whole module is experimental

Elad Ben-Israel added 2 commits November 6, 2019 14:45
- remove validation of CFN event (not required)
- redesign `failOnError` as `safeHandler` which returns a "safe" cloudformation handler.
- fail if user handler returns a non-JSON response.
@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Nov 6, 2019
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

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

Elad Ben-Israel added 3 commits November 6, 2019 15:44
@eladb eladb removed the pr/do-not-merge This PR should not be merged at this time. label Nov 6, 2019
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • 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 Nov 6, 2019

Thank you for contributing! Your pull request is now being automatically merged.

@mergify mergify bot merged commit f9eec04 into master Nov 6, 2019
@mergify mergify bot deleted the benisrae/async-custom-resources branch November 6, 2019 15:47
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@whereisaaron
Copy link

"How to specify stack creation and rollback timeout? #2125"

Issue #2125 was closed saying it was resolved by this pull request. But how? This seems like an unrelated change?

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.

Speed up custom resource development
6 participants