### Initialize Example Module with Kitchen (Shell) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md This command initializes the working directory for a specific example module using Kitchen-Terraform. It prepares the environment for applying and testing the module. ```shell kitchen_do create ``` -------------------------------- ### Apply Example Module with Kitchen (Shell) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md This command applies the Terraform configuration for a specific example module using Kitchen-Terraform. It provisions the resources defined in the module. ```shell kitchen_do converge ``` -------------------------------- ### Verify Example Module with Kitchen (Shell) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md This command runs verification tests against a specific example module using Kitchen-Terraform and InSpec. It checks if the applied module behaves as expected. ```shell kitchen_do verify ``` -------------------------------- ### Destroy Example Module with Kitchen (Shell) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md This command destroys the resources provisioned by a specific example module using Kitchen-Terraform. It cleans up the test environment. ```shell kitchen_do destroy ``` -------------------------------- ### Service Account Setup Helper Script (Bash) Source: https://context7.com/terraform-google-modules/terraform-google-address/llms.txt A bash script to automate the setup of a service account with necessary IAM roles for managing IP addresses and DNS records in Google Cloud. It creates the service account, downloads its key, grants `roles/dns.admin` and `roles/compute.networkAdmin`, and enables required APIs. The script also provides instructions on setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable and verifying resources with `gcloud`. ```bash # Usage: ./helpers/setup-sa.sh # Create service account and grant required roles ./helpers/setup-sa.sh my-gcp-project address-manager # The script performs the following: # 1. Creates a service account in the specified project # 2. Downloads service account key to credentials.json # 3. Grants roles/dns.admin for Cloud DNS management # 4. Grants roles/compute.networkAdmin for IP address management # 5. Enables required APIs (cloudresourcemanager, compute, dns) # After running, set credentials for Terraform: export GOOGLE_APPLICATION_CREDENTIALS="./credentials.json" # Verify addresses with gcloud: gcloud compute addresses list --project=my-gcp-project ``` -------------------------------- ### Start Interactive Docker Testing Container (Make) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md This make command starts the Docker container used for testing in interactive mode. This allows for manual execution of Kitchen-Terraform commands. ```makefile make docker_run ``` -------------------------------- ### Prepare Test Project with Docker (Make) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md This make command prepares an isolated test project using Docker. It automates the setup required for running integration tests, ensuring a consistent testing environment. ```makefile make docker_test_prepare ``` -------------------------------- ### Run Noninteractive Integration Tests (Make) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md This make command executes integration tests for all example modules noninteractively. It utilizes the prepared test project to verify the module's functionality. ```makefile make docker_test_integration ``` -------------------------------- ### Run Service Account Setup Script (Shell) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/README.md This script automates the process of granting required IAM roles and creating a service account for use with Google Cloud resources. It takes the host project name and desired service account name as input. Upon successful execution, it generates a 'credentials.json' file. ```shell ./helpers/setup-sa.sh ``` -------------------------------- ### Reserve External IP Address with Terraform Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/README.md This example demonstrates how to reserve a global external IP address using the Google Address Terraform Module. By setting the 'global' input variable to 'true' and omitting the 'subnetwork', you can reserve an IP address accessible from the internet. ```hcl module "address-fe" { source = "terraform-google-modules/address/google" version = "~> 3.1" names = ["external-facing-ip"] global = true } ``` -------------------------------- ### Reserve Internal IP Addresses with Terraform Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/README.md This example demonstrates how to reserve multiple internal IP addresses on a specified subnetwork using the Google Address Terraform Module. It automatically assigns the next available IP addresses from the subnetwork. The number of reserved IPs is determined by the length of the 'names' variable. ```hcl module "address-fe" { source = "terraform-google-modules/address/google" version = "~> 5.0" project_id = "gcp-network" region = "us-west1" subnetwork = "projects/gcp-network/regions/us-west1/subnetworks/dev-us-west1-dynamic" names = [ "gusw1-dev-fooapp-fe-0001-a-001-ip", "gusw1-dev-fooapp-fe-0001-a-002-ip", "gusw1-dev-fooapp-fe-0001-a-003-ip" ] } ``` -------------------------------- ### Reserve Internal IP Addresses with Cloud DNS Integration Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/README.md This example shows how to reserve internal IP addresses and automatically register them in Google Cloud DNS. It requires specifying the subnetwork, enabling Cloud DNS, and providing details for the DNS project, domain, and managed zone. Short names for DNS records can also be provided. ```hcl module "address-fe" { source = "terraform-google-modules/address/google" version = "~> 3.1" subnetwork = "projects/gcp-network/regions/us-west1/subnetworks/dev-us-west1-dynamic" enable_cloud_dns = true dns_project = "gcp-dns" dns_domain = "example.com" dns_managed_zone = "nonprod-dns-zone" names = [ "gusw1-dev-fooapp-fe-0001-a-001-ip", "gusw1-dev-fooapp-fe-0001-a-002-ip", "gusw1-dev-fooapp-fe-0001-a-003-ip" ] dns_short_names = [ "gusw1-dev-fooapp-fe-0001-a-001", "gusw1-dev-fooapp-fe-0001-a-002", "gusw1-dev-fooapp-fe-0001-a-003" ] } ``` -------------------------------- ### Configure Reverse DNS with GCP PTR Records in Terraform Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/README.md This snippet demonstrates how to enable reverse DNS registration for GCP PTR records using the Terraform Google Address module. It requires setting `enable_gcp_ptr` to true and providing the `dns_reverse_zone`. The example also shows common configurations like `subnetwork`, `enable_cloud_dns`, and `dns_domain`. ```hcl module "address-fe" { source = "terraform-google-modules/address/google" version = "~> 3.1" subnetwork = "projects/gcp-network/regions/us-west1/subnetworks/dev-us-west1-dynamic" enable_cloud_dns = true enable_gcp_ptr = true dns_project = "gcp-dns" dns_domain = "example.com" dns_managed_zone = "nonprod-dns-zone" dns_reverse_zone = "nonprod-dns-reverse-zone" names = [ "gusw1-dev-fooapp-fe-0001-a-001-ip", "gusw1-dev-fooapp-fe-0001-a-002-ip", "gusw1-dev-fooapp-fe-0001-a-003-ip" ] dns_short_names = [ "gusw1-dev-fooapp-fe-0001-a-001", "gusw1-dev-fooapp-fe-0001-a-002", "gusw1-dev-fooapp-fe-0001-a-003" ] } ``` -------------------------------- ### Reserve Specific Internal IP Addresses with Terraform Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/README.md This example shows how to reserve specific internal IP addresses on a subnetwork using the Google Address Terraform Module. You provide the exact IP addresses to be reserved via the 'addresses' variable. These IP addresses must be available and fall within the subnetwork's range. ```hcl module "address-fe" { source = "terraform-google-modules/address/google" version = "~> 3.1" subnetwork = "projects/gcp-network/regions/us-west1/subnetworks/dev-us-west1-dynamic" names = [ "gusw1-dev-fooapp-fe-0001-a-001-ip", "gusw1-dev-fooapp-fe-0001-a-002-ip", "gusw1-dev-fooapp-fe-0001-a-003-ip" ] addresses = [ "10.11.0.10", "10.11.0.11", "10.11.0.12" ] } ``` -------------------------------- ### Terraform 'count' cannot be computed error Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/docs/TROUBLESHOOTING.md This error occurs when the 'count' argument in Terraform resources is set to a computed value, often due to conditional logic based on input variables. Ensure that variables like 'dns_domain', 'dns_short_names', 'enable_cloud_dns', 'enable_reverse_dns', 'global', and 'names' are assigned literal values. ```terraform Error: Error running plan: 2 error(s) occurred: * module.example.module.address.google_dns_record_set.ip: google_dns_record_set.ip: value of 'count' cannot be computed * module.example.module.address.google_dns_record_set.ptr: google_dns_record_set.ptr: value of 'count' cannot be computed ``` -------------------------------- ### Generate Module Documentation (Make) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md This make command automatically generates the Inputs and Outputs tables for the module's README files. It should be run whenever the module's interfaces (variables or outputs) are changed. ```makefile make generate_docs ``` -------------------------------- ### Lint and Format Code (Make) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md This make command runs linting and formatting checks across various files in the repository. It helps maintain code quality and consistency. ```makefile make docker_test_lint ``` -------------------------------- ### Configure Google Address Terraform Module Source: https://context7.com/terraform-google-modules/terraform-google-address/llms.txt This snippet demonstrates how to configure the Google Address Terraform Module, including required project and region details, address names, and various optional settings for IP allocation, address type, global scope, IP version, network tier, purpose, prefix length, and DNS configuration. It also shows how to set resource metadata like labels and descriptions. ```hcl module "address-complete" { source = "terraform-google-modules/address/google" version = "~> 5.0" # Required variables project_id = "my-gcp-project" # GCP project ID region = "us-west1" # Region for regional addresses names = ["my-address"] # List of address resource names (RFC1035 compliant) # Optional: IP allocation addresses = [""] # Specific IPs or "" for auto-allocation subnetwork = "" # Subnet self-link for INTERNAL addresses address_type = "INTERNAL" # INTERNAL or EXTERNAL global = false # true for global scope ip_version = "IPV4" # IPV4 or IPV6 network_tier = "PREMIUM" # PREMIUM or STANDARD # Optional: Address purpose purpose = "GCE_ENDPOINT" # GCE_ENDPOINT, SHARED_LOADBALANCER_VIP, VPC_PEERING prefix_length = 16 # For VPC_PEERING ranges # Optional: DNS configuration enable_cloud_dns = false # Enable forward DNS registration enable_reverse_dns = false # Enable reverse DNS (PTR) registration dns_project = "" # Project hosting Cloud DNS zone dns_domain = "" # Domain for DNS records dns_managed_zone = "" # Cloud DNS managed zone name dns_reverse_zone = "" # Reverse DNS zone for PTR records dns_short_names = [] # Hostnames (aligned with names list) dns_ttl = 300 # DNS record TTL in seconds dns_record_type = "A" # DNS record type # Optional: Resource metadata labels = {} # Key-value labels for organization descriptions = [] # Descriptions for each address } # Module outputs: # addresses - List of reserved IP addresses # names - List of address resource names # self_links - List of address resource URIs # dns_fqdns - List of registered FQDNs # reverse_dns_fqdns - List of PTR record FQDNs ``` -------------------------------- ### Export Service Account Credentials (Shell) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md This command exports the service account credentials from a JSON file into an environment variable. This is a prerequisite for setting up the test environment for integration testing. ```shell export SERVICE_ACCOUNT_JSON=$(< credentials.json) ``` -------------------------------- ### Reserve IP Addresses with Labels and Descriptions (HCL) Source: https://context7.com/terraform-google-modules/terraform-google-address/llms.txt Reserves IP addresses and applies custom labels and descriptions for better resource management and cost allocation. This configuration is useful for organizing resources by environment, team, or cost center. The module takes an array of names, labels, and descriptions as input. ```hcl module "labeled-address" { source = "terraform-google-modules/address/google" version = "~> 5.0" project_id = "my-gcp-project" region = "us-central1" subnetwork = "projects/my-gcp-project/regions/us-central1/subnetworks/prod-subnet" names = [ "prod-api-gateway-ip", "prod-web-frontend-ip" ] labels = { environment = "production" team = "platform" cost-center = "engineering" } descriptions = [ "Production API Gateway static IP address", "Production Web Frontend static IP address" ] } ``` -------------------------------- ### Set Test Environment Variables (Shell) Source: https://github.com/terraform-google-modules/terraform-google-address/blob/main/CONTRIBUTING.md These commands set essential environment variables required for Terraform to configure the test project. They include organization ID, folder ID, and billing account ID. ```shell export TF_VAR_org_id="your_org_id" export TF_VAR_folder_id="your_folder_id" export TF_VAR_billing_account="your_billing_account_id" ``` -------------------------------- ### Reserve IP Addresses with Forward DNS Registration (HCL) Source: https://context7.com/terraform-google-modules/terraform-google-address/llms.txt Reserves IP addresses and automatically registers A records in Google Cloud DNS. Requires project ID, region, subnetwork, names, and DNS configuration details like project, domain, managed zone, and TTL. ```hcl module "address-with-dns" { source = "terraform-google-modules/address/google" version = "~> 5.0" project_id = "my-gcp-project" region = "us-west1" subnetwork = "projects/my-gcp-project/regions/us-west1/subnetworks/app-subnet" enable_cloud_dns = true dns_project = "my-dns-project" dns_domain = "internal.example.com" dns_managed_zone = "internal-dns-zone" dns_ttl = 300 names = [ "web-server-001-ip", "web-server-002-ip", "web-server-003-ip" ] dns_short_names = [ "web-001", "web-002", "web-003" ] } # Outputs: # addresses = ["10.11.2.20", "10.11.2.21", "10.11.2.22"] # dns_fqdns = ["web-001.internal.example.com", "web-002.internal.example.com", "web-003.internal.example.com"] ``` -------------------------------- ### Reserve IP Addresses with Forward and Reverse DNS Registration (HCL) Source: https://context7.com/terraform-google-modules/terraform-google-address/llms.txt Reserves IP addresses and configures both forward (A record) and reverse (PTR record) DNS entries using the Google Address Terraform module. Requires Cloud DNS to be enabled and configured with specified projects, domains, and zones. Outputs include reserved IP addresses and their corresponding FQDNs. ```hcl module "address-full-dns" { source = "terraform-google-modules/address/google" version = "~> 5.0" project_id = "my-gcp-project" region = "us-west1" subnetwork = "projects/my-gcp-project/regions/us-west1/subnetworks/secure-subnet" enable_cloud_dns = true enable_reverse_dns = true dns_project = "my-dns-project" dns_domain = "secure.example.com" dns_managed_zone = "secure-dns-zone" dns_reverse_zone = "reverse-dns-zone" dns_ttl = 300 dns_record_type = "A" names = [ "secure-server-001-ip", "secure-server-002-ip" ] dns_short_names = [ "secure-001", "secure-002" ] } # Outputs: # addresses = ["10.11.5.100", "10.11.5.101"] # dns_fqdns = ["secure-001.secure.example.com", "secure-002.secure.example.com"] # reverse_dns_fqdns = ["100.5.11.10.in-addr.arpa", "101.5.11.10.in-addr.arpa"] ``` -------------------------------- ### Reserve Internal IP Addresses with Dynamic Allocation (HCL) Source: https://context7.com/terraform-google-modules/terraform-google-address/llms.txt Reserves internal IP addresses on a specified subnetwork, allowing GCP to dynamically assign available IPs. Requires project ID, region, subnetwork, and a list of names for the addresses. ```hcl module "address-fe" { source = "terraform-google-modules/address/google" version = "~> 5.0" project_id = "my-gcp-project" region = "us-west1" subnetwork = "projects/my-gcp-project/regions/us-west1/subnetworks/dev-subnet" names = [ "app-frontend-001-ip", "app-frontend-002-ip", "app-frontend-003-ip" ] } # Outputs: # addresses = ["10.11.2.5", "10.11.2.6", "10.11.2.7"] # names = ["app-frontend-001-ip", "app-frontend-002-ip", "app-frontend-003-ip"] # self_links = ["https://www.googleapis.com/compute/v1/projects/my-gcp-project/regions/us-west1/addresses/app-frontend-001-ip", ...] ``` -------------------------------- ### Reserve IP Addresses for VPC Peering (HCL) Source: https://context7.com/terraform-google-modules/terraform-google-address/llms.txt Reserves an internal IP address range for use with private services access and VPC peering connections. This configuration requires specifying the VPC network and a prefix length for the IP range. The `global` flag should be set to `true` for global resources like VPC peering. ```hcl module "peering-address" { source = "terraform-google-modules/address/google" version = "~> 5.0" project_id = "my-gcp-project" region = "us-central1" global = true address_type = "INTERNAL" purpose = "VPC_PEERING" prefix_length = 16 subnetwork = "projects/my-gcp-project/global/networks/my-vpc" names = ["private-services-range"] } ``` -------------------------------- ### Reserve Global External IP Addresses (HCL) Source: https://context7.com/terraform-google-modules/terraform-google-address/llms.txt Reserves globally scoped external IP addresses for global load balancers and CDN. Supports both IPv4 and IPv6. Requires project ID, region, and names. Set `global = true`. ```hcl module "global-address" { source = "terraform-google-modules/address/google" version = "~> 5.0" project_id = "my-gcp-project" region = "us-central1" global = true address_type = "EXTERNAL" ip_version = "IPV4" names = ["global-lb-address"] } # For IPv6 global addresses: module "global-ipv6-address" { source = "terraform-google-modules/address/google" version = "~> 5.0" project_id = "my-gcp-project" region = "us-central1" global = true address_type = "EXTERNAL" ip_version = "IPV6" names = ["global-ipv6-address"] } # Outputs: # addresses = ["203.0.113.50"] # or IPv6 format for second module ``` -------------------------------- ### Reserve Regional External IP Addresses (HCL) Source: https://context7.com/terraform-google-modules/terraform-google-address/llms.txt Reserves regional external IP addresses, suitable for resources like load balancers or NAT gateways. Requires project ID, region, and a list of names. Defaults to IPV4. ```hcl module "external-address" { source = "terraform-google-modules/address/google" version = "~> 5.0" project_id = "my-gcp-project" region = "europe-west1" address_type = "EXTERNAL" names = [ "regional-external-ip-1", "regional-external-ip-2", "regional-external-ip-3" ] } # Outputs: # addresses = ["34.76.123.45", "34.76.123.46", "34.76.123.47"] # names = ["regional-external-ip-1", "regional-external-ip-2", "regional-external-ip-3"] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.