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

Google provider: No module named google.google_compute_region_security_policy #3752

Open cyber-francis opened 3 weeks ago

cyber-francis commented 3 weeks ago

Expected Behavior

{
"cdktf": "0.20.8",
"providers": {
   "google": "~>6.8.0",
   "google-beta": "~>6.8.0",
  }
}

cdktf get runs perfectly. But, then within my python code, I can't import this lib: from imports.google.google_compute_region_security_policy import GoogleComputeRegionSecurityPolicy

google_compute_region_security_policy exists in the vanilla terraform, but not in cdktf.

Actual Behavior

No module named imports.google.google_compute_region_security_policy

Steps to Reproduce

  1. create a cdktf.json file with below parameters:
{
"cdktf": "0.20.8",
"providers": {
   "google": "~>6.8.0",
   "google-beta": "~>6.8.0",
  }
}
  1. cdktf get
  2. from imports.google.google_compute_region_security_policy import GoogleComputeRegionSecurityPolicy

Versions

google@~>6.8.0 google-beta@~>6.8.0 cdktf-cdktf-provider-google: terraform provider version: 5.36.0, prebuilt provider version: 13.25.0

Providers

No response

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

No response

Help Wanted

Community Note

DanielMSchmidt commented 1 week ago

It seems like you have the google provider in your cdktf.json as well as the pre-built provider in your project. This is normally not what you want to do, you should either remove the local one or the pre-built one.

Other than that I do believe for resources the imports omit the provider name, so the import would be from imports.google.compute_region_security_policy import ComputeRegionSecurityPolicy

cyber-francis commented 1 week ago

I removed it, but this module doesn't exits. The compute region security policy. Please, can you confirm if you tried it and it worked for you?