hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.88k stars 456 forks source link

cloudflare: `cdktf convert` explodes when the cloudflare/cloudflare provider is present #3634

Open infowolfe opened 6 months ago

infowolfe commented 6 months ago

Expected Behavior

I should be able to copy an example stanza from the provider docs and have the relevant python code generated.

Actual Behavior

Adding package @cdktf/provider-cloudflare @ 11.11.0
Internal Error: unexpected array
Error: unexpected array
    at Parser.renderAttributeType (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:205:23)
    at Parser.renderAttributesForBlock (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:264:31)
    at Parser.resourceFrom (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:124:31)
    at ResourceParser.parse (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:466:33)
    at /usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/provider-generator.js:94:121
    at Array.map (<anonymous>)
    at TerraformProviderGenerator.buildResourceModels (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/provider-generator.js:94:75)
    at /usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/hcl2cdk/lib/index.js:93:31
    at Array.reduce (<anonymous>)
    at convertToTypescript (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/hcl2cdk/lib/index.js:91:79)
Collecting Debug Information...
/usr/local/lib/node_modules/cdktf-cli/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
        throw ex;
        ^

Error: unexpected array
    at Parser.renderAttributeType (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:205:23)
    at Parser.renderAttributesForBlock (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:264:31)
    at Parser.resourceFrom (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:124:31)
    at ResourceParser.parse (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/resource-parser.js:466:33)
    at /usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/provider-generator.js:94:121
    at Array.map (<anonymous>)
    at TerraformProviderGenerator.buildResourceModels (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/provider-generator/lib/get/generator/provider-generator.js:94:75)
    at /usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/hcl2cdk/lib/index.js:93:31
    at Array.reduce (<anonymous>)
    at convertToTypescript (/usr/local/lib/node_modules/cdktf-cli/node_modules/@cdktf/hcl2cdk/lib/index.js:91:79) {
  language: 'python',
  __type: 'Internal'
}

Node.js v20.13.1

Steps to Reproduce

  1. add cloudflare/cloudflare to your providers in a cdktf project
  2. copy a stanza from here: https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/record
  3. pbpaste | grep -v "^#" | cdktf convert --language python --provider cloudflare/cloudflare

Versions

language: python cdktf-cli: 0.20.7 node: v20.13.1 cdktf: 0.20.7 constructs: 10.3.0 jsii: 1.98.0 terraform: 1.8.4 arch: x64 os: darwin 21.6.0 python: Python 3.12.3 pip: null pipenv: pipenv, version 2023.12.1 providers aws@undefined (LOCAL) terraform provider version: 5.49.0 cloudflare/cloudflare@undefined (LOCAL) terraform provider version: 4.33.0 cdktf-cdktf-provider-aws (PREBUILT) terraform provider version: 5.43.0 prebuilt provider version: 19.12.0 cdktf version: ^0.20.0 cdktf-cdktf-provider-cloudflare (PREBUILT) terraform provider version: 4.33.0 prebuilt provider version: 11.11.0 cdktf version: ^0.20.0

Providers

────────────────────────────┬──────┬────────┬──────────────────────────────────┐ ────── ───── ── ─── ────────── ──── Provider Name Provider │ CDKTF│ Constra│ Package Name Package │ Version nt Version ────────────────────────────┼──────┼────────┼──────────────────────────────────┤ ────── ───── ── ─── ────────── ──── aws 5.49.0 │ │ │ │

────────────────────────────┼──────┼────────┼──────────────────────────────────┤ ────── ───── ── ─── ────────── ──── cloudflare/clou 4.33.0 │ │ │ │ flare ────────────────────────────┼──────┼────────┼──────────────────────────────────┤ ────── ───── ── ─── ────────── ──── aws 5.43.0 │ │ │ cdktf-cdktf-provider- 19.12.0 │ ^0.20.0 ws

────────────────────────────┼──────┼────────┼──────────────────────────────────┤ ────── ───── ── ─── ────────── ──── cloudflare/clou 4.33.0 │ │ │ cdktf-cdktf-provider- 11.11.0 │ flare ^0.20.0 loudflare

────────────────────────────┴──────┴────────┴──────────────────────────────────┘ ────── ───── ── ─── ────────── ────

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

Help Wanted

Community Note