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.85k stars 450 forks source link

Python - provider argument dict keys changed to lower-case with underscores #2681

Open jantman opened 1 year ago

jantman commented 1 year ago

Community Note

cdktf & Language Versions

cdktf-cli 0.15.5 Python 3.10.9 / cdktf 0.15.5

Affected Resource(s)

Grafana provider

Expected Behavior

Dictionary key arguments would be passed to provider configuration as specified.

Actual Behavior

Dictionary key arguments are lower-cased and have dashes converted to underscores, breaking them.

Steps to Reproduce

  1. Install cdktf latest version (0.15.5), generate bindings for grafana/grafana@~> 1.35 provider.
  2. Configure the provider with the http_headers argument, such as:
GrafanaProvider(
    self, 'grafana', org_id=1, http_headers={'X-Disable-Provenance': 'disabled'}
)
  1. The resulting synth'ed JSON has a header of x_disable_provenance instead of X-Disable-Provenance, which doesn't work with the underlying application.
  "provider": {
    "grafana": [
      {
        "http_headers": {
          "x_disable_provenance": "disabled"
        },
        "insecure_skip_verify": true,
        "org_id": 1,
        "url": "http://nuc1:3000/"
      }
    ]
  },

Important Factoids

This can currently be worked around with the add_override escape hatch.

References

It looks to me like this is related to #235 and #646 but I don't understand enough about the internals to really understand what's going on or why it works this way.

farnoy commented 2 months ago

Just hit this using Typescript

cdktf debug
language: typescript
cdktf-cli: 0.20.7
node: v22.3.0
cdktf: 0.20.8
constructs: 10.3.0
jsii: null
terraform: 1.9.2
arch: x64
os: linux 6.9.3