diff --git a/packages/@aws-cdk/service-spec-importers/src/importers/import-cloudformation-registry.ts b/packages/@aws-cdk/service-spec-importers/src/importers/import-cloudformation-registry.ts index c141ffc7c..a59718890 100644 --- a/packages/@aws-cdk/service-spec-importers/src/importers/import-cloudformation-registry.ts +++ b/packages/@aws-cdk/service-spec-importers/src/importers/import-cloudformation-registry.ts @@ -44,7 +44,9 @@ export function importCloudFormationRegistryResource(options: LoadCloudFormation // AWS::CloudFront::ContinuousDeploymentPolicy recently introduced a change where they're marking deprecatedProperties // as `/definitions//properties/` instead of `/properties///`. Ignore those, as it's // out-of-spec - const deprecatedProperties = (resource.deprecatedProperties ?? []).filter((p) => p.startsWith('/properties/')); + const deprecatedProperties = (resource.deprecatedProperties ?? []) + .filter((p) => p.startsWith('/properties/')) + .map(simplePropNameFromJsonPtr); resourceBuilder.markDeprecatedProperties(...deprecatedProperties); // Mark everything 'readOnlyProperties` as attributes. However, in the old spec it is possible diff --git a/packages/@aws-cdk/service-spec-importers/test/cloudformation-registry.test.ts b/packages/@aws-cdk/service-spec-importers/test/cloudformation-registry.test.ts index ea09d1129..6b8b81778 100644 --- a/packages/@aws-cdk/service-spec-importers/test/cloudformation-registry.test.ts +++ b/packages/@aws-cdk/service-spec-importers/test/cloudformation-registry.test.ts @@ -35,3 +35,51 @@ test('include primaryIdentifier in database', () => { const primaryIdentifier = db.lookup('resource', 'cloudFormationType', 'equals', 'AWS::Some::Type')[0]?.primaryIdentifier; expect(primaryIdentifier).toEqual(['id', 'secondId']); }); + +test('deprecated properties', () => { + importCloudFormationRegistryResource({ + db, + report, + resource: { + typeName: 'AWS::Some::Type', + description: 'resource with PrimaryIdentifier', + properties: { + id: { + type: 'string', + }, + }, + deprecatedProperties: ['/properties/id'], + }, + }); + + // eslint-disable-next-line prettier/prettier + const resource = db.lookup('resource', 'cloudFormationType', 'equals', 'AWS::Some::Type').only(); + expect(resource.properties.id.deprecated).toBeDefined(); +}); + +test('type definitions in deprecated properties do not fail', () => { + importCloudFormationRegistryResource({ + db, + report, + resource: { + typeName: 'AWS::Some::Type', + description: 'resource with PrimaryIdentifier', + properties: { + id: { $ref: '#/definitions/Type' }, + }, + definitions: { + Type: { + type: 'object', + properties: { + id: { + type: 'string', + }, + }, + }, + }, + deprecatedProperties: ['/definitions/Type/properties/id'], + }, + }); + + // THEN: no failure +});