diff --git a/infrastructure/gcp/acr/README.md b/infrastructure/gcp/acr/README.md deleted file mode 100644 index 678340a9..00000000 --- a/infrastructure/gcp/acr/README.md +++ /dev/null @@ -1,124 +0,0 @@ -# Module: acr - -## Description - -Creates a Google Artifact Registry repository with a service account and IAM role for writing to the registry - -## Architecture - -The module creates a google_artifact_registry_repository resource, a google_service_account for accessing the registry, a google_project_iam_member to assign the artifactregistry.writer role to the service account, and a google_service_account_key for the service account. The google_artifact_registry_repository resource is configured with the provided project_id, location, and containerregistry_name. The google_service_account and google_project_iam_member resources are used to grant access to the registry. The google_service_account_key resource is used to generate a private key for the service account. The module also outputs the ID of the container registry, the URL of the container registry, and the service account key for container registry access. - -## Features - -- Creates a Google Artifact Registry repository with a specified format -- Configures a service account with the artifactregistry.writer role for writing to the registry -- Supports custom labels for the container registry via the tags variable - -## Basic Usage - -```hcl -module "acr" { - source = "git::https://github.com/nullplatform/tofu-modules.git//infrastructure/gcp/acr?ref=v1.53.0" - - containerregistry_name = "your-containerregistry-name" - location = "your-location" - project_id = "your-project-id" -} -``` - -## Using Outputs - -```hcl -# Reference outputs in other resources -resource "example_resource" "this" { - example_attribute = module.acr.acr_id -} -``` - - -## Requirements - -| Name | Version | -|------|---------| -| [terraform](#requirement\_terraform) | >= 1.3 | -| [google](#requirement\_google) | ~> 5.0 | - -## Providers - -| Name | Version | -|------|---------| -| [google](#provider\_google) | ~> 5.0 | - -## Resources - -| Name | Type | -|------|------| -| [google_artifact_registry_repository.registry](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/artifact_registry_repository) | resource | -| [google_project_iam_member.artifact_sa_role](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_member) | resource | -| [google_service_account.artifact_sa](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource | -| [google_service_account_key.artifact_sa_key](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account_key) | resource | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [containerregistry\_name](#input\_containerregistry\_name) | The name of the container registry (repository ID) | `string` | n/a | yes | -| [format](#input\_format) | The format of the repository (DOCKER, NPM, PYTHON, etc) | `string` | `"DOCKER"` | no | -| [location](#input\_location) | The GCP region where the container registry will be created (e.g., us-central1, europe-west1) | `string` | n/a | yes | -| [project\_id](#input\_project\_id) | The GCP project ID | `string` | n/a | yes | -| [tags](#input\_tags) | A mapping of labels to assign to the container registry | `map(string)` | `{}` | no | - -## Outputs - -| Name | Description | -|------|-------------| -| [acr\_id](#output\_acr\_id) | The ID of the container registry | -| [acr\_login\_server](#output\_acr\_login\_server) | The URL of the container registry | -| [service\_account\_key\_json](#output\_service\_account\_key\_json) | The Service Account key for container registry access | - - - diff --git a/infrastructure/gcp/acr/main.tf b/infrastructure/gcp/acr/main.tf deleted file mode 100644 index 7019cd47..00000000 --- a/infrastructure/gcp/acr/main.tf +++ /dev/null @@ -1,30 +0,0 @@ -resource "google_artifact_registry_repository" "registry" { - project = var.project_id - location = var.location - repository_id = var.containerregistry_name - format = var.format - - labels = var.tags -} - -resource "google_service_account" "artifact_sa" { - account_id = "artifact-registry-sa" - display_name = "Service Account for Artifact Registry" - description = "Used to push/pull Docker images" -} - -resource "google_project_iam_member" "artifact_sa_role" { - project = var.project_id - role = "roles/artifactregistry.writer" - member = "serviceAccount:${google_service_account.artifact_sa.email}" -} - -resource "google_service_account_iam_member" "workload_identity" { - for_each = { - for wi in var.workload_identity_bindings : "${wi.namespace}-${wi.ksa_name}" => wi - } - - service_account_id = google_service_account.artifact_sa.name - role = "roles/iam.workloadIdentityUser" - member = "serviceAccount:${var.project_id}.svc.id.goog[${each.value.namespace}/${each.value.ksa_name}]" -} diff --git a/infrastructure/gcp/acr/outputs.tf b/infrastructure/gcp/acr/outputs.tf deleted file mode 100644 index 2bacb500..00000000 --- a/infrastructure/gcp/acr/outputs.tf +++ /dev/null @@ -1,14 +0,0 @@ -output "acr_id" { - description = "The ID of the container registry" - value = google_artifact_registry_repository.registry.id -} - -output "acr_login_server" { - description = "The URL of the container registry" - value = "${var.location}-docker.pkg.dev/${var.project_id}/${var.containerregistry_name}" -} - -output "service_account_email" { - description = "GCP Service Account email. Annotate the Kubernetes ServiceAccount bound via workload_identity_bindings with iam.gke.io/gcp-service-account= to impersonate this account from pods." - value = google_service_account.artifact_sa.email -} diff --git a/infrastructure/gcp/acr/providers.tf b/infrastructure/gcp/acr/providers.tf deleted file mode 100644 index f9740720..00000000 --- a/infrastructure/gcp/acr/providers.tf +++ /dev/null @@ -1,10 +0,0 @@ -terraform { - required_version = ">= 1.3" - - required_providers { - google = { - source = "hashicorp/google" - version = "~> 5.0" - } - } -} diff --git a/infrastructure/gcp/acr/variables.tf b/infrastructure/gcp/acr/variables.tf deleted file mode 100644 index feb924c6..00000000 --- a/infrastructure/gcp/acr/variables.tf +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -# REQUIRED VARIABLES -############################################################################### - -variable "project_id" { - type = string - description = "The GCP project ID" -} - -variable "location" { - type = string - description = "The GCP region where the container registry will be created (e.g., us-central1, europe-west1)" -} - -variable "containerregistry_name" { - type = string - description = "The name of the container registry (repository ID)" -} - -############################################################################### -# OPTIONAL VARIABLES - REGISTRY CONFIGURATION -############################################################################### - -variable "format" { - type = string - description = "The format of the repository (DOCKER, NPM, PYTHON, etc)" - default = "DOCKER" -} - -############################################################################### -# OPTIONAL VARIABLES - TAGS AND METADATA -############################################################################### - -variable "tags" { - type = map(string) - description = "A mapping of labels to assign to the container registry" - default = {} -} - -variable "workload_identity_bindings" { - description = "Kubernetes ServiceAccounts allowed to impersonate the GCP Service Account via Workload Identity. Each entry grants roles/iam.workloadIdentityUser on the GSA to the KSA identified by namespace/ksa_name." - type = list(object({ - namespace = string - ksa_name = string - })) - default = [] -} diff --git a/infrastructure/gcp/artifact-registry/main.tf b/infrastructure/gcp/artifact-registry/main.tf index 1e815f78..4beb89b4 100644 --- a/infrastructure/gcp/artifact-registry/main.tf +++ b/infrastructure/gcp/artifact-registry/main.tf @@ -3,6 +3,8 @@ resource "google_artifact_registry_repository" "registry" { location = var.location repository_id = var.repository_id format = var.format + + labels = var.tags } resource "google_service_account" "artifact_sa" { diff --git a/infrastructure/gcp/artifact-registry/variables.tf b/infrastructure/gcp/artifact-registry/variables.tf index cccd01eb..bafded6d 100644 --- a/infrastructure/gcp/artifact-registry/variables.tf +++ b/infrastructure/gcp/artifact-registry/variables.tf @@ -19,6 +19,12 @@ variable "format" { default = "DOCKER" } +variable "tags" { + type = map(string) + description = "A mapping of labels to assign to the Artifact Registry repository" + default = {} +} + variable "workload_identity_bindings" { description = "Kubernetes ServiceAccounts allowed to impersonate the GCP Service Account via Workload Identity. Each entry grants roles/iam.workloadIdentityUser on the GSA to the KSA identified by namespace/ksa_name." type = list(object({ diff --git a/infrastructure/gcp/cloud-dns/main.tf b/infrastructure/gcp/cloud-dns/main.tf index 21420aac..630b6a70 100644 --- a/infrastructure/gcp/cloud-dns/main.tf +++ b/infrastructure/gcp/cloud-dns/main.tf @@ -1,6 +1,10 @@ +locals { + zone_name = var.zone_name != null ? var.zone_name : replace(var.domain_name, ".", "-") +} + resource "google_dns_managed_zone" "zone" { project = var.project_id - name = var.zone_name + name = local.zone_name dns_name = "${var.domain_name}." visibility = var.visibility @@ -15,4 +19,6 @@ resource "google_dns_managed_zone" "zone" { } } } + + labels = var.tags } diff --git a/infrastructure/gcp/cloud-dns/outputs.tf b/infrastructure/gcp/cloud-dns/outputs.tf index 71dfee15..9c270876 100644 --- a/infrastructure/gcp/cloud-dns/outputs.tf +++ b/infrastructure/gcp/cloud-dns/outputs.tf @@ -1,7 +1,14 @@ output "zone_name" { - value = google_dns_managed_zone.zone.name + description = "The name of the created DNS managed zone" + value = google_dns_managed_zone.zone.name +} + +output "zone_id" { + description = "The ID of the created DNS managed zone" + value = google_dns_managed_zone.zone.id } output "name_servers" { - value = google_dns_managed_zone.zone.name_servers + description = "The list of name servers for the DNS managed zone" + value = google_dns_managed_zone.zone.name_servers } diff --git a/infrastructure/gcp/cloud-dns/tests/cloud_dns.tftest.hcl b/infrastructure/gcp/cloud-dns/tests/cloud_dns.tftest.hcl index e7801fdb..d8dabbfd 100644 --- a/infrastructure/gcp/cloud-dns/tests/cloud_dns.tftest.hcl +++ b/infrastructure/gcp/cloud-dns/tests/cloud_dns.tftest.hcl @@ -45,3 +45,32 @@ run "zone_uses_provided_name" { error_message = "Zone name should match zone_name variable" } } + +run "zone_name_derived_from_domain_when_omitted" { + command = plan + + variables { + zone_name = null + } + + assert { + condition = google_dns_managed_zone.zone.name == "myorg-example-com" + error_message = "Zone name should derive from domain_name by replacing dots with dashes when zone_name is null" + } +} + +run "labels_applied_from_tags" { + command = plan + + variables { + tags = { + env = "test" + team = "platform" + } + } + + assert { + condition = google_dns_managed_zone.zone.labels["env"] == "test" + error_message = "Labels should be applied from tags variable" + } +} diff --git a/infrastructure/gcp/cloud-dns/variables.tf b/infrastructure/gcp/cloud-dns/variables.tf index cf518e28..5a0b9b9d 100644 --- a/infrastructure/gcp/cloud-dns/variables.tf +++ b/infrastructure/gcp/cloud-dns/variables.tf @@ -3,14 +3,15 @@ variable "project_id" { description = "The GCP project ID" } -variable "zone_name" { +variable "domain_name" { type = string - description = "The name of the DNS zone resource" + description = "The domain name for the DNS zone (without trailing dot, e.g. example.com)" } -variable "domain_name" { +variable "zone_name" { type = string - description = "The domain name (without trailing dot)" + description = "The name of the DNS zone resource. Defaults to domain_name with dots replaced by dashes." + default = null } variable "visibility" { @@ -24,3 +25,9 @@ variable "private_zone_networks" { description = "VPC network self-links for private zones" default = [] } + +variable "tags" { + type = map(string) + description = "A mapping of labels to assign to the DNS managed zone" + default = {} +} diff --git a/infrastructure/gcp/cloud-nat/outputs.tf b/infrastructure/gcp/cloud-nat/outputs.tf index 940eb5de..31479126 100644 --- a/infrastructure/gcp/cloud-nat/outputs.tf +++ b/infrastructure/gcp/cloud-nat/outputs.tf @@ -1,7 +1,9 @@ output "router_name" { - value = google_compute_router.router.name + description = "The name of the created Cloud Router" + value = google_compute_router.router.name } output "nat_name" { - value = google_compute_router_nat.nat.name + description = "The name of the created Cloud NAT gateway" + value = google_compute_router_nat.nat.name } diff --git a/infrastructure/gcp/dns/README.md b/infrastructure/gcp/dns/README.md deleted file mode 100644 index 1ad2db8c..00000000 --- a/infrastructure/gcp/dns/README.md +++ /dev/null @@ -1,126 +0,0 @@ -# Module: dns - -## Description - -Creates a Google Cloud DNS managed zone with optional private visibility and VPC association - -## Architecture - -The module creates a google_dns_managed_zone resource, which is configured with the provided project ID, domain name, and visibility settings. The zone's name is determined by the dns_zone_name variable, or defaults to the domain name with dashes if not provided. The module also supports private DNS zones by associating VPCs using the vpc_ids variable. The google_dns_managed_zone resource is further configured with labels using the tags variable. The module outputs the created DNS zone's name, ID, and name servers. - -## Features - -- Creates a Google Cloud DNS managed zone -- Configures private DNS zone visibility with VPC association -- Supports custom DNS zone names and labels - -## Basic Usage - -```hcl -module "dns" { - source = "git::https://github.com/nullplatform/tofu-modules.git//infrastructure/gcp/dns?ref=v1.53.0" - - domain_name = "your-domain-name" - project_id = "your-project-id" -} -``` - -## Using Outputs - -```hcl -# Reference outputs in other resources -resource "example_resource" "this" { - example_attribute = module.dns.dns_zone_name -} -``` - - -## Requirements - -| Name | Version | -|------|---------| -| [terraform](#requirement\_terraform) | >= 1.3 | -| [google](#requirement\_google) | ~> 5.0 | - -## Providers - -| Name | Version | -|------|---------| -| [google](#provider\_google) | ~> 5.0 | - -## Resources - -| Name | Type | -|------|------| -| [google_dns_managed_zone.zone](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_managed_zone) | resource | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [dns\_zone\_name](#input\_dns\_zone\_name) | The name of the DNS zone resource (defaults to domain name with dashes) | `string` | `null` | no | -| [domain\_name](#input\_domain\_name) | The domain name to use for the DNS zone (e.g., example.com) | `string` | n/a | yes | -| [project\_id](#input\_project\_id) | The GCP project ID | `string` | n/a | yes | -| [tags](#input\_tags) | A mapping of labels to assign to the DNS zone | `map(string)` | `{}` | no | -| [visibility](#input\_visibility) | Zone visibility: public or private | `string` | `"public"` | no | -| [vpc\_ids](#input\_vpc\_ids) | Vpc self-links for private DNS zone association | `list(string)` | `[]` | no | - -## Outputs - -| Name | Description | -|------|-------------| -| [dns\_zone\_id](#output\_dns\_zone\_id) | The ID of the created DNS zone | -| [dns\_zone\_name](#output\_dns\_zone\_name) | The name of the created DNS zone | -| [name\_servers](#output\_name\_servers) | The list of name servers for the DNS zone | - - - diff --git a/infrastructure/gcp/dns/main.tf b/infrastructure/gcp/dns/main.tf deleted file mode 100644 index 86a0ba40..00000000 --- a/infrastructure/gcp/dns/main.tf +++ /dev/null @@ -1,24 +0,0 @@ -locals { - zone_name = var.dns_zone_name != null ? var.dns_zone_name : replace(var.domain_name, ".", "-") -} - -resource "google_dns_managed_zone" "zone" { - project = var.project_id - name = local.zone_name - dns_name = "${var.domain_name}." - visibility = var.visibility - - dynamic "private_visibility_config" { - for_each = var.visibility == "private" ? [1] : [] - content { - dynamic "networks" { - for_each = var.vpc_ids - content { - network_url = networks.value - } - } - } - } - - labels = var.tags -} diff --git a/infrastructure/gcp/dns/outputs.tf b/infrastructure/gcp/dns/outputs.tf deleted file mode 100644 index 2b978b28..00000000 --- a/infrastructure/gcp/dns/outputs.tf +++ /dev/null @@ -1,14 +0,0 @@ -output "dns_zone_name" { - description = "The name of the created DNS zone" - value = google_dns_managed_zone.zone.name -} - -output "dns_zone_id" { - description = "The ID of the created DNS zone" - value = google_dns_managed_zone.zone.id -} - -output "name_servers" { - description = "The list of name servers for the DNS zone" - value = google_dns_managed_zone.zone.name_servers -} diff --git a/infrastructure/gcp/dns/providers.tf b/infrastructure/gcp/dns/providers.tf deleted file mode 100644 index f9740720..00000000 --- a/infrastructure/gcp/dns/providers.tf +++ /dev/null @@ -1,10 +0,0 @@ -terraform { - required_version = ">= 1.3" - - required_providers { - google = { - source = "hashicorp/google" - version = "~> 5.0" - } - } -} diff --git a/infrastructure/gcp/dns/variables.tf b/infrastructure/gcp/dns/variables.tf deleted file mode 100644 index 19add0b8..00000000 --- a/infrastructure/gcp/dns/variables.tf +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################### -# REQUIRED VARIABLES -############################################################################### - -variable "project_id" { - type = string - description = "The GCP project ID" -} - -variable "domain_name" { - type = string - description = "The domain name to use for the DNS zone (e.g., example.com)" -} - -############################################################################### -# OPTIONAL VARIABLES - DNS CONFIGURATION -############################################################################### - -variable "dns_zone_name" { - type = string - description = "The name of the DNS zone resource (defaults to domain name with dashes)" - default = null -} - -variable "visibility" { - type = string - description = "Zone visibility: public or private" - default = "public" -} - -variable "vpc_ids" { - type = list(string) - description = "Vpc self-links for private DNS zone association" - default = [] -} - -############################################################################### -# OPTIONAL VARIABLES - TAGS AND METADATA -############################################################################### - -variable "tags" { - type = map(string) - description = "A mapping of labels to assign to the DNS zone" - default = {} -} diff --git a/infrastructure/gcp/nat/README.md b/infrastructure/gcp/nat/README.md deleted file mode 100644 index d2994274..00000000 --- a/infrastructure/gcp/nat/README.md +++ /dev/null @@ -1,128 +0,0 @@ -# Module: nat - -## Description - -Creates a Cloud Router and Cloud NAT in Google Cloud Platform - -## Architecture - -This module creates a google_compute_router resource and a google_compute_router_nat resource, connecting them internally by setting the router attribute of the nat resource to the name of the router resource. The inputs for project_id, location, vpc_id, router_name, and nat_name are used to configure these resources. The module also outputs the names of the created router and nat resources. - -## Features - -- Creates Cloud Router with specified name and region -- Configures Cloud NAT with auto-allocated IP addresses -- Supports all subnetworks and IP ranges for NAT - -## Basic Usage - -```hcl -module "nat" { - source = "git::https://github.com/nullplatform/tofu-modules.git//infrastructure/gcp/nat?ref=v1.53.0" - - location = "your-location" - nat_name = "your-nat-name" - project_id = "your-project-id" - router_name = "your-router-name" - vpc_id = "your-vpc-id" -} -``` - -## Using Outputs - -```hcl -# Reference outputs in other resources -resource "example_resource" "this" { - example_attribute = module.nat.router_name -} -``` - - -## Requirements - -| Name | Version | -|------|---------| -| [terraform](#requirement\_terraform) | >= 1.3 | -| [google](#requirement\_google) | ~> 5.0 | - -## Providers - -| Name | Version | -|------|---------| -| [google](#provider\_google) | ~> 5.0 | - -## Resources - -| Name | Type | -|------|------| -| [google_compute_router.router](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_router) | resource | -| [google_compute_router_nat.nat](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_router_nat) | resource | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [location](#input\_location) | The GCP region where Cloud NAT will be created (e.g., us-central1, europe-west1) | `string` | n/a | yes | -| [nat\_name](#input\_nat\_name) | The name of the Cloud NAT | `string` | n/a | yes | -| [project\_id](#input\_project\_id) | The GCP project ID | `string` | n/a | yes | -| [router\_name](#input\_router\_name) | The name of the Cloud Router | `string` | n/a | yes | -| [tags](#input\_tags) | A mapping of labels to assign to the NAT resources | `map(string)` | `{}` | no | -| [vpc\_id](#input\_vpc\_id) | The self-link of the virtual network | `string` | n/a | yes | - -## Outputs - -| Name | Description | -|------|-------------| -| [nat\_name](#output\_nat\_name) | The name of the Cloud NAT | -| [router\_name](#output\_router\_name) | The name of the Cloud Router | - - - diff --git a/infrastructure/gcp/nat/main.tf b/infrastructure/gcp/nat/main.tf deleted file mode 100644 index 3de75205..00000000 --- a/infrastructure/gcp/nat/main.tf +++ /dev/null @@ -1,15 +0,0 @@ -resource "google_compute_router" "router" { - name = var.router_name - project = var.project_id - region = var.location - network = var.vpc_id -} - -resource "google_compute_router_nat" "nat" { - name = var.nat_name - project = var.project_id - router = google_compute_router.router.name - region = var.location - nat_ip_allocate_option = "AUTO_ONLY" - source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES" -} diff --git a/infrastructure/gcp/nat/outputs.tf b/infrastructure/gcp/nat/outputs.tf deleted file mode 100644 index 303cde95..00000000 --- a/infrastructure/gcp/nat/outputs.tf +++ /dev/null @@ -1,9 +0,0 @@ -output "router_name" { - description = "The name of the Cloud Router" - value = google_compute_router.router.name -} - -output "nat_name" { - description = "The name of the Cloud NAT" - value = google_compute_router_nat.nat.name -} diff --git a/infrastructure/gcp/nat/providers.tf b/infrastructure/gcp/nat/providers.tf deleted file mode 100644 index f9740720..00000000 --- a/infrastructure/gcp/nat/providers.tf +++ /dev/null @@ -1,10 +0,0 @@ -terraform { - required_version = ">= 1.3" - - required_providers { - google = { - source = "hashicorp/google" - version = "~> 5.0" - } - } -} diff --git a/infrastructure/gcp/nat/variables.tf b/infrastructure/gcp/nat/variables.tf deleted file mode 100644 index aa36123f..00000000 --- a/infrastructure/gcp/nat/variables.tf +++ /dev/null @@ -1,38 +0,0 @@ -############################################################################### -# REQUIRED VARIABLES -############################################################################### - -variable "project_id" { - type = string - description = "The GCP project ID" -} - -variable "location" { - type = string - description = "The GCP region where Cloud NAT will be created (e.g., us-central1, europe-west1)" -} - -variable "vpc_id" { - type = string - description = "The self-link of the virtual network" -} - -variable "router_name" { - type = string - description = "The name of the Cloud Router" -} - -variable "nat_name" { - type = string - description = "The name of the Cloud NAT" -} - -############################################################################### -# OPTIONAL VARIABLES - TAGS AND METADATA -############################################################################### - -variable "tags" { - type = map(string) - description = "A mapping of labels to assign to the NAT resources" - default = {} -} diff --git a/infrastructure/gcp/vnet/README.md b/infrastructure/gcp/vnet/README.md deleted file mode 100644 index 0d3dc00a..00000000 --- a/infrastructure/gcp/vnet/README.md +++ /dev/null @@ -1,119 +0,0 @@ -# Module: vnet - -## Description - -This module creates a virtual private network with subnets in Google Cloud Platform - -## Architecture - -The module uses the google network module to create a virtual private network and subnets, and outputs the network and subnet names and IDs. The module also supports secondary IP ranges for GKE pods and services, and allows for custom tags to be applied to the virtual network resources. The subnets are created with private access enabled. The module uses a for loop to iterate over the subnets definition and create each subnet with the specified name, IP address prefix, and location. - -## Features - -- Creates virtual private network with subnets -- Configures subnets with private access -- Supports secondary IP ranges for GKE pods and services -- Applies custom tags to virtual network resources - -## Basic Usage - -```hcl -module "vnet" { - source = "git::https://github.com/nullplatform/tofu-modules.git//infrastructure/gcp/vnet?ref=v1.53.0" - - project_id = "your-project-id" - subnets_definition = "your-subnets-definition" - vpc_name = "your-vpc-name" -} -``` - -## Using Outputs - -```hcl -# Reference outputs in other resources -resource "example_resource" "this" { - example_attribute = module.vnet.vnet_name -} -``` - - -## Requirements - -| Name | Version | -|------|---------| -| [terraform](#requirement\_terraform) | >= 1.3 | -| [google](#requirement\_google) | ~> 5.0 | - -## Modules - -| Name | Source | Version | -|------|--------|---------| -| [vpc](#module\_vpc) | terraform-google-modules/network/google | ~> 9.0 | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [project\_id](#input\_project\_id) | The GCP project ID | `string` | n/a | yes | -| [secondary\_ranges](#input\_secondary\_ranges) | Secondary IP ranges for GKE pods and services | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no | -| [subnets\_definition](#input\_subnets\_definition) | List of subnets to create within the virtual network |
list(object({
name = string
address_prefix = string
location = string
}))
| n/a | yes | -| [tags](#input\_tags) | A mapping of labels to assign to the virtual network resources | `map(string)` | `{}` | no | -| [vpc\_name](#input\_vpc\_name) | The name of the virtual private network | `string` | n/a | yes | - -## Outputs - -| Name | Description | -|------|-------------| -| [subnet\_ids](#output\_subnet\_ids) | The self-links of the subnets created in the virtual network | -| [subnet\_names](#output\_subnet\_names) | The names of the subnets created in the virtual network | -| [vnet\_id](#output\_vnet\_id) | The self-link of the virtual network | -| [vnet\_name](#output\_vnet\_name) | The name of the virtual network | - - - diff --git a/infrastructure/gcp/vnet/main.tf b/infrastructure/gcp/vnet/main.tf deleted file mode 100644 index a5a66bd4..00000000 --- a/infrastructure/gcp/vnet/main.tf +++ /dev/null @@ -1,18 +0,0 @@ -module "vpc" { - source = "terraform-google-modules/network/google" - version = "~> 9.0" - - project_id = var.project_id - network_name = var.vpc_name - - subnets = [ - for s in var.subnets_definition : { - subnet_name = s.name - subnet_ip = s.address_prefix - subnet_region = s.location - subnet_private_access = true - } - ] - - secondary_ranges = var.secondary_ranges -} diff --git a/infrastructure/gcp/vnet/outputs.tf b/infrastructure/gcp/vnet/outputs.tf deleted file mode 100644 index 2b37e1d4..00000000 --- a/infrastructure/gcp/vnet/outputs.tf +++ /dev/null @@ -1,19 +0,0 @@ -output "vnet_name" { - description = "The name of the virtual network" - value = module.vpc.network_name -} - -output "vnet_id" { - description = "The self-link of the virtual network" - value = module.vpc.network_self_link -} - -output "subnet_names" { - description = "The names of the subnets created in the virtual network" - value = module.vpc.subnets_names -} - -output "subnet_ids" { - description = "The self-links of the subnets created in the virtual network" - value = module.vpc.subnets_self_links -} diff --git a/infrastructure/gcp/vnet/providers.tf b/infrastructure/gcp/vnet/providers.tf deleted file mode 100644 index f9740720..00000000 --- a/infrastructure/gcp/vnet/providers.tf +++ /dev/null @@ -1,10 +0,0 @@ -terraform { - required_version = ">= 1.3" - - required_providers { - google = { - source = "hashicorp/google" - version = "~> 5.0" - } - } -} diff --git a/infrastructure/gcp/vnet/variables.tf b/infrastructure/gcp/vnet/variables.tf deleted file mode 100644 index 9711d14f..00000000 --- a/infrastructure/gcp/vnet/variables.tf +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################### -# REQUIRED VARIABLES -############################################################################### - -variable "project_id" { - type = string - description = "The GCP project ID" -} - -variable "vpc_name" { - type = string - description = "The name of the virtual private network" -} - -variable "subnets_definition" { - type = list(object({ - name = string - address_prefix = string - location = string - })) - description = "List of subnets to create within the virtual network" -} - -############################################################################### -# OPTIONAL VARIABLES - KUBERNETES CONFIGURATION -############################################################################### - -variable "secondary_ranges" { - type = map(list(object({ range_name = string, ip_cidr_range = string }))) - description = "Secondary IP ranges for GKE pods and services" - default = {} -} - -############################################################################### -# OPTIONAL VARIABLES - TAGS AND METADATA -############################################################################### - -variable "tags" { - type = map(string) - description = "A mapping of labels to assign to the virtual network resources" - default = {} -} diff --git a/infrastructure/gcp/vpc/outputs.tf b/infrastructure/gcp/vpc/outputs.tf index 93b8eed1..bd424440 100644 --- a/infrastructure/gcp/vpc/outputs.tf +++ b/infrastructure/gcp/vpc/outputs.tf @@ -1,15 +1,19 @@ output "network_name" { - value = module.vpc.network_name + description = "The name of the VPC network" + value = module.vpc.network_name } output "network_self_link" { - value = module.vpc.network_self_link + description = "The self-link of the VPC network" + value = module.vpc.network_self_link } output "subnets_names" { - value = module.vpc.subnets_names + description = "The names of the subnets created in the VPC" + value = module.vpc.subnets_names } output "subnets_self_links" { - value = module.vpc.subnets_self_links + description = "The self-links of the subnets created in the VPC" + value = module.vpc.subnets_self_links }