Allow creating organizations/instances without VPC Peering
This commit is contained in:
parent
6f5a6aa06d
commit
0822531b78
|
@ -180,13 +180,13 @@ module "apigee" {
|
|||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [project_id](variables.tf#L96) | Project ID. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L117) | Project ID. | <code>string</code> | ✓ | |
|
||||
| [addons_config](variables.tf#L17) | Addons configuration. | <code title="object({ advanced_api_ops = optional(bool, false) api_security = optional(bool, false) connectors_platform = optional(bool, false) integration = optional(bool, false) monetization = optional(bool, false) })">object({…})</code> | | <code>null</code> |
|
||||
| [endpoint_attachments](variables.tf#L29) | Endpoint attachments. | <code title="map(object({ region = string service_attachment = string }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [envgroups](variables.tf#L39) | Environment groups (NAME => [HOSTNAMES]). | <code>map(list(string))</code> | | <code>{}</code> |
|
||||
| [environments](variables.tf#L46) | Environments. | <code title="map(object({ display_name = optional(string) description = optional(string, "Terraform-managed") deployment_type = optional(string) api_proxy_type = optional(string) node_config = optional(object({ min_node_count = optional(number) max_node_count = optional(number) })) iam = optional(map(list(string))) envgroups = optional(list(string)) regions = optional(list(string)) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [instances](variables.tf#L65) | Instances ([REGION] => [INSTANCE]). | <code title="map(object({ name = optional(string) display_name = optional(string) description = optional(string, "Terraform-managed") runtime_ip_cidr_range = string troubleshooting_ip_cidr_range = string disk_encryption_key = optional(string) consumer_accept_list = optional(list(string)) enable_nat = optional(bool, false) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [organization](variables.tf#L81) | Apigee organization. If set to null the organization must already exist. | <code title="object({ display_name = optional(string) description = optional(string, "Terraform-managed") authorized_network = optional(string) runtime_type = optional(string, "CLOUD") billing_type = optional(string) database_encryption_key = optional(string) analytics_region = optional(string, "europe-west1") retention = optional(string) })">object({…})</code> | | <code>null</code> |
|
||||
| [instances](variables.tf#L65) | Instances ([REGION] => [INSTANCE]). | <code title="map(object({ name = optional(string) display_name = optional(string) description = optional(string, "Terraform-managed") runtime_ip_cidr_range = optional(string) troubleshooting_ip_cidr_range = optional(string) disk_encryption_key = optional(string) consumer_accept_list = optional(list(string)) enable_nat = optional(bool, false) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [organization](variables.tf#L89) | Apigee organization. If set to null the organization must already exist. | <code title="object({ display_name = optional(string) description = optional(string, "Terraform-managed") authorized_network = optional(string) runtime_type = optional(string, "CLOUD") billing_type = optional(string) database_encryption_key = optional(string) analytics_region = optional(string, "europe-west1") retention = optional(string) disable_vpc_peering = optional(bool, false) })">object({…})</code> | | <code>null</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ resource "google_apigee_organization" "organization" {
|
|||
runtime_type = var.organization.runtime_type
|
||||
runtime_database_encryption_key_name = var.organization.database_encryption_key
|
||||
retention = var.organization.retention
|
||||
disable_vpc_peering = var.organization.disable_vpc_peering
|
||||
}
|
||||
|
||||
resource "google_apigee_envgroup" "envgroups" {
|
||||
|
@ -85,13 +86,17 @@ resource "google_apigee_environment_iam_binding" "binding" {
|
|||
}
|
||||
|
||||
resource "google_apigee_instance" "instances" {
|
||||
for_each = var.instances
|
||||
name = coalesce(each.value.name, "instance-${each.key}")
|
||||
display_name = each.value.display_name
|
||||
description = each.value.description
|
||||
location = each.key
|
||||
org_id = local.org_id
|
||||
ip_range = "${each.value.runtime_ip_cidr_range},${each.value.troubleshooting_ip_cidr_range}"
|
||||
for_each = var.instances
|
||||
name = coalesce(each.value.name, "instance-${each.key}")
|
||||
display_name = each.value.display_name
|
||||
description = each.value.description
|
||||
location = each.key
|
||||
org_id = local.org_id
|
||||
ip_range = (
|
||||
compact([each.value.runtime_ip_cidr_range, each.value.troubleshooting_ip_cidr_range]) != []
|
||||
? join(",", compact([each.value.runtime_ip_cidr_range, each.value.troubleshooting_ip_cidr_range]))
|
||||
: null
|
||||
)
|
||||
disk_encryption_key_name = each.value.disk_encryption_key
|
||||
consumer_accept_list = each.value.consumer_accept_list
|
||||
}
|
||||
|
|
|
@ -68,12 +68,20 @@ variable "instances" {
|
|||
name = optional(string)
|
||||
display_name = optional(string)
|
||||
description = optional(string, "Terraform-managed")
|
||||
runtime_ip_cidr_range = string
|
||||
troubleshooting_ip_cidr_range = string
|
||||
runtime_ip_cidr_range = optional(string)
|
||||
troubleshooting_ip_cidr_range = optional(string)
|
||||
disk_encryption_key = optional(string)
|
||||
consumer_accept_list = optional(list(string))
|
||||
enable_nat = optional(bool, false)
|
||||
}))
|
||||
validation {
|
||||
condition = alltrue([
|
||||
for k, v in var.instances :
|
||||
# has troubleshooting_ip => has runtime_ip
|
||||
v.runtime_ip_cidr_range != null || v.troubleshooting_ip_cidr_range == null
|
||||
])
|
||||
error_message = "Using a troubleshooting range requires specifying a runtime range too."
|
||||
}
|
||||
default = {}
|
||||
nullable = false
|
||||
}
|
||||
|
@ -89,7 +97,20 @@ variable "organization" {
|
|||
database_encryption_key = optional(string)
|
||||
analytics_region = optional(string, "europe-west1")
|
||||
retention = optional(string)
|
||||
disable_vpc_peering = optional(bool, false)
|
||||
})
|
||||
validation {
|
||||
condition = var.organization == null || (
|
||||
try(var.organization.runtime_type, null) == "CLOUD" || !try(var.organization.disable_vpc_peering, false)
|
||||
)
|
||||
error_message = "Disabling the VPC peering can only be done in organization using the CLOUD runtime"
|
||||
}
|
||||
validation {
|
||||
condition = var.organization == null || (
|
||||
try(var.organization.authorized_network, null) == null || !try(var.organization.disable_vpc_peering, false)
|
||||
)
|
||||
error_message = "Disabling the VPC peering is mutually exclusive with authorized_network."
|
||||
}
|
||||
default = null
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue