From 6a13742e3c4c442a5b90f9b3cb24fffd43bbf715 Mon Sep 17 00:00:00 2001 From: Miren Esnaola Date: Tue, 8 Aug 2023 18:50:57 +0200 Subject: [PATCH] Apigee addons --- .../apigee/bigquery-analytics/README.md | 2 +- blueprints/apigee/hybrid-gke/README.md | 2 +- .../README.md | 2 +- modules/apigee/README.md | 36 ++++++++++++----- modules/apigee/main.tf | 40 +++++++++++++++++++ modules/apigee/variables.tf | 12 ++++++ 6 files changed, 80 insertions(+), 14 deletions(-) diff --git a/blueprints/apigee/bigquery-analytics/README.md b/blueprints/apigee/bigquery-analytics/README.md index 5261f72e..d674a841 100644 --- a/blueprints/apigee/bigquery-analytics/README.md +++ b/blueprints/apigee/bigquery-analytics/README.md @@ -105,5 +105,5 @@ module "test" { europe-west1 = "10.0.0.0/28" } } -# tftest modules=10 resources=64 +# tftest modules=10 resources=65 ``` diff --git a/blueprints/apigee/hybrid-gke/README.md b/blueprints/apigee/hybrid-gke/README.md index 5d79f1f8..e2151d47 100644 --- a/blueprints/apigee/hybrid-gke/README.md +++ b/blueprints/apigee/hybrid-gke/README.md @@ -80,5 +80,5 @@ module "test" { project_id = "my-project" hostname = "test.myorg.org" } -# tftest modules=18 resources=61 +# tftest modules=18 resources=62 ``` diff --git a/blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/README.md b/blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/README.md index 51534dda..8abca3c3 100644 --- a/blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/README.md +++ b/blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/README.md @@ -79,5 +79,5 @@ module "test" { onprem_project_id = "my-onprem-project" hostname = "test.myorg.org" } -# tftest modules=14 resources=77 +# tftest modules=14 resources=78 ``` diff --git a/modules/apigee/README.md b/modules/apigee/README.md index 4bc10e9a..353fb528 100644 --- a/modules/apigee/README.md +++ b/modules/apigee/README.md @@ -61,7 +61,7 @@ module "apigee" { } } } -# tftest modules=1 resources=14 +# tftest modules=1 resources=15 ``` ### All resources (HYBRID control plane) @@ -96,7 +96,7 @@ module "apigee" { } } } -# tftest modules=1 resources=8 +# tftest modules=1 resources=9 ``` ### New environment group @@ -109,7 +109,7 @@ module "apigee" { test = ["test.example.com"] } } -# tftest modules=1 resources=1 +# tftest modules=1 resources=2 ``` ### New environment @@ -125,7 +125,7 @@ module "apigee" { } } } -# tftest modules=1 resources=1 +# tftest modules=1 resources=2 ``` ### New instance @@ -141,7 +141,7 @@ module "apigee" { } } } -# tftest modules=1 resources=1 +# tftest modules=1 resources=2 ``` ### New endpoint attachment @@ -159,6 +159,19 @@ module "apigee" { } } } +# tftest modules=1 resources=2 +``` + +### Apigee add-ons + +```hcl +module "apigee" { + source = "./fabric/modules/apigee" + project_id = "my-project" + addons_config = { + monetization = true + } +} # tftest modules=1 resources=1 ``` @@ -166,12 +179,13 @@ module "apigee" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [project_id](variables.tf#L78) | Project ID. | string | ✓ | | -| [endpoint_attachments](variables.tf#L17) | Endpoint attachments. | map(object({…})) | | null | -| [envgroups](variables.tf#L26) | Environment groups (NAME => [HOSTNAMES]). | map(list(string)) | | null | -| [environments](variables.tf#L32) | Environments. | map(object({…})) | | null | -| [instances](variables.tf#L50) | Instances ([REGION] => [INSTANCE]). | map(object({…})) | | null | -| [organization](variables.tf#L63) | Apigee organization. If set to null the organization must already exist. | object({…}) | | null | +| [project_id](variables.tf#L90) | 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#L75) | Apigee organization. If set to null the organization must already exist. | object({…}) | | null | ## Outputs diff --git a/modules/apigee/main.tf b/modules/apigee/main.tf index 5c7cfe4f..e68c5f90 100644 --- a/modules/apigee/main.tf +++ b/modules/apigee/main.tf @@ -16,6 +16,7 @@ locals { 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) envgroups = coalesce(var.envgroups, {}) environments = coalesce(var.environments, {}) instances = coalesce(var.instances, {}) @@ -119,3 +120,42 @@ resource "google_apigee_endpoint_attachment" "endpoint_attachments" { location = each.value.region service_attachment = each.value.service_attachment } + +resource "google_apigee_addons_config" "test_organization" { + org = local.org_name + dynamic "addons_config" { + for_each = var.addons_config == null ? [] : [""] + content { + dynamic "advanced_api_ops_config" { + for_each = var.addons_config.advanced_api_ops ? [] : [""] + content { + enabled = true + } + } + dynamic "api_security_config" { + for_each = var.addons_config.api_security ? [] : [""] + content { + enabled = true + } + } + dynamic "connectors_platform_config" { + for_each = var.addons_config.connectors_platform ? [] : [""] + content { + enabled = true + } + } + dynamic "integration_config" { + for_each = var.addons_config.integration ? [] : [""] + content { + enabled = true + } + } + dynamic "monetization_config" { + for_each = var.addons_config.monetization ? [] : [""] + content { + enabled = true + } + } + } + } +} diff --git a/modules/apigee/variables.tf b/modules/apigee/variables.tf index 27053764..4c2f0308 100644 --- a/modules/apigee/variables.tf +++ b/modules/apigee/variables.tf @@ -14,6 +14,18 @@ * limitations under the License. */ +variable "addons_config" { + description = "Addons configuration." + type = 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) + }) + default = null +} + variable "endpoint_attachments" { description = "Endpoint attachments." type = map(object({