diff --git a/packages/@cdktf/commons/src/provider-schema.ts b/packages/@cdktf/commons/src/provider-schema.ts index 449928d059..1a7b9cf448 100644 --- a/packages/@cdktf/commons/src/provider-schema.ts +++ b/packages/@cdktf/commons/src/provider-schema.ts @@ -57,6 +57,7 @@ interface BaseAttribute { optional?: boolean; computed?: boolean; sensitive?: boolean; + deprecated?: boolean; } interface NestedTypeAttribute extends BaseAttribute { diff --git a/packages/@cdktf/provider-generator/lib/get/generator/resource-parser.ts b/packages/@cdktf/provider-generator/lib/get/generator/resource-parser.ts index 62c856e4c4..15a158eeda 100644 --- a/packages/@cdktf/provider-generator/lib/get/generator/resource-parser.ts +++ b/packages/@cdktf/provider-generator/lib/get/generator/resource-parser.ts @@ -139,7 +139,7 @@ class Parser { const fileName = getFileName(provider, baseName); const filePath = `providers/${toSnakeCase(provider)}/${fileName}`; - const attributes = this.renderAttributesForBlock( + let attributes = this.renderAttributesForBlock( new Scope({ name: baseName, isProvider, @@ -211,6 +211,17 @@ class Parser { } ); + // Remove deprecated attributes that may conflict after being snake cased + // Example: oci_core_ipsec_connection_tunnel_management (hashicorp/oci@=5.21.0) has bgp_ipv6_state and bgp_ipv6state + // (which both result in "bgpIpv6State" when camel-cased, with the second one being deprecated: true) + // As we currently don't handle any deprecated ones at all, we'll just delete one of the two attributes for now + attributes = attributes.filter((attr, idx) => { + const hasOtherWithSameName = attributes + .slice(idx + 1) // only search after the index of the current attribute to avoid deleting both + .some((other) => other.name === attr.name && other !== attr); + return !hasOtherWithSameName; + }); + const resourceModel = new ResourceModel({ terraformType: type, baseName,