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

backup: Properties validation failed for resource when using CfnReportPlan.ReportSettingProperty and CfnReportPlan.ReportDeliveryChannelProperty #25558

Closed
TSE-WDG opened this issue May 12, 2023 · 3 comments
Labels
@aws-cdk/aws-backup Related AWS Backup @aws-cdk/aws-cloudformation Related to AWS CloudFormation @aws-cdk/cfnspec bug This issue is a bug. effort/medium Medium work item – several days of effort needs-review p1

Comments

@TSE-WDG
Copy link

TSE-WDG commented May 12, 2023

Describe the bug

I want to use CfnReportPlan construct (in java) but if i use CfnReportPlan.ReportSettingProperty and CfnReportPlan.ReportDeliveryChannelProperty i have an error in Cloudformation at deploy step.

Expected Behavior

working cloudformation stack

Current Behavior

(in cloudformation stack events)
CREATE_FAILED

Properties validation failed for resource XXXXXXX with message:
#/ReportSetting: required key [ReportTemplate] not found
#/ReportSetting: extraneous key [reportTemplate] is not permitted
#/ReportSetting: extraneous key [regions] is not permitted
#/ReportSetting: extraneous key [accounts] is not permitted
#/ReportDeliveryChannel: required key [S3BucketName] not found
#/ReportDeliveryChannel: extraneous key [s3BucketName] is not permitted

Reproduction Steps

ReportSettingProperty reportSettingProperty = ReportSettingProperty.builder()
	         .reportTemplate("BACKUP_JOB_REPORT")
	         .accounts(List.of(accountId))
	         .regions(List.of("eu-central-1"))
	         .build();
	
	ReportDeliveryChannelProperty deliveryChannel = ReportDeliveryChannelProperty.builder()
		.s3BucketName(REPORT_BUCKET) // The bucket already exist
		.build();
	
	CfnReportPlanProps props = CfnReportPlanProps.builder()
		.reportPlanName("backup_jobs")
		.reportSetting(reportSettingProperty)
		.reportDeliveryChannel(deliveryChannel)
		.build();

	return new CfnReportPlan(this, "backup-report", props);

Possible Solution

As workaround you can use Map instead of ReportSettingProperty & ReportDeliveryChannelProperty.

    CfnReportPlanProps props = CfnReportPlanProps.builder()
        .reportPlanName("backup_jobs")
        .reportSetting(Map.of(
            "ReportTemplate", "BACKUP_JOB_REPORT",
            "Accounts", List.of(accountId),
            "Regions", List.of("eu-central-1")
        ))
        .reportDeliveryChannel(Map.of(
            "S3BucketName", REPORT_BUCKET
        ))
        .build();

    return new CfnReportPlan(this, "backup-report", props);

Additional Information/Context

No response

CDK CLI Version

2.61.1

Framework Version

No response

Node.js Version

18

OS

Linux

Language

Java

Language Version

17

Other information

No response

@TSE-WDG TSE-WDG added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 12, 2023
@github-actions github-actions bot added the @aws-cdk/aws-cloudformation Related to AWS CloudFormation label May 12, 2023
@pahud pahud self-assigned this May 12, 2023
@pahud pahud changed the title CfnReportPlan: Properties validation failed for resource when using CfnReportPlan.ReportSettingProperty and CfnReportPlan.ReportDeliveryChannelProperty backup: Properties validation failed for resource when using CfnReportPlan.ReportSettingProperty and CfnReportPlan.ReportDeliveryChannelProperty May 12, 2023
@github-actions github-actions bot added the @aws-cdk/aws-backup Related AWS Backup label May 12, 2023
@pahud pahud added investigating This issue is being investigated and/or work is in progress to resolve the issue. @aws-cdk/cfnspec p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels May 12, 2023
@pahud
Copy link
Contributor

pahud commented May 12, 2023

Thank you for your feedback.

I will discuss with the team internally as this is a previous bug from cfn-spec. At this moment, as it's not strong typed, we need to define the properties in this way. We'll see if there's something we can do to improve the experience.

@pahud pahud added needs-review and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels May 12, 2023
@pahud pahud removed their assignment May 12, 2023
@peterwoodworth
Copy link
Contributor

This is a consequence of this #21767, we're tracking this and will come up with a way to make sure this doesn't happen again. For now though, going forward you'll need to explicitly define the JSON exactly as it will appear in the template

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-backup Related AWS Backup @aws-cdk/aws-cloudformation Related to AWS CloudFormation @aws-cdk/cfnspec bug This issue is a bug. effort/medium Medium work item – several days of effort needs-review p1
Projects
None yet
Development

No branches or pull requests

3 participants