diff --git a/modules/apigee/README.md b/modules/apigee/README.md index 319f6bb8..9d3c32e4 100644 --- a/modules/apigee/README.md +++ b/modules/apigee/README.md @@ -181,13 +181,13 @@ module "apigee" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [project_id](variables.tf#L91) | Project ID. | string | ✓ | | +| [project_id](variables.tf#L95) | Project ID. | string | ✓ | | | [addons_config](variables.tf#L17) | Addons configuration. | object({…}) | | null | -| [endpoint_attachments](variables.tf#L29) | Endpoint attachments. | map(object({…})) | | null | -| [envgroups](variables.tf#L38) | Environment groups (NAME => [HOSTNAMES]). | map(list(string)) | | null | -| [environments](variables.tf#L44) | Environments. | map(object({…})) | | null | -| [instances](variables.tf#L62) | Instances ([REGION] => [INSTANCE]). | map(object({…})) | | null | -| [organization](variables.tf#L76) | Apigee organization. If set to null the organization must already exist. | object({…}) | | null | +| [endpoint_attachments](variables.tf#L29) | Endpoint attachments. | map(object({…})) | | {} | +| [envgroups](variables.tf#L39) | Environment groups (NAME => [HOSTNAMES]). | map(list(string)) | | {} | +| [environments](variables.tf#L46) | Environments. | map(object({…})) | | {} | +| [instances](variables.tf#L65) | Instances ([REGION] => [INSTANCE]). | map(object({…})) | | {} | +| [organization](variables.tf#L80) | Apigee organization. If set to null the organization must already exist. | object({…}) | | null | ## Outputs @@ -196,8 +196,8 @@ module "apigee" { | [endpoint_attachment_hosts](outputs.tf#L17) | Endpoint hosts. | | | [envgroups](outputs.tf#L22) | Environment groups. | | | [environments](outputs.tf#L27) | Environment. | | -| [instance_nat_ips](outputs.tf#L32) | NAT IP addresses used in instances. | | | [instances](outputs.tf#L37) | Instances. | | +| [nat_ips](outputs.tf#L32) | NAT IP addresses used in instances. | | | [org_id](outputs.tf#L42) | Organization ID. | | | [org_name](outputs.tf#L47) | Organization name. | | | [organization](outputs.tf#L52) | Organization. | | diff --git a/modules/apigee/main.tf b/modules/apigee/main.tf index 202ac267..2e5db90c 100644 --- a/modules/apigee/main.tf +++ b/modules/apigee/main.tf @@ -15,7 +15,6 @@ */ locals { - instance_ips = merge([ org_id = try(google_apigee_organization.organization[0].id, "organizations/${var.project_id}") org_name = try(google_apigee_organization.organization[0].name, var.project_id) } @@ -98,7 +97,10 @@ resource "google_apigee_instance" "instances" { } resource "google_apigee_nat_address" "apigee_nat" { - for_each = local.instance_ips + for_each = { + for k, v in var.instances : + k => google_apigee_instance.instances[k].id + } name = each.key instance_id = each.value } diff --git a/modules/apigee/outputs.tf b/modules/apigee/outputs.tf index 62e843ac..be30ef22 100644 --- a/modules/apigee/outputs.tf +++ b/modules/apigee/outputs.tf @@ -29,7 +29,7 @@ output "environments" { value = try(google_apigee_environment.environments, null) } -output "instance_nat_ips" { +output "nat_ips" { description = "NAT IP addresses used in instances." value = try(google_apigee_nat_address.apigee_nat, null) } diff --git a/modules/apigee/variables.tf b/modules/apigee/variables.tf index 9f356dea..3fa5f4e2 100644 --- a/modules/apigee/variables.tf +++ b/modules/apigee/variables.tf @@ -71,7 +71,7 @@ variable "instances" { troubleshooting_ip_cidr_range = string disk_encryption_key = optional(string) consumer_accept_list = optional(list(string)) - nat_required = optional(bool, false) + nat_ips = optional(number, 0) })) default = {} nullable = false