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(cfn-custom-resource): Add optional 'reason' field for detailed failure reporting #1758

Merged
merged 9 commits into from
Mar 21, 2025

Conversation

moizsh
Copy link
Contributor

@moizsh moizsh commented Jan 8, 2025

Issue #, if available:
#1801

Description of changes:

This PR adds an optional 'reason' field to the CloudFormation Custom Resource response model. This enhancement allows users to provide detailed failure reasons for Custom Resource creation/update operations, particularly useful in scenarios where the Lambda function is hosted in a separate account and logs are not directly accessible. The 'reason' field enables better error reporting and debugging for consumers of the Custom Resource.

Checklist

Breaking change checklist

RFC issue #: N/A

  • Migration process documented
  • Implement warnings (if it can live side by side)

Changes made:

  • Added an optional 'reason' field to the Response class for CloudFormation Custom Resources
  • Updated CloudFormationResponse to include the 'reason' in the response JSON when provided
  • Modified the Response builder to allow setting a custom reason
  • Ensured backward compatibility by making the 'reason' field optional
  • Added new test cases to verify the behavior of the new 'reason' field
  • Updated existing tests to include checks for the 'reason' field
  • Added appropriate JavaDoc comments for the new 'reason' field and its usage

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…ailure reporting in CloudFormation custom resource responses
Copy link

sonarqubecloud bot commented Jan 8, 2025

@phipag phipag self-assigned this Jan 8, 2025
@phipag phipag self-requested a review March 13, 2025 11:52
@phipag phipag added the feature-request New feature or request label Mar 13, 2025
@phipag phipag linked an issue Mar 13, 2025 that may be closed by this pull request
@phipag
Copy link
Contributor

phipag commented Mar 13, 2025

I created issue #1801 related to this PR.

@phipag
Copy link
Contributor

phipag commented Mar 21, 2025

Thanks @moizsh for your contribution. This change looks good to me and the PR is ready to be merged.

@phipag phipag self-requested a review March 21, 2025 12:01
@phipag
Copy link
Contributor

phipag commented Mar 21, 2025

Actually the Java 8 build fails. I'll look into this.

The build fails with

> Task :test FAILED
helloworld.AppTest > successfulResponse FAILED
    java.lang.NoSuchFieldError at AppTest.kt:11

But it succeeds locally using Java 8 and the same gradle version.

@phipag
Copy link
Contributor

phipag commented Mar 21, 2025

Testing if bumping the Kotlin example version to the current one (1.19.0) resolves the issue.

Anyway, this issue is not related to this PR and can be investigated separately.

@phipag
Copy link
Contributor

phipag commented Mar 21, 2025

This resolved the issue, we have an open issue to improve the existing workflows (#1231).

@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 21, 2025
@pull-request-size pull-request-size bot added size/M and removed size/L labels Mar 21, 2025
@phipag phipag merged commit 7434bf9 into aws-powertools:main Mar 21, 2025
12 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to send 'Reason' field when using CloudFormation Custom resource
2 participants