Fixed, added back environments to each instance, that way we can also create instances for already existing environments
This commit is contained in:
parent
6818b23b53
commit
fdb133f1de
|
@ -53,14 +53,13 @@ Do the following to verify that everything works as expected.
|
|||
|
||||
4. At 4am (UTC) every day the Cloud Scheduler will run and will export the analytics to the BigQuery table. Double-check they are there.
|
||||
<!-- BEGIN TFDOC -->
|
||||
|
||||
## Variables
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [envgroups](variables.tf#L24) | Environment groups (NAME => [HOSTNAMES]). | <code>map(list(string))</code> | ✓ | |
|
||||
| [environments](variables.tf#L30) | Environments. | <code title="map(object({ display_name = optional(string) description = 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> | ✓ | |
|
||||
| [instances](variables.tf#L46) | Instance. | <code title="map(object({ display_name = optional(string) description = optional(string) runtime_ip_cidr_range = string troubleshooting_ip_cidr_range = string disk_encryption_key = optional(string) consumer_accept_list = optional(list(string)) }))">map(object({…}))</code> | ✓ | |
|
||||
| [environments](variables.tf#L30) | Environments. | <code title="map(object({ display_name = optional(string) description = 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)) }))">map(object({…}))</code> | ✓ | |
|
||||
| [instances](variables.tf#L45) | Instance. | <code title="map(object({ display_name = optional(string) description = optional(string) runtime_ip_cidr_range = string troubleshooting_ip_cidr_range = string disk_encryption_key = optional(string) consumer_accept_list = optional(list(string)) environments = optional(list(string)) }))">map(object({…}))</code> | ✓ | |
|
||||
| [project_id](variables.tf#L91) | Project ID. | <code>string</code> | ✓ | |
|
||||
| [psc_config](variables.tf#L97) | PSC configuration. | <code>map(string)</code> | ✓ | |
|
||||
| [datastore_name](variables.tf#L17) | Datastore. | <code>string</code> | | <code>"gcs"</code> |
|
||||
|
@ -74,7 +73,6 @@ Do the following to verify that everything works as expected.
|
|||
| name | description | sensitive |
|
||||
|---|---|:---:|
|
||||
| [ip_address](outputs.tf#L17) | IP address. | |
|
||||
|
||||
<!-- END TFDOC -->
|
||||
## Test
|
||||
|
||||
|
@ -92,13 +90,13 @@ module "test" {
|
|||
environments = {
|
||||
apis-test = {
|
||||
envgroups = ["test"]
|
||||
regions = ["europe-west1"]
|
||||
}
|
||||
}
|
||||
instances = {
|
||||
europe-west1 = {
|
||||
runtime_ip_cidr_range = "10.0.4.0/22"
|
||||
troubleshooting_ip_cidr_range = "10.1.0.0/28"
|
||||
environments = ["apis-test"]
|
||||
}
|
||||
}
|
||||
psc_config = {
|
||||
|
|
|
@ -38,7 +38,6 @@ variable "environments" {
|
|||
}))
|
||||
iam = optional(map(list(string)))
|
||||
envgroups = optional(list(string))
|
||||
regions = optional(list(string))
|
||||
}))
|
||||
nullable = false
|
||||
}
|
||||
|
@ -52,6 +51,7 @@ variable "instances" {
|
|||
troubleshooting_ip_cidr_range = string
|
||||
disk_encryption_key = optional(string)
|
||||
consumer_accept_list = optional(list(string))
|
||||
environments = optional(list(string))
|
||||
}))
|
||||
nullable = false
|
||||
}
|
||||
|
|
|
@ -76,11 +76,11 @@ module "apigee" {
|
|||
environments = {
|
||||
(local.environment) = {
|
||||
envgroups = [local.envgroup]
|
||||
regions = [var.region]
|
||||
}
|
||||
}
|
||||
instances = {
|
||||
(var.region) = {
|
||||
environments = [local.environment]
|
||||
runtime_ip_cidr_range = var.apigee_runtime_ip_cidr_range
|
||||
troubleshooting_ip_cidr_range = var.apigee_troubleshooting_ip_cidr_range
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ module "apigee" {
|
|||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=5 inventory=minimal-cloud.yaml
|
||||
# tftest modules=1 resources=6 inventory=minimal-cloud.yaml
|
||||
```
|
||||
|
||||
### Minimal example with existing organization (CLOUD)
|
||||
|
@ -80,7 +80,7 @@ module "apigee" {
|
|||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=4 inventory=minimal-cloud-no-org.yaml
|
||||
# tftest modules=1 resources=5 inventory=minimal-cloud-no-org.yaml
|
||||
```
|
||||
|
||||
### Disable VPC Peering (CLOUD)
|
||||
|
@ -114,7 +114,7 @@ module "apigee" {
|
|||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=5 inventory=no-peering.yaml
|
||||
# tftest modules=1 resources=6 inventory=no-peering.yaml
|
||||
```
|
||||
|
||||
|
||||
|
@ -142,13 +142,11 @@ module "apigee" {
|
|||
display_name = "APIs test"
|
||||
description = "APIs Test"
|
||||
envgroups = ["test"]
|
||||
regions = ["europe-west1"]
|
||||
}
|
||||
apis-prod = {
|
||||
display_name = "APIs prod"
|
||||
description = "APIs prod"
|
||||
envgroups = ["prod"]
|
||||
regions = ["europe-west3"]
|
||||
iam = {
|
||||
"roles/viewer" = ["group:devops@myorg.com"]
|
||||
}
|
||||
|
@ -158,10 +156,12 @@ module "apigee" {
|
|||
europe-west1 = {
|
||||
runtime_ip_cidr_range = "10.0.4.0/22"
|
||||
troubleshooting_ip_cidr_range = "10.1.1.0.0/28"
|
||||
environments = ["apis-test"]
|
||||
}
|
||||
europe-west3 = {
|
||||
runtime_ip_cidr_range = "10.0.8.0/22"
|
||||
troubleshooting_ip_cidr_range = "10.1.16.0/28"
|
||||
environments = ["apis-prod"]
|
||||
enable_nat = true
|
||||
}
|
||||
}
|
||||
|
@ -320,8 +320,8 @@ module "apigee" {
|
|||
| [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 = 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> |
|
||||
| [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)) }))">map(object({…}))</code> | | <code>{}</code> |
|
||||
| [instances](variables.tf#L64) | 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) environments = optional(list(string)) }))">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
|
||||
|
|
|
@ -112,15 +112,16 @@ resource "google_apigee_nat_address" "apigee_nat" {
|
|||
}
|
||||
|
||||
resource "google_apigee_instance_attachment" "instance_attachments" {
|
||||
for_each = merge(concat([for k1, v1 in var.environments : {
|
||||
for v2 in coalesce(v1.regions, []) :
|
||||
"${k1}-${v2}" => {
|
||||
environment = k1
|
||||
region = v2
|
||||
for_each = merge(concat([for k1, v1 in var.instances : {
|
||||
for v2 in coalesce(v1.environments, []) :
|
||||
"${v2}-${k1}" => {
|
||||
instance = k1
|
||||
environment = v2
|
||||
}
|
||||
}])...)
|
||||
instance_id = google_apigee_instance.instances[each.value.region].id
|
||||
environment = google_apigee_environment.environments[each.value.environment].name
|
||||
instance_id = google_apigee_instance.instances[each.value.instance].id
|
||||
environment = try(google_apigee_environment.environments[each.value.environment].name,
|
||||
"${local.org_id}/environments/${each.value.environment}")
|
||||
}
|
||||
|
||||
resource "google_apigee_endpoint_attachment" "endpoint_attachments" {
|
||||
|
@ -131,7 +132,7 @@ resource "google_apigee_endpoint_attachment" "endpoint_attachments" {
|
|||
service_attachment = each.value.service_attachment
|
||||
}
|
||||
|
||||
resource "google_apigee_addons_config" "test_organization" {
|
||||
resource "google_apigee_addons_config" "addons_config" {
|
||||
for_each = toset(var.addons_config == null ? [] : [""])
|
||||
org = local.org_name
|
||||
addons_config {
|
||||
|
|
|
@ -56,7 +56,6 @@ variable "environments" {
|
|||
}))
|
||||
iam = optional(map(list(string)))
|
||||
envgroups = optional(list(string))
|
||||
regions = optional(list(string))
|
||||
}))
|
||||
default = {}
|
||||
nullable = false
|
||||
|
@ -73,6 +72,7 @@ variable "instances" {
|
|||
disk_encryption_key = optional(string)
|
||||
consumer_accept_list = optional(list(string))
|
||||
enable_nat = optional(bool, false)
|
||||
environments = optional(list(string))
|
||||
}))
|
||||
validation {
|
||||
condition = alltrue([
|
||||
|
|
|
@ -17,21 +17,23 @@ environments = {
|
|||
display_name = "APIs test"
|
||||
description = "APIs Test"
|
||||
envgroups = ["test"]
|
||||
regions = ["europe-west1"]
|
||||
}
|
||||
apis-prod = {
|
||||
display_name = "APIs prod"
|
||||
description = "APIs prod"
|
||||
envgroups = ["prod"]
|
||||
regions = ["europe-west3"]
|
||||
iam = {
|
||||
"roles/viewer" = ["group:devops@myorg.com"]
|
||||
}
|
||||
}
|
||||
}
|
||||
instances = {
|
||||
europe-west1 = {}
|
||||
europe-west3 = {}
|
||||
europe-west1 = {
|
||||
environments = ["europe-west1"]
|
||||
}
|
||||
europe-west3 = {
|
||||
environments = ["europe-west3"]
|
||||
}
|
||||
}
|
||||
endpoint_attachments = {
|
||||
endpoint-backend-1 = {
|
||||
|
|
|
@ -18,13 +18,11 @@ environments = {
|
|||
display_name = "APIs test"
|
||||
description = "APIs Test"
|
||||
envgroups = ["test"]
|
||||
regions = ["europe-west1"]
|
||||
}
|
||||
apis-prod = {
|
||||
display_name = "APIs prod"
|
||||
description = "APIs prod"
|
||||
envgroups = ["prod"]
|
||||
regions = ["europe-west3"]
|
||||
iam = {
|
||||
"roles/viewer" = ["group:devops@myorg.com"]
|
||||
}
|
||||
|
@ -34,10 +32,12 @@ instances = {
|
|||
europe-west1 = {
|
||||
runtime_ip_cidr_range = "10.0.4.0/22"
|
||||
troubleshooting_ip_cidr_range = "10.1.0.0/28"
|
||||
environments = ["apis-test"]
|
||||
}
|
||||
europe-west3 = {
|
||||
runtime_ip_cidr_range = "10.0.6.0/22"
|
||||
troubleshooting_ip_cidr_range = "10.1.0.16/28"
|
||||
environments = ["apis-prod"]
|
||||
}
|
||||
}
|
||||
endpoint_attachments = {
|
||||
|
|
Loading…
Reference in New Issue