Refactored apigee module and adjusted the blueprints accordingly
This commit is contained in:
@@ -25,33 +25,27 @@ module "apigee" {
|
||||
}
|
||||
environments = {
|
||||
apis-test = {
|
||||
display_name = "APIs test"
|
||||
description = "APIs Test"
|
||||
deployment_type = "ARCHIVE"
|
||||
api_proxy_type = "PROGRAMMABLE"
|
||||
envgroups = ["test"]
|
||||
display_name = "APIs test"
|
||||
description = "APIs Test"
|
||||
envgroups = ["test"]
|
||||
regions = ["europe-west1"]
|
||||
}
|
||||
apis-prod = {
|
||||
display_name = "APIs prod"
|
||||
description = "APIs prod"
|
||||
deployment_type = "PROXY"
|
||||
api_proxy_type = "CONFIGURABLE"
|
||||
envgroups = ["prod"]
|
||||
display_name = "APIs prod"
|
||||
description = "APIs prod"
|
||||
envgroups = ["prod"]
|
||||
regions = ["europe-west3"]
|
||||
iam = {
|
||||
"roles/viewer" = ["group:devops@myorg.com"]
|
||||
}
|
||||
}
|
||||
}
|
||||
instances = {
|
||||
instance-test-ew1 = {
|
||||
region = "europe-west1"
|
||||
environments = ["apis-test"]
|
||||
europe-west1 = {
|
||||
runtime_ip_cidr_range = "10.0.4.0/22"
|
||||
troubleshooting_ip_cidr_range = "10.1.1.0.0/28"
|
||||
}
|
||||
instance-prod-ew3 = {
|
||||
region = "europe-west3"
|
||||
environments = ["apis-prod"]
|
||||
europe-west3 = {
|
||||
runtime_ip_cidr_range = "10.0.8.0/22"
|
||||
troubleshooting_ip_cidr_range = "10.1.16.0/28"
|
||||
}
|
||||
@@ -105,7 +99,7 @@ module "apigee" {
|
||||
# tftest modules=1 resources=8
|
||||
```
|
||||
|
||||
### New environment group in an existing organization
|
||||
### New environment group
|
||||
|
||||
```hcl
|
||||
module "apigee" {
|
||||
@@ -118,7 +112,7 @@ module "apigee" {
|
||||
# tftest modules=1 resources=1
|
||||
```
|
||||
|
||||
### New environment in an existing environment group
|
||||
### New environment
|
||||
|
||||
```hcl
|
||||
module "apigee" {
|
||||
@@ -128,29 +122,26 @@ module "apigee" {
|
||||
apis-test = {
|
||||
display_name = "APIs test"
|
||||
description = "APIs Test"
|
||||
envgroups = ["test"]
|
||||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=2
|
||||
# tftest modules=1 resources=1
|
||||
```
|
||||
|
||||
### New instance attached to an existing environment
|
||||
### New instance
|
||||
|
||||
```hcl
|
||||
module "apigee" {
|
||||
source = "./fabric/modules/apigee"
|
||||
project_id = "my-project"
|
||||
instances = {
|
||||
instance-test-ew1 = {
|
||||
region = "europe-west1"
|
||||
environments = ["apis-test"]
|
||||
europe-west1 = {
|
||||
runtime_ip_cidr_range = "10.0.4.0/22"
|
||||
troubleshooting_ip_cidr_range = "10.1.1.0/28"
|
||||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=2
|
||||
# tftest modules=1 resources=1
|
||||
```
|
||||
|
||||
### New endpoint attachment
|
||||
@@ -176,12 +167,12 @@ module "apigee" {
|
||||
|
||||
| name | description | type | required | default |
|
||||
|---|---|:---:|:---:|:---:|
|
||||
| [project_id](variables.tf#L78) | Project ID. | <code>string</code> | ✓ | |
|
||||
| [project_id](variables.tf#L77) | Project ID. | <code>string</code> | ✓ | |
|
||||
| [endpoint_attachments](variables.tf#L17) | Endpoint attachments. | <code title="map(object({ region = string service_attachment = string }))">map(object({…}))</code> | | <code>null</code> |
|
||||
| [envgroups](variables.tf#L26) | Environment groups (NAME => [HOSTNAMES]). | <code>map(list(string))</code> | | <code>null</code> |
|
||||
| [environments](variables.tf#L32) | 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 = list(string) }))">map(object({…}))</code> | | <code>null</code> |
|
||||
| [instances](variables.tf#L49) | Instances. | <code title="map(object({ display_name = optional(string) description = optional(string, "Terraform-managed") region = string environments = list(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> | | <code>null</code> |
|
||||
| [organization](variables.tf#L64) | 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") })">object({…})</code> | | <code>null</code> |
|
||||
| [environments](variables.tf#L32) | 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>null</code> |
|
||||
| [instances](variables.tf#L50) | Instances ([REGION] => [INSTANCE]). | <code title="map(object({ 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)) }))">map(object({…}))</code> | | <code>null</code> |
|
||||
| [organization](variables.tf#L63) | 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") })">object({…})</code> | | <code>null</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ resource "google_apigee_environment" "environments" {
|
||||
|
||||
resource "google_apigee_envgroup_attachment" "envgroup_attachments" {
|
||||
for_each = merge(concat([for k1, v1 in local.environments : {
|
||||
for v2 in v1.envgroups : "${k1}-${v2}" => {
|
||||
for v2 in coalesce(v1.envgroups, []) : "${k1}-${v2}" => {
|
||||
environment = k1
|
||||
envgroup = v2
|
||||
}
|
||||
@@ -88,10 +88,10 @@ resource "google_apigee_environment_iam_binding" "binding" {
|
||||
|
||||
resource "google_apigee_instance" "instances" {
|
||||
for_each = local.instances
|
||||
name = each.key
|
||||
name = "instance-${each.key}"
|
||||
display_name = each.value.display_name
|
||||
description = each.value.description
|
||||
location = each.value.region
|
||||
location = each.key
|
||||
org_id = local.org_id
|
||||
ip_range = "${each.value.runtime_ip_cidr_range},${each.value.troubleshooting_ip_cidr_range}"
|
||||
disk_encryption_key_name = each.value.disk_encryption_key
|
||||
@@ -99,14 +99,14 @@ resource "google_apigee_instance" "instances" {
|
||||
}
|
||||
|
||||
resource "google_apigee_instance_attachment" "instance_attachments" {
|
||||
for_each = merge(concat([for k1, v1 in local.instances : {
|
||||
for v2 in v1.environments :
|
||||
for_each = merge(concat([for k1, v1 in local.environments : {
|
||||
for v2 in coalesce(v1.regions, []) :
|
||||
"${k1}-${v2}" => {
|
||||
instance = k1
|
||||
environment = v2
|
||||
environment = k1
|
||||
region = v2
|
||||
}
|
||||
}])...)
|
||||
instance_id = google_apigee_instance.instances[each.value.instance].id
|
||||
instance_id = google_apigee_instance.instances[each.value.region].id
|
||||
environment = try(google_apigee_environment.environments[each.value.environment].name,
|
||||
"${local.org_id}/environments/${each.value.environment}")
|
||||
}
|
||||
|
||||
@@ -41,18 +41,17 @@ variable "environments" {
|
||||
max_node_count = optional(number)
|
||||
}))
|
||||
iam = optional(map(list(string)))
|
||||
envgroups = list(string)
|
||||
envgroups = optional(list(string))
|
||||
regions = optional(list(string))
|
||||
}))
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "instances" {
|
||||
description = "Instances."
|
||||
description = "Instances ([REGION] => [INSTANCE])."
|
||||
type = map(object({
|
||||
display_name = optional(string)
|
||||
description = optional(string, "Terraform-managed")
|
||||
region = string
|
||||
environments = list(string)
|
||||
runtime_ip_cidr_range = string
|
||||
troubleshooting_ip_cidr_range = string
|
||||
disk_encryption_key = optional(string)
|
||||
|
||||
Reference in New Issue
Block a user