I am having problems trying to get this submodule to work in my terraform scripts:
Using Terraform:
Terraform v1.1.4
on darwin_amd64
- provider registry.terraform.io/hashicorp/google v4.7.0
When I add my module to my main.tf:
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 4.7.0"
}
}
}
...
module "lb" {
source = "./modules/lb"
project_id = var.project_id
}
I created a module under my modules directory and it has modules/lb/main.tf:
data "google_project" "project" {
project_id = var.project_id
}
module "lb-http" {
source = "GoogleCloudPlatform/lb-http/google//modules/serverless_negs"
version = "~> 4.4"
project = var.project-id
name = var.lb_name
ssl = true
managed_ssl_certificate_domains = [var.my_subdomain]
https_redirect = true
backends = {
default = {
description = null
enable_cdn = false
custom_request_headers = null
custom_response_headers = null
security_policy = null
log_config = {
enable = true
sample_rate = 1.0
}
groups = [
{
# Your serverless service should have a NEG created that's referenced here.
group = google_compute_region_network_endpoint_group.default.id
}
]
iap_config = {
enable = false
oauth2_client_id = null
oauth2_client_secret = null
}
}
}
}
I get this error when I run terraform init:
Initializing modules...
Initializing the backend...
Initializing provider plugins...
- Reusing previous version of hashicorp/google from the dependency lock file
- Finding hashicorp/google-beta versions matching ">= 3.32.0, < 4.0.0"...
- Installing hashicorp/google-beta v3.90.1...
- Installed hashicorp/google-beta v3.90.1 (signed by HashiCorp)
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/google: locked provider
│ registry.terraform.io/hashicorp/google 4.7.0 does not match configured version constraint >= 3.32.0, < 4.0.0, ~> 4.7.0; must use
│ terraform init -upgrade to allow selection of new versions
I’m fairly certain I just have a very poor understanding of terraform versions and compatibility between sub modules. I just cannot pinpoint the issue.