Open corymhall opened 2 years ago
A solution we are working on (thanks to @rix0rrr for proposing this):
{ MyProp: { PrimitiveType: Json } }
, we automatically write a patch file that adds a marker field into the property, like { MyProp: { WasOnceJson: true } }
.cfn2ts
, for every property MyProp
we encounter we look at WasOnceJson
.
MyProp.PrimitiveType = 'Json'
, we proceed as normal.
/**
myPropTyped
instead.myProp
and myPropTyped
*/
readonly myProp?: any;/**
myProp
and myPropTyped
*/
readonly myPropTyped?: MyPropType;
"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
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.
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
https://github.com/aws/aws-cdk/issues/25558
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.
internal P133761646
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 asJson
which is not ideal.Issue list
Type Change List of Properties that have changed from
Json
to a type