aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.55k stars 3.87k forks source link

(cfnspec): should be able to handle types changing from `Json` to type #21767

Open corymhall opened 2 years ago

corymhall commented 2 years ago

Overview

Sometimes a property type in the cfnspec is set to Json which means that it accepts any JSON value. If a service team ever adds actual types for this property it is not a breaking change on their side, but it does lead to breaking changes for us. Our current workaround is to add a patch which keeps the value as Json which is not ideal.

Issue list

Type Change List of Properties that have changed from Json to a type

madeline-k commented 1 year ago

A solution we are working on (thanks to @rix0rrr for proposing this):

/**

"At most" vs "exactly" depends on whether the original property was optional or required.

Once we have this in place, we can add the WasOnceJson field as necessary, and get rid of this patch: https://github.com/aws/aws-cdk/commit/4fbc1827b8978262da0b5b77b1ee9bc0ecfdcc3e#diff-08b4822e59cb5286d16984c086cf2fe15085a336fa7a37157d923b1f408f5647

Wurstnase commented 1 year ago

Looks like, that the new type will generate an additional dataclass. Before the patch it is PascalCase. After this patch it becomes camelCase. Would it a big problem to make the properties PascalCase again so it would be possible to use the generated dataclasses?

In that case we could benefit with typing and autocompletion.

peterwoodworth commented 1 year ago

We've received a number of reports since we patched the breaking changes found in spec 101, including

https://github.com/aws/aws-cdk/issues/23570 https://github.com/aws/aws-cdk/issues/23679 https://github.com/aws/aws-cdk/issues/23709

24754

https://github.com/aws/aws-cdk/issues/25558

25774

25990

Nabeelperson commented 5 months ago

This issue also effects: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-backup-backupselection-conditionparameter.html

I use Java CDK:

            CfnBackupSelection.Builder.create(this, id + "TagSelector")
                .backupPlanId(backupPlan.getAttrBackupPlanId())
                .backupSelection(
                    BackupSelectionResourceTypeProperty.builder()
                        .selectionName("Selector")
                        .iamRoleArn(role.getRoleArn())
                        .resources(List.of("*"))
                        .conditions(
                            Map.of(
                                "StringEquals",
                                List.of(
                                    ConditionParameterProperty.builder()
                                        .conditionKey("aws:ResourceTag/TagKey")
                                        .conditionValue("TagValue")
                                        .build()
                                )
                            )
                        )
                        .build()
                )
                .build();

Results in camelCase yaml output.

pahud commented 3 months ago

internal P133761646