apigee module without service networking
This commit is contained in:
parent
24b5e03c80
commit
9c4bb0562f
|
@ -1,6 +1,6 @@
|
|||
# Apigee Module
|
||||
# Google Apigee Organization Module
|
||||
|
||||
This module allows managing a single Apigee organization and its environments and environmentgrous.
|
||||
This module allows managing a single Apigee organization and its environments and environmentgroups.
|
||||
|
||||
## TODO
|
||||
|
||||
|
@ -16,7 +16,7 @@ module "apigee" {
|
|||
project_id = "my-project"
|
||||
analytics_region = "us-central1"
|
||||
runtime_type = "CLOUD"
|
||||
peering_network = "my-vpc"
|
||||
authorized_network = "my-vpc"
|
||||
peering_range = "10.0.0.0/16"
|
||||
apigee_environments = [
|
||||
"eval1",
|
||||
|
@ -34,7 +34,7 @@ module "apigee" {
|
|||
}
|
||||
}
|
||||
}
|
||||
# tftest:modules=1:resources=10
|
||||
# tftest:modules=1:resources=6
|
||||
```
|
||||
|
||||
### Apigee hybrid Evaluation Organization
|
|
@ -31,7 +31,7 @@ resource "google_apigee_organization" "apigee_org" {
|
|||
display_name = var.display_name
|
||||
description = var.description
|
||||
runtime_type = var.runtime_type
|
||||
authorized_network = var.peering_network
|
||||
authorized_network = var.authorized_network
|
||||
}
|
||||
|
||||
resource "google_apigee_environment" "apigee_env" {
|
||||
|
@ -52,21 +52,3 @@ resource "google_apigee_envgroup_attachment" "env_to_envgroup_attachment" {
|
|||
envgroup_id = google_apigee_envgroup.apigee_envgroup[each.value.envgroup].id
|
||||
environment = google_apigee_environment.apigee_env[each.value.env].name
|
||||
}
|
||||
|
||||
resource "google_compute_global_address" "apigee_peering_range" {
|
||||
count = var.peering_range == null ? 0 : 1
|
||||
project = var.project_id
|
||||
name = "${var.project_id}-apigee-peering"
|
||||
purpose = "VPC_PEERING"
|
||||
address_type = "INTERNAL"
|
||||
address = split("/", var.peering_range)[0]
|
||||
prefix_length = split("/", var.peering_range)[1]
|
||||
network = var.peering_network
|
||||
}
|
||||
|
||||
resource "google_service_networking_connection" "apigee_vpc_connection" {
|
||||
count = var.peering_network == null ? 0 : 1
|
||||
network = "projects/${var.project_id}/global/networks/${var.peering_network}"
|
||||
service = "servicenetworking.googleapis.com"
|
||||
reserved_peering_ranges = [google_compute_global_address.apigee_peering_range.0.name]
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
output "org" {
|
||||
description = "Apigee Organization."
|
||||
value = google_apigee_organization.apigee_org
|
||||
}
|
||||
|
||||
output "org_ca_certificate" {
|
||||
description = "Apigee organization CA certificate."
|
||||
value = google_apigee_organization.apigee_org.ca_certificate
|
||||
}
|
||||
|
||||
output "org_id" {
|
||||
description = "Apigee Organization ID."
|
||||
value = google_apigee_organization.apigee_org.id
|
||||
}
|
||||
|
||||
output "subscription_type" {
|
||||
description = "Apigee subscription type."
|
||||
value = google_apigee_organization.apigee_org.subscription_type
|
||||
}
|
|
@ -14,15 +14,36 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
variable "project_id" {
|
||||
description = "Project ID to host this Apigee organization (will also become the Apigee Org name)."
|
||||
variable "authorized_network" {
|
||||
description = "VPC network id (requires service network peering enabled (Used in Apigee X only)."
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "analytics_region" {
|
||||
description = "Analytics Region for the Apgiee Organization (immutable). See https://cloud.google.com/apigee/docs/api-platform/get-started/install-cli."
|
||||
type = string
|
||||
default = "us-central1"
|
||||
}
|
||||
|
||||
variable "apigee_envgroups" {
|
||||
description = "Apigee Environment Groups."
|
||||
type = map(object({
|
||||
environments = list(string)
|
||||
hostnames = list(string)
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "apigee_environments" {
|
||||
description = "Apigee Environment Names."
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "description" {
|
||||
description = "Description of the Apigee Organization."
|
||||
type = string
|
||||
default = "Apigee Organization created by tf module"
|
||||
}
|
||||
|
||||
variable "display_name" {
|
||||
|
@ -31,10 +52,9 @@ variable "display_name" {
|
|||
default = null
|
||||
}
|
||||
|
||||
variable "description" {
|
||||
description = "Description of the Apigee Organization."
|
||||
variable "project_id" {
|
||||
description = "Project ID to host this Apigee organization (will also become the Apigee Org name)."
|
||||
type = string
|
||||
default = "Apigee Organization created by tf module"
|
||||
}
|
||||
|
||||
variable "runtime_type" {
|
||||
|
@ -46,34 +66,4 @@ variable "runtime_type" {
|
|||
}
|
||||
}
|
||||
|
||||
variable "peering_network" {
|
||||
description = "VPC Network used for peering Apigee (Used in Apigee X only)."
|
||||
type = string
|
||||
default = null
|
||||
|
||||
# validation {
|
||||
# condition = var.runtime_type == "CLOUD" ? var.peering_vpc != null : true
|
||||
# error_message = "A peering_vpc must be provided for Apigee Organizations of runtime_type \"CLOUD\"."
|
||||
# }
|
||||
}
|
||||
|
||||
variable "peering_range" {
|
||||
description = "RFC1919 CIDR range used for peering the Apigee tennant project. Min size for trial is /22 min size for PAID is /20"
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "apigee_environments" {
|
||||
description = "Apigee Environment Names."
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "apigee_envgroups" {
|
||||
description = "Apigee Environment Groups."
|
||||
type = map(object({
|
||||
environments = list(string)
|
||||
hostnames = list(string)
|
||||
}))
|
||||
default = {}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# Apigee Module
|
||||
# Google Apigee X Instance Module
|
||||
|
||||
This module allows managing a single Apigee X instance and its environment attachments.
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/**
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
resource "google_apigee_instance" "apigee_instance" {
|
||||
org_id = var.apigee_org_id
|
||||
name = var.name
|
||||
|
@ -6,7 +22,6 @@ resource "google_apigee_instance" "apigee_instance" {
|
|||
#disk_encryption_key_name = google_kms_crypto_key.apigee_key.id
|
||||
}
|
||||
|
||||
|
||||
resource "google_apigee_instance_attachment" "apigee_instance_attchment" {
|
||||
for_each = toset(var.apigee_environments)
|
||||
instance_id = google_apigee_instance.apigee_instance.id
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
/**
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* limitations under the License.
|
||||
* See the License for the specific language governing permissions and
|
||||
*/
|
||||
|
||||
output "instance" {
|
||||
description = "Apigee instance."
|
||||
value = google_apigee_instance.apigee_instance
|
||||
}
|
||||
|
||||
output "endpoint" {
|
||||
description = "Internal endpoint of the Apigee instance."
|
||||
value = google_apigee_instance.apigee_instance.host
|
||||
|
|
|
@ -1,11 +1,26 @@
|
|||
variable "name" {
|
||||
description = "Apigee instance name."
|
||||
type = string
|
||||
}
|
||||
/**
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
variable "apigee_org_id" {
|
||||
description = "Apigee Organization ID"
|
||||
type = string
|
||||
variable "apigee_envgroups" {
|
||||
description = "Apigee Environment Groups."
|
||||
type = map(object({
|
||||
environments = list(string)
|
||||
hostnames = list(string)
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "apigee_environments" {
|
||||
|
@ -14,15 +29,25 @@ variable "apigee_environments" {
|
|||
default = []
|
||||
}
|
||||
|
||||
variable "apigee_org_id" {
|
||||
description = "Apigee Organization ID"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "cidr_mask" {
|
||||
description = "CIDR mask for the Apigee instance"
|
||||
type = number
|
||||
validation {
|
||||
condition = contains([16, 20, 22], var.cidr_mask)
|
||||
error_message = "Allowed Values for cidr_mask [16, 20, 22]."
|
||||
error_message = "Invalid CIDR mask; Allowed values for cidr_mask: [16, 20, 22]."
|
||||
}
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
description = "Apigee instance name."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
description = "Compute region."
|
||||
type = string
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
output "subscription_type" {
|
||||
description = "Apigee subscription type."
|
||||
value = google_apigee_organization.apigee_org.subscription_type
|
||||
}
|
||||
|
||||
output "org_ca_certificate" {
|
||||
description = "Apigee organization CA certificate."
|
||||
value = google_apigee_organization.apigee_org.ca_certificate
|
||||
}
|
||||
|
||||
output "org_id" {
|
||||
description = "Apigee Organization ID."
|
||||
value = google_apigee_organization.apigee_org.id
|
||||
}
|
Loading…
Reference in New Issue