-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from baskaran-md/apigee-disable-vpc-peering
Add sample module for Apigee Provisioning without VPC Peering
- Loading branch information
Showing
13 changed files
with
469 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Basic Apigee X Setup without VPC Peering | ||
|
||
A minimal Apigee X setup without using VPC Peering. It also configures the northbound routing through | ||
L7 External LoadBalancer and Private Service Connect's - Network Endpoint Group (PSC NEG). | ||
|
||
Refer to below docs for more information. | ||
|
||
- [Apigee Networking - Non-VPC Peering Option](https://cloud.google.com/apigee/docs/api-platform/get-started/networking-options#non-vpc-peering-architecture-overview) | ||
- [Release Notes](https://cloud.google.com/apigee/docs/release-notes#August_26_2024) | ||
|
||
<!-- BEGIN_SAMPLES_DEFAULT_SETUP_INSTRUCTIONS --> | ||
## Setup Instructions | ||
|
||
Set the project ID where you want your Apigee Organization to be deployed to: | ||
|
||
```sh | ||
PROJECT_ID=my-project-id | ||
``` | ||
|
||
```sh | ||
cd samples/... # Sample from above | ||
cp ./x-demo.tfvars ./my-config.tfvars | ||
``` | ||
|
||
Decide on a [backend](https://www.terraform.io/language/settings/backends) and create the necessary config. To use a backend on Google Cloud Storage (GCS) use: | ||
|
||
```sh | ||
gsutil mb "gs://$PROJECT_ID-tf" | ||
|
||
cat <<EOF >terraform.tf | ||
terraform { | ||
backend "gcs" { | ||
bucket = "$PROJECT_ID-tf" | ||
prefix = "terraform/state" | ||
} | ||
} | ||
EOF | ||
``` | ||
|
||
Validate your config: | ||
|
||
```sh | ||
terraform init | ||
terraform plan --var-file=./my-config.tfvars -var "project_id=$PROJECT_ID" | ||
``` | ||
|
||
and provision everything (takes roughly 25min): | ||
|
||
```sh | ||
terraform apply --var-file=./my-config.tfvars -var "project_id=$PROJECT_ID" | ||
``` | ||
<!-- END_SAMPLES_DEFAULT_SETUP_INSTRUCTIONS --> | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_google"></a> [google](#provider\_google) | n/a | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_apigee-x-core"></a> [apigee-x-core](#module\_apigee-x-core) | ../../modules/apigee-x-core | n/a | | ||
| <a name="module_nb-psc-l7xlb"></a> [nb-psc-l7xlb](#module\_nb-psc-l7xlb) | ../../modules/nb-psc-l7xlb | n/a | | ||
| <a name="module_nip-development-hostname"></a> [nip-development-hostname](#module\_nip-development-hostname) | ../../modules/nip-development-hostname | n/a | | ||
| <a name="module_project"></a> [project](#module\_project) | github.com/terraform-google-modules/cloud-foundation-fabric//modules/project | v28.0.0 | | ||
| <a name="module_psc-ingress-vpc"></a> [psc-ingress-vpc](#module\_psc-ingress-vpc) | github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-vpc | v28.0.0 | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [google_compute_region_network_endpoint_group.psc_neg](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_region_network_endpoint_group) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_apigee_envgroups"></a> [apigee\_envgroups](#input\_apigee\_envgroups) | Apigee Environment Groups. | <pre>map(object({<br> hostnames = list(string)<br> }))</pre> | `null` | no | | ||
| <a name="input_apigee_environments"></a> [apigee\_environments](#input\_apigee\_environments) | Apigee Environments. | <pre>map(object({<br> display_name = optional(string)<br> description = optional(string)<br> node_config = optional(object({<br> min_node_count = optional(number)<br> max_node_count = optional(number)<br> }))<br> iam = optional(map(list(string)))<br> envgroups = list(string)<br> type = optional(string)<br> }))</pre> | `null` | no | | ||
| <a name="input_apigee_instances"></a> [apigee\_instances](#input\_apigee\_instances) | Apigee Instances (only one instance for EVAL orgs). | <pre>map(object({<br> region = string<br> environments = list(string)<br> }))</pre> | `null` | no | | ||
| <a name="input_ax_region"></a> [ax\_region](#input\_ax\_region) | GCP region for storing Apigee analytics data (see https://cloud.google.com/apigee/docs/api-platform/get-started/install-cli). | `string` | n/a | yes | | ||
| <a name="input_billing_account"></a> [billing\_account](#input\_billing\_account) | Billing account id. | `string` | `null` | no | | ||
| <a name="input_project_create"></a> [project\_create](#input\_project\_create) | Create project. When set to false, uses a data source to reference existing project. | `bool` | `false` | no | | ||
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | Project id (also used for the Apigee Organization). | `string` | n/a | yes | | ||
| <a name="input_project_parent"></a> [project\_parent](#input\_project\_parent) | Parent folder or organization in 'folders/folder\_id' or 'organizations/org\_id' format. | `string` | `null` | no | | ||
| <a name="input_psc_ingress_network"></a> [psc\_ingress\_network](#input\_psc\_ingress\_network) | PSC ingress VPC name. | `string` | n/a | yes | | ||
| <a name="input_psc_ingress_subnets"></a> [psc\_ingress\_subnets](#input\_psc\_ingress\_subnets) | Subnets for exposing Apigee services via PSC | <pre>list(object({<br> name = string<br> ip_cidr_range = string<br> region = string<br> secondary_ip_range = map(string)<br> }))</pre> | `[]` | no | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/** | ||
* Copyright 2024 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. | ||
*/ | ||
|
||
module "project" { | ||
source = "github.com/terraform-google-modules/cloud-foundation-fabric//modules/project?ref=v28.0.0" | ||
name = var.project_id | ||
parent = var.project_parent | ||
billing_account = var.billing_account | ||
project_create = var.project_create | ||
services = [ | ||
"apigee.googleapis.com", | ||
"cloudkms.googleapis.com", | ||
"compute.googleapis.com" | ||
] | ||
} | ||
|
||
module "apigee-x-core" { | ||
source = "../../modules/apigee-x-core" | ||
project_id = module.project.project_id | ||
apigee_environments = var.apigee_environments | ||
ax_region = var.ax_region | ||
apigee_envgroups = { | ||
for name, env_group in var.apigee_envgroups : name => { | ||
hostnames = concat(env_group.hostnames, ["${name}.${module.nip-development-hostname.hostname}"]) | ||
} | ||
} | ||
apigee_instances = var.apigee_instances | ||
disable_vpc_peering = true | ||
} | ||
|
||
/** | ||
* Below are the modules required for creating XLB + PSC NEG. | ||
*/ | ||
|
||
locals { | ||
psc_subnet_region_name = { for subnet in var.psc_ingress_subnets : | ||
subnet.region => "${subnet.region}/${subnet.name}" | ||
} | ||
} | ||
|
||
module "nip-development-hostname" { | ||
source = "../../modules/nip-development-hostname" | ||
project_id = module.project.project_id | ||
address_name = "apigee-external" | ||
subdomain_prefixes = [for name, _ in var.apigee_envgroups : name] | ||
} | ||
|
||
module "psc-ingress-vpc" { | ||
source = "github.com/terraform-google-modules/cloud-foundation-fabric//modules/net-vpc?ref=v28.0.0" | ||
project_id = module.project.project_id | ||
name = var.psc_ingress_network | ||
auto_create_subnetworks = false | ||
subnets = var.psc_ingress_subnets | ||
} | ||
|
||
resource "google_compute_region_network_endpoint_group" "psc_neg" { | ||
project = var.project_id | ||
for_each = var.apigee_instances | ||
name = "psc-neg-${each.value.region}" | ||
region = each.value.region | ||
network = module.psc-ingress-vpc.network.id | ||
subnetwork = module.psc-ingress-vpc.subnet_self_links[local.psc_subnet_region_name[each.value.region]] | ||
network_endpoint_type = "PRIVATE_SERVICE_CONNECT" | ||
psc_target_service = module.apigee-x-core.instance_service_attachments[each.value.region] | ||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
module "nb-psc-l7xlb" { | ||
source = "../../modules/nb-psc-l7xlb" | ||
project_id = module.project.project_id | ||
name = "apigee-xlb-psc" | ||
ssl_certificate = [module.nip-development-hostname.ssl_certificate] | ||
external_ip = module.nip-development-hostname.ip_address | ||
psc_negs = [for _, psc_neg in google_compute_region_network_endpoint_group.psc_neg : psc_neg.id] | ||
} |
Oops, something went wrong.