I am trying to resolve my issue with the Terraform code to create Load Balancer based on the official documentation for the Application Load Balancer with MIG/url map/forwarding and backend services: https://cloud.google.com/load-balancing/docs/https/ext-http-lb-tf-module-examples#with_mig_backend_and_custom_headers
I do not know what he is talking to me about because my IP address is in the range which is 10.0.0.0/24.
This is my configuration:
# VPC network
resource "google_compute_network" "great-ilb_network" {
name = "great-l7-ilb-network"
auto_create_subnetworks = false
project = var.project_id
}
# proxy-only subnet
resource "google_compute_subnetwork" "great-proxy_subnet" {
name = "great-l7-ilb-proxy-subnet"
ip_cidr_range = "10.0.0.0/24"
network = google_compute_network.great-ilb_network.self_link
}
# backend subnet
resource "google_compute_subnetwork" "great-ilb_subnet" {
name = "great-l7-ilb-subnet"
ip_cidr_range = "10.0.1.0/24"
region = var.region
network = google_compute_network.great-ilb_network.self_link
}
# MIG
resource "google_compute_instance_group_manager" "great-instance_group_manager" {
name = "my-great-instance-group-manager"
base_instance_name = "my-instance"
target_size = 4
version {
instance_template = google_compute_instance_template.great-instance_template.self_link
}
}
# instance template
resource "google_compute_instance_template" "great-instance_template" {
name = "my-great-instance-template"
machine_type = var.vm_config.vm_type
disk {
source_image = "debian-cloud/debian-10"
auto_delete = true
}
network_interface {
network = "default"
access_config {}
}
metadata_startup_script = var.vm_config.vm_startup_script
}
# Backend Service
resource "google_compute_backend_service" "fancy-fe-frontend" {
name = "fancy-fe-frontend"
project = var.project_id
port_name = "frontend"
health_checks = [google_compute_health_check.http-health-check.self_link]
backend {
group = google_compute_instance_group_manager.great-instance_group_manager.instance_group
}
protocol = "HTTP"
timeout_sec = 10
load_balancing_scheme = "EXTERNAL"
}
# HTTP Health Check
resource "google_compute_health_check" "http-health-check" {
name = "great-fancy-fe-frontend-hc"
project = var.project_id
timeout_sec = 1
check_interval_sec = 1
http_health_check {
port = 80
}
}
# forwarding rule
resource "google_compute_global_forwarding_rule" "default" {
name = "l7-xlb-forwarding-rule"
project = var.project_id
provider = google-beta
ip_protocol = "TCP"
load_balancing_scheme = "EXTERNAL"
port_range = "80"
target = google_compute_target_http_proxy.default.id
ip_address = google_compute_global_address.l7-xlb-static-ip.address
}
# http proxy
resource "google_compute_target_http_proxy" "default" {
name = "l7-xlb-target-http-proxy"
project = var.project_id
provider = google-beta
url_map = google_compute_url_map.default.id
}
# url map
resource "google_compute_url_map" "default" {
name = "l7-xlb-url-map"
project = var.project_id
provider = google-beta
default_service = google_compute_backend_service.fancy-fe-frontend.id
}
# reserved IP address
resource "google_compute_global_address" "l7-xlb-static-ip" {
provider = google-beta
project = var.project_id
name = "l7-xlb-static-ip"
address = "10.0.0.10"
}
And this the error which I see typing: terraform apply --auto-approve
module.load_balancer.google_compute_global_address.l7-xlb-static-ip: Creating... ╷ │
Error: Error creating GlobalAddress: googleapi:
Error 400: Invalid value for field 'resource.address': '10.0.0.10'. Specified IP address is not allocated to the project or does not belong to the specified scope.,
invalid │ │ with module.load_balancer.google_compute_global_address.l7-xlb-static-ip,
│ on modules\lb\lb.tf line 108, in resource "google_compute_global_address" "l7-xlb-static-ip":
│ 108: resource "google_compute_global_address" "l7-xlb-static-ip" {
Would someone support me with that and point my failure in th eabove snippet of Terraform code?