This commit is contained in:
Lorenzo Caggioni 2022-02-03 09:38:06 +01:00
commit f23885cacd
6 changed files with 19 additions and 14 deletions

View File

@ -11,7 +11,7 @@ module "apigee-x-instance" {
source = "./modules/apigee-x-instance"
name = "my-us-instance"
region = "us-central1"
cidr_mask = 22
ip_range = "10.0.0.0/22"
apigee_org_id = "my-project"
apigee_environments = [
@ -29,7 +29,7 @@ module "apigee-x-instance" {
source = "./modules/apigee-x-instance"
name = "my-us-instance"
region = "us-central1"
cidr_mask = 16
ip_range = "10.0.0.0/22"
disk_encryption_key = "my-disk-key"
apigee_org_id = "my-project"
@ -49,7 +49,7 @@ module "apigee-x-instance" {
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
| [apigee_org_id](variables.tf#L32) | Apigee Organization ID. | <code>string</code> | ✓ | |
| [cidr_mask](variables.tf#L37) | CIDR mask for the Apigee instance. | <code>number</code> | ✓ | |
| [ip_range](variables.tf#L37) | Customer-provided CIDR block of length 22 for the Apigee instance. | <code>string</code> | ✓ | |
| [name](variables.tf#L52) | Apigee instance name. | <code>string</code> | ✓ | |
| [region](variables.tf#L57) | Compute region. | <code>string</code> | ✓ | |
| [apigee_envgroups](variables.tf#L17) | Apigee Environment Groups. | <code title="map&#40;object&#40;&#123;&#10; environments &#61; list&#40;string&#41;&#10; hostnames &#61; list&#40;string&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |

View File

@ -18,7 +18,7 @@ resource "google_apigee_instance" "apigee_instance" {
org_id = var.apigee_org_id
name = var.name
location = var.region
peering_cidr_range = "SLASH_${var.cidr_mask}"
ip_range = var.ip_range
disk_encryption_key_name = var.disk_encryption_key
}

View File

@ -34,12 +34,12 @@ variable "apigee_org_id" {
type = string
}
variable "cidr_mask" {
description = "CIDR mask for the Apigee instance."
type = number
variable "ip_range" {
description = "Customer-provided CIDR block of length 22 for the Apigee instance."
type = string
validation {
condition = contains([16, 20, 22], var.cidr_mask)
error_message = "Invalid CIDR mask; Allowed values for cidr_mask: [16, 20, 22]."
condition = try(cidrnetmask(var.ip_range), null) == "255.255.252.0"
error_message = "Invalid CIDR block provided; Allowed pattern for ip_range: X.X.X.X/22."
}
}

View File

@ -15,10 +15,10 @@
*/
module "apigee-x-instance" {
source = "../../../../modules/apigee-x-instance"
name = var.name
region = var.region
cidr_mask = 22
source = "../../../../modules/apigee-x-instance"
name = var.name
region = var.region
ip_range = var.ip_range
apigee_org_id = "my-project"
apigee_environments = [

View File

@ -23,3 +23,8 @@ variable "region" {
type = string
default = "europe-west1"
}
variable "ip_range" {
type = string
default = "10.0.0.0/22"
}

View File

@ -39,6 +39,6 @@ def test_instance(resources):
instances = [r['values'] for r in resources if r['type']
== 'google_apigee_instance']
assert len(instances) == 1
assert instances[0]['peering_cidr_range'] == 'SLASH_22'
assert instances[0]['ip_range'] == '10.0.0.0/22'
assert instances[0]['name'] == 'my-test-instance'
assert instances[0]['location'] == 'europe-west1'