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): rename catchErrorPattern to ignoreErrorCodesMatching #6553

Merged
merged 11 commits into from
Mar 4, 2020

Conversation

iliapolo
Copy link
Contributor

@iliapolo iliapolo commented Mar 3, 2020

Description

Notice that i've added the ignoreErrorCodesMatching and PhysicalResourceId.fromResponse validation even on the onDelete. This is because it might result in an empty physical resource id, which will in turn cause a failure when submitting the response to CloudFormation:

2 | 8:26:06 PM | DELETE_FAILED        | Custom::AWS           | Playground/FakeResource/Resource/Default (PlaygroundFakeResourceBC34BA32) Invalid PhysicalResourceId
	new CustomResource (/Users/epolon/dev/src/github.com/aws/aws-cdk/packages/@aws-cdk/aws-cloudformation/lib/custom-resource.ts:163:21)
	\_ new AwsCustomResource (/Users/epolon/dev/src/github.com/aws/aws-cdk/packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts:259:27)
	\_ new AwsCdkPlaygroundConstruct (/Users/epolon/dev/src/github.com/aws/aws-cdk-playground/lib/aws-cdk-playground-stack.ts:19:5)
	\_ Object.<anonymous> (/Users/epolon/dev/src/github.com/aws/aws-cdk-playground/bin/aws-cdk-playground.ts:15:1)
	\_ Module._compile (internal/modules/cjs/loader.js:778:30)
	\_ Module.m._compile (/Users/epolon/dev/src/github.com/aws/aws-cdk-playground/node_modules/ts-node/src/index.ts:536:23)
	\_ Module._extensions..js (internal/modules/cjs/loader.js:789:10)
	\_ Object.require.extensions.(anonymous function) [as .ts] (/Users/epolon/dev/src/github.com/aws/aws-cdk-playground/node_modules/ts-node/src/index.ts:539:12)
	\_ Module.load (internal/modules/cjs/loader.js:653:32)
	\_ tryModuleLoad (internal/modules/cjs/loader.js:593:12)
	\_ Function.Module._load (internal/modules/cjs/loader.js:585:3)
	\_ Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
	\_ main (/Users/epolon/dev/src/github.com/aws/aws-cdk-playground/node_modules/ts-node/src/bin.ts:212:14)
	\_ Object.<anonymous> (/Users/epolon/dev/src/github.com/aws/aws-cdk-playground/node_modules/ts-node/src/bin.ts:470:3)
	\_ Module._compile (internal/modules/cjs/loader.js:778:30)
	\_ Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
	\_ Module.load (internal/modules/cjs/loader.js:653:32)
	\_ tryModuleLoad (internal/modules/cjs/loader.js:593:12)
	\_ Function.Module._load (internal/modules/cjs/loader.js:585:3)
	\_ Function.Module.runMain (internal/modules/cjs/loader.js:831:12)

Commit Message

feat(custom-resources): rename catchErrorPattern to ignoreErrorCodesMatching (#6553)

In the spirit of being "Explicit and Clear*, renaming catchErrorPattern to ignoreErrorCodesMatching since it better describes the meaning of this property.

In addition, the following validations were added:

  • ignoreErrorCodesMatching cannot be used with PhysicalResourceId.fromResponse since the response might not exist.
  • ignoreErrorCodesMatching cannot be used with getData or getDataString since the resource might not have any attributes due to the error catching.

Relates to #5873

BREAKING CHANGE: catchErrorPattern was renamed to ignoreErrorCodesMatching. In addition, a few synth time validations were added when using this property. See Error Handling for details.

End Commit Message

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

@iliapolo iliapolo requested review from eladb and rix0rrr March 3, 2020 09:44
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 3, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@iliapolo iliapolo requested a review from rix0rrr March 3, 2020 13:21
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@@ -190,9 +190,21 @@ export interface AwsCustomResourceProps {
*
*/
export class AwsCustomResource extends cdk.Construct implements iam.IGrantable {

private static breakIgnoreErrorsCircuit(sdkCalls: Array<AwsSdkCall | undefined>, caller: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

personal taste... why not a non exported function outside the class for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just prefer starting with the minimal visibility necessary. The function is used to validate specific configuration that can (currently) only arise in the AwsCustomResource class. I'd like additional usages of it to be very intentional and not just treat it as a sort of utility function.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 61051b1
  • 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 Mar 4, 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: 2eaa440
  • Result: FAILED
  • 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 Mar 4, 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 94599f8 into master Mar 4, 2020
@mergify mergify bot deleted the epolon/custom-resources-rename-catchErrorPattern branch March 4, 2020 11:54
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

eladb pushed a commit that referenced this pull request Mar 9, 2020
…esMatching` (#6553)

In the spirit of being "Explicit and Clear*, renaming `catchErrorPattern` to `ignoreErrorCodesMatching` since it better describes the meaning of this property.

In addition, the following validations were added:

- `ignoreErrorCodesMatching` cannot be used with `PhysicalResourceId.fromResponse` since the response might not exist.
- `ignoreErrorCodesMatching` cannot be used with `getData` or `getDataString` since the resource might not have any attributes due to the error catching.

Relates to #5873 

BREAKING CHANGE: `catchErrorPattern` was renamed to `ignoreErrorCodesMatching`. In addition, a few synth time validations were added when using this property. See [Error Handling](https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/custom-resources#error-handling-1) for details.
horsmand pushed a commit to horsmand/aws-cdk that referenced this pull request Mar 9, 2020
…esMatching` (aws#6553)

In the spirit of being "Explicit and Clear*, renaming `catchErrorPattern` to `ignoreErrorCodesMatching` since it better describes the meaning of this property.

In addition, the following validations were added:

- `ignoreErrorCodesMatching` cannot be used with `PhysicalResourceId.fromResponse` since the response might not exist.
- `ignoreErrorCodesMatching` cannot be used with `getData` or `getDataString` since the resource might not have any attributes due to the error catching.

Relates to aws#5873 

BREAKING CHANGE: `catchErrorPattern` was renamed to `ignoreErrorCodesMatching`. In addition, a few synth time validations were added when using this property. See [Error Handling](https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/custom-resources#error-handling-1) for details.
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.

5 participants