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 455 forks source link

CDKTF: Cannot Get "dev_overrides" Provider Properly #3754

Open jackchuka opened 3 weeks ago

jackchuka commented 3 weeks ago

Expected Behavior

Successfully creates binding for dev_overrides providers.

Actual Behavior

failed to add custom/provider via cdktf provider add custom/provider. (*I'm masking provider name with custom/provider, the one I'm building is not public yet) I've also tried followings, but no matter what I do it tries to lookup public registry.


❯ cdktf provider add custom/provider
(node:17756) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[2024-10-26T16:03:47.122] [INFO] default - Checking whether pre-built provider exists for the following constraints:
  provider: custom/provider
  version : latest
  language: go
  cdktf   : 0.20.8

[2024-10-26T16:03:47.250] [INFO] default - Pre-built provider does not exist for the given constraints.
[2024-10-26T16:03:47.250] [INFO] default - Adding local provider registry.terraform.io/custom/provider with version constraint undefined to cdktf.json
Usage Error: Could not find a version for the provider 'registry.terraform.io/custom/provider' in the public registry. This could be due to a typo, please take a look at https://cdk.tf/registry-providers to find all supported providers.

my terraformrc

❯ bat ~/.terraformrc
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /Users/jackchuka/.terraformrc
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ provider_installation {
   2   │ 
   3   │   dev_overrides {
   4   │       "registry.terraform.io/custom/provider"= "/Users/jackchuka/.local/share/mise/installs/go/1.23.2/bin"
   5   │   }
   6   │ 
   7   │   # For all other providers, install them directly from their origin provider
   8   │   # registries as normal. If you omit this, Terraform will _only_ use
   9   │   # the dev_overrides block, and so no other providers will be available.
  10   │   direct {}
  11   │ }
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Steps to Reproduce

  1. create a custom provider

  2. register via dev_overrides

  3. confirm it's able to terraform plan/apply, etc...

  4. create cdktest stack

❯ cd cmd/terraform-provider-platform             

❯ mkdir cdktest

❯ cd cdktest

❯ cdktf init --template="go" --local
(node:17582) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Note: By supplying '--local' option you have chosen local storage mode for storing the state of your stack.
This means that your Terraform state file will be stored locally on disk in a file 'terraform.<STACK NAME>.tfstate' in the root of your project.
? Project Name cdktest
? Project Description A simple getting started project for cdktf.
? Do you want to send crash reports to the CDKTF team? Refer to 
https://developer.hashicorp.com/terraform/cdktf/create-and-deploy/configuration-file#enable-crash-reporting-for-the-cli for more 
information no
  1. add my custom provider
    ❯ cdktf provider add custom/provider

Versions

❯ node -v
v20.6.1

❯ terraform version
Terraform v1.9.8
on darwin_arm64

❯ cdktf --version
0.20.8

Providers

No response

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

No response

Help Wanted

Community Note