Skip to content

Commit

Permalink
Merge branch 'master' of github.com:GoogleCloudPlatform/cloud-foundat…
Browse files Browse the repository at this point in the history
…ion-fabric
  • Loading branch information
ludoo committed Jan 28, 2023
2 parents 83a0916 + edd3a82 commit 926541f
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ module "data-platform" {
prefix = "myprefix"
}
# tftest modules=39 resources=286
# tftest modules=39 resources=287
```

## Customizations
Expand Down
24 changes: 14 additions & 10 deletions modules/apigee/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ module "apigee" {
}
environments = {
apis-test = {
display_name = "APIs test"
description = "APIs Test"
envgroups = ["test"]
display_name = "APIs test"
description = "APIs Test"
deployment_type = "ARCHIVE"
api_proxy_type = "PROGRAMMABLE"
envgroups = ["test"]
}
apis-prod = {
display_name = "APIs prod"
description = "APIs prod"
envgroups = ["prod"]
display_name = "APIs prod"
description = "APIs prod"
deployment_type = "PROXY"
api_proxy_type = "CONFIGURABLE"
envgroups = ["prod"]
iam = {
"roles/viewer" = ["group:[email protected]"]
}
Expand Down Expand Up @@ -169,12 +173,12 @@ module "apigee" {

| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
| [project_id](variables.tf#L75) | 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&#40;object&#40;&#123;&#10; region &#61; string&#10; service_attachment &#61; string&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>null</code> |
| [envgroups](variables.tf#L26) | Environment groups (NAME => [HOSTNAMES]). | <code>map&#40;list&#40;string&#41;&#41;</code> | | <code>null</code> |
| [environments](variables.tf#L32) | Environments. | <code title="map&#40;object&#40;&#123;&#10; display_name &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string, &#34;Terraform-managed&#34;&#41;&#10; node_config &#61; optional&#40;object&#40;&#123;&#10; min_node_count &#61; optional&#40;number&#41;&#10; max_node_count &#61; optional&#40;number&#41;&#10; &#125;&#41;&#41;&#10; iam &#61; optional&#40;map&#40;list&#40;string&#41;&#41;&#41;&#10; envgroups &#61; list&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>null</code> |
| [instances](variables.tf#L47) | Instances. | <code title="map&#40;object&#40;&#123;&#10; display_name &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string, &#34;Terraform-managed&#34;&#41;&#10; region &#61; string&#10; environments &#61; list&#40;string&#41;&#10; psa_ip_cidr_range &#61; string&#10; disk_encryption_key &#61; optional&#40;string&#41;&#10; consumer_accept_list &#61; optional&#40;list&#40;string&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>null</code> |
| [organization](variables.tf#L61) | Apigee organization. If set to null the organization must already exist. | <code title="object&#40;&#123;&#10; display_name &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string, &#34;Terraform-managed&#34;&#41;&#10; authorized_network &#61; optional&#40;string&#41;&#10; runtime_type &#61; optional&#40;string, &#34;CLOUD&#34;&#41;&#10; billing_type &#61; optional&#40;string&#41;&#10; database_encryption_key &#61; optional&#40;string&#41;&#10; analytics_region &#61; optional&#40;string, &#34;europe-west1&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [environments](variables.tf#L32) | Environments. | <code title="map&#40;object&#40;&#123;&#10; display_name &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string, &#34;Terraform-managed&#34;&#41;&#10; deployment_type &#61; optional&#40;string&#41;&#10; api_proxy_type &#61; optional&#40;string&#41;&#10; node_config &#61; optional&#40;object&#40;&#123;&#10; min_node_count &#61; optional&#40;number&#41;&#10; max_node_count &#61; optional&#40;number&#41;&#10; &#125;&#41;&#41;&#10; iam &#61; optional&#40;map&#40;list&#40;string&#41;&#41;&#41;&#10; envgroups &#61; list&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>null</code> |
| [instances](variables.tf#L49) | Instances. | <code title="map&#40;object&#40;&#123;&#10; display_name &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string, &#34;Terraform-managed&#34;&#41;&#10; region &#61; string&#10; environments &#61; list&#40;string&#41;&#10; psa_ip_cidr_range &#61; string&#10; disk_encryption_key &#61; optional&#40;string&#41;&#10; consumer_accept_list &#61; optional&#40;list&#40;string&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>null</code> |
| [organization](variables.tf#L63) | Apigee organization. If set to null the organization must already exist. | <code title="object&#40;&#123;&#10; display_name &#61; optional&#40;string&#41;&#10; description &#61; optional&#40;string, &#34;Terraform-managed&#34;&#41;&#10; authorized_network &#61; optional&#40;string&#41;&#10; runtime_type &#61; optional&#40;string, &#34;CLOUD&#34;&#41;&#10; billing_type &#61; optional&#40;string&#41;&#10; database_encryption_key &#61; optional&#40;string&#41;&#10; analytics_region &#61; optional&#40;string, &#34;europe-west1&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |

## Outputs

Expand Down
10 changes: 6 additions & 4 deletions modules/apigee/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ resource "google_apigee_envgroup" "envgroups" {
}

resource "google_apigee_environment" "environments" {
for_each = local.environments
name = each.key
display_name = each.value.display_name
description = each.value.description
for_each = local.environments
name = each.key
display_name = each.value.display_name
description = each.value.description
deployment_type = each.value.deployment_type
api_proxy_type = each.value.api_proxy_type
dynamic "node_config" {
for_each = try(each.value.node_config, null) != null ? [""] : []
content {
Expand Down
6 changes: 4 additions & 2 deletions modules/apigee/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ variable "envgroups" {
variable "environments" {
description = "Environments."
type = map(object({
display_name = optional(string)
description = optional(string, "Terraform-managed")
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)
Expand Down
3 changes: 2 additions & 1 deletion modules/project/service-accounts.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ locals {
"gkehub.googleapis.com",
"pubsub.googleapis.com",
"secretmanager.googleapis.com",
"sqladmin.googleapis.com"
"sqladmin.googleapis.com",
"cloudbuild.googleapis.com",
]
service_accounts_cmek_service_keys = distinct(flatten([
for s in keys(var.service_encryption_key_ids) : [
Expand Down
2 changes: 1 addition & 1 deletion tests/blueprints/apigee/bigquery-analytics/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

counts:
modules: 9
resources: 60
resources: 61
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_resources(e2e_plan_runner):
"Test that plan works and the numbers of resources is as expected."
modules, resources = e2e_plan_runner()
assert len(modules) == 6
assert len(resources) == 18
assert len(resources) == 19
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_resources(e2e_plan_runner):
"Test that plan works and the numbers of resources is as expected."
modules, resources = e2e_plan_runner()
assert len(modules) == 7
assert len(resources) == 29
assert len(resources) == 30
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_resources(e2e_plan_runner):
"Test that plan works and the numbers of resources is as expected."
modules, resources = e2e_plan_runner()
assert len(modules) == 10
assert len(resources) == 31
assert len(resources) == 32
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ def test_resources(e2e_plan_runner):
"Test that plan works and the numbers of resources is as expected."
modules, resources = e2e_plan_runner(FIXTURES_DIR)
assert len(modules) == 38
assert len(resources) == 285
assert len(resources) == 286
2 changes: 1 addition & 1 deletion tests/blueprints/gke/binauthz/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_resources(e2e_plan_runner):
"Test that plan works and the numbers of resources is as expected."
modules, resources = e2e_plan_runner()
assert len(modules) == 13
assert len(resources) == 43
assert len(resources) == 44
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_resources(e2e_plan_runner):
"Test that plan works and the numbers of resources is as expected."
modules, resources = e2e_plan_runner()
assert len(modules) == 10
assert len(resources) == 38
assert len(resources) == 39
2 changes: 1 addition & 1 deletion tests/blueprints/serverless/api_gateway/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def test_resources(e2e_plan_runner):
"Test that plan works and the numbers of resources is as expected."
modules, resources = e2e_plan_runner()
assert len(modules) == 7
assert len(resources) == 31
assert len(resources) == 32
2 changes: 1 addition & 1 deletion tests/fast/stages/s00_bootstrap/simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ counts:
google_project_iam_binding: 9
google_project_iam_member: 1
google_project_service: 29
google_project_service_identity: 2
google_project_service_identity: 3
google_service_account: 3
google_service_account_iam_binding: 3
google_storage_bucket: 4
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
project_id = "my-project"
environments = {
apis-test = {
display_name = "APIs test"
description = "APIs Test"
api_proxy_type = "PROGRAMMABLE"
envgroups = ["test"]
node_config = {
min_node_count = 2
max_node_count = 5
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
project_id = "my-project"
environments = {
apis-test = {
display_name = "APIs test"
description = "APIs Test"
deployment_type = "ARCHIVE"
envgroups = ["test"]
node_config = {
min_node_count = 2
max_node_count = 5
}
}
}
6 changes: 4 additions & 2 deletions tests/modules/apigee/fixture/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ variable "envgroups" {
variable "environments" {
description = "Environments."
type = map(object({
display_name = optional(string)
description = optional(string, "Terraform-managed")
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)
Expand Down
12 changes: 12 additions & 0 deletions tests/modules/apigee/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ def test_env_only(plan_runner):
'google_apigee_envgroup_attachment.envgroup_attachments': 1,
}

def test_env_only_with_deployment_type(plan_runner):
"Test that creates an environment in an existing environment group, with deployment_type set."
_, resources = plan_runner(tf_var_file='test.env_only_with_deployment_type.tfvars')
assert [r['values'].get('deployment_type') for r in resources
] == [None, 'ARCHIVE']

def test_env_only_with_api_proxy_type(plan_runner):
"Test that creates an environment in an existing environment group, with api_proxy_type set."
_, resources = plan_runner(tf_var_file='test.env_only_with_api_proxy_type.tfvars')
assert [r['values'].get('api_proxy_type') for r in resources
] == [None, 'PROGRAMMABLE']

def test_instance_only(plan_runner):
"Test that creates only an instance."
_, resources = plan_runner(tf_var_file='test.instance_only.tfvars')
Expand Down

0 comments on commit 926541f

Please sign in to comment.