-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved apigee bigquery analytics blueprint, added apigee network patterns
- Loading branch information
Showing
45 changed files
with
887 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Apigee Examples | ||
|
||
This repository contains the following Apigee examples: | ||
|
||
* [Apigee BigQuery analytics](./bigquery-analytics/README.md) | ||
* Apigee network patterns | ||
* [Apigee X - Northbound GLB with PSC Neg, Southbouth PSC with ILB (L7) and Hybrid NEG | ||
](./network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/README.md) |
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
...operations/apigee/terraform.tfvars.sample → ...igquery-analytics/terraform.tfvars.sample
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
File renamed without changes.
File renamed without changes.
68 changes: 68 additions & 0 deletions
68
...prints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/README.md
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,68 @@ | ||
# Apigee X - Northbound GLB with PSC Neg, Southbouth PSC with ILB (L7) and Hybrid NEG | ||
|
||
The following example shows how to expose an on-prem target backend to clients in the internet. | ||
|
||
The architecture is the one depicted below. | ||
|
||
![Diagram](diagram.png) | ||
|
||
To emulate an service deployed on-premise, we have used a managed instance group of instances running Nginx exposed via a regional internalload balancer (L7). The service is accesible through VPN. | ||
|
||
## Running the blueprint | ||
|
||
1. Clone this repository or [open it in cloud shell](https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fcloud-foundation-fabric&cloudshell_print=cloud-shell-readme.txt&cloudshell_working_dir=blueprints%2F%apigee%2F/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg), then go through the following steps to create resources: | ||
|
||
2. Copy the file [terraform.tfvars.sample](./terraform.tfvars.sample) to a file called ```terraform.tfvars``` and update the values if required. | ||
|
||
3. Initialize the terraform configuration | ||
|
||
```terraform init``` | ||
|
||
4. Apply the terraform configuration | ||
|
||
```terraform apply``` | ||
|
||
Once the resources have been created, do the following: | ||
|
||
Create an A record in your DNS registrar to point the environment group hostname to the public IP address returned after the terraform configuration was applied. You might need to wait some time until the certificate is provisioned. | ||
|
||
## Testing the blueprint | ||
|
||
Do the following to verify that everything works as expected. | ||
|
||
1. Deploy the API proxy | ||
|
||
./deploy-apiproxy.sh | ||
|
||
2. Send a request | ||
|
||
curl -v https://HOSTNAME/test/ | ||
|
||
You should get back an HTTP 200 OK response. | ||
<!-- BEGIN TFDOC --> | ||
|
||
## Variables | ||
|
||
| name | description | type | required | default | | ||
|---|---|:---:|:---:|:---:| | ||
| [apigee_project_id](variables.tf#L17) | Project ID. | <code>string</code> | ✓ | | | ||
| [billing_account_id](variables.tf#L47) | Parameters for the creation of the new project. | <code>string</code> | ✓ | | | ||
| [hostname](variables.tf#L52) | Host name. | <code>string</code> | ✓ | | | ||
| [onprem_project_id](variables.tf#L57) | Project ID. | <code>string</code> | ✓ | | | ||
| [parent](variables.tf#L75) | Parent (organizations/organizationID or folders/folderID). | <code>string</code> | ✓ | | | ||
| [apigee_proxy_only_subnet_ip_cidr_range](variables.tf#L23) | Subnet IP CIDR range. | <code>string</code> | | <code>"10.2.1.0/24"</code> | | ||
| [apigee_psa_ip_cidr_range](variables.tf#L29) | Apigee PSA IP CIDR range. | <code>string</code> | | <code>"10.0.4.0/22"</code> | | ||
| [apigee_psc_subnet_ip_cidr_range](variables.tf#L35) | Subnet IP CIDR range. | <code>string</code> | | <code>"10.2.2.0/24"</code> | | ||
| [apigee_subnet_ip_cidr_range](variables.tf#L41) | Subnet IP CIDR range. | <code>string</code> | | <code>"10.2.0.0/24"</code> | | ||
| [onprem_proxy_only_subnet_ip_cidr_range](variables.tf#L63) | Subnet IP CIDR range. | <code>string</code> | | <code>"10.1.1.0/24"</code> | | ||
| [onprem_subnet_ip_cidr_range](variables.tf#L69) | Subnet IP CIDR range. | <code>string</code> | | <code>"10.1.0.0/24"</code> | | ||
| [region](variables.tf#L80) | Region. | <code>string</code> | | <code>"europe-west1"</code> | | ||
| [zone](variables.tf#L86) | Zone. | <code>string</code> | | <code>"europe-west1-c"</code> | | ||
|
||
## Outputs | ||
|
||
| name | description | sensitive | | ||
|---|---|:---:| | ||
| [ip_address](outputs.tf#L17) | GLB IP address. | | | ||
|
||
<!-- END TFDOC --> |
96 changes: 96 additions & 0 deletions
96
blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee.tf
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,96 @@ | ||
/** | ||
* Copyright 2022 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. | ||
*/ | ||
|
||
locals { | ||
envgroup = "test" | ||
environment = "apis-test" | ||
} | ||
|
||
module "apigee_project" { | ||
source = "../../../../modules/project" | ||
billing_account = var.billing_account_id | ||
parent = var.parent | ||
name = var.apigee_project_id | ||
services = [ | ||
"apigee.googleapis.com", | ||
"compute.googleapis.com", | ||
"servicenetworking.googleapis.com", | ||
] | ||
} | ||
|
||
module "apigee_vpc" { | ||
source = "../../../../modules/net-vpc" | ||
project_id = module.apigee_project.project_id | ||
name = "vpc" | ||
subnets_proxy_only = [ | ||
{ | ||
ip_cidr_range = var.apigee_proxy_only_subnet_ip_cidr_range | ||
name = "regional-proxy" | ||
region = var.region | ||
active = true | ||
} | ||
] | ||
subnets = [ | ||
{ | ||
ip_cidr_range = var.apigee_subnet_ip_cidr_range | ||
name = "subnet" | ||
region = var.region | ||
} | ||
] | ||
subnets_psc = [{ | ||
ip_cidr_range = var.apigee_psc_subnet_ip_cidr_range | ||
name = "subnet-psc" | ||
region = var.region | ||
}] | ||
psa_config = { | ||
ranges = { | ||
"apigee" = var.apigee_psa_ip_cidr_range | ||
} | ||
} | ||
} | ||
|
||
module "apigee" { | ||
source = "../../../../modules/apigee" | ||
project_id = module.apigee_project.project_id | ||
organization = { | ||
authorized_network = module.apigee_vpc.network.name | ||
analytics_region = var.region | ||
} | ||
envgroups = { | ||
(local.envgroup) = [var.hostname] | ||
} | ||
environments = { | ||
(local.environment) = { | ||
envgroups = [local.envgroup] | ||
} | ||
} | ||
instances = { | ||
instance-1 = { | ||
region = var.region | ||
environments = [local.environment] | ||
psa_ip_cidr_range = var.apigee_psa_ip_cidr_range | ||
} | ||
} | ||
endpoint_attachments = { | ||
backend = { | ||
region = var.region | ||
service_attachment = google_compute_service_attachment.service_attachment.id | ||
} | ||
} | ||
depends_on = [ | ||
module.apigee_vpc | ||
] | ||
} |
50 changes: 50 additions & 0 deletions
50
blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee_nb.tf
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,50 @@ | ||
/** | ||
* Copyright 2022 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 "glb" { | ||
source = "../../../../modules/net-glb" | ||
name = "glb" | ||
project_id = module.apigee_project.project_id | ||
protocol = "HTTPS" | ||
use_classic_version = false | ||
backend_service_configs = { | ||
default = { | ||
backends = [{ backend = "neg-0" }] | ||
protocol = "HTTPS" | ||
health_checks = [] | ||
} | ||
} | ||
neg_configs = { | ||
neg-0 = { | ||
psc = { | ||
region = var.region | ||
target_service = module.apigee.instances["instance-1"].service_attachment | ||
network = module.apigee_vpc.network.self_link | ||
subnetwork = ( | ||
module.apigee_vpc.subnets_psc["${var.region}/subnet-psc"].self_link | ||
) | ||
} | ||
} | ||
} | ||
ssl_certificates = { | ||
managed_configs = { | ||
default = { | ||
domains = [var.hostname] | ||
} | ||
} | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee_sb.tf
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,68 @@ | ||
/** | ||
* Copyright 2022 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 "apigee_ilb_l7" { | ||
source = "../../../../modules/net-ilb-l7" | ||
name = "apigee-ilb" | ||
project_id = module.apigee_project.project_id | ||
region = var.region | ||
backend_service_configs = { | ||
default = { | ||
backends = [{ | ||
balancing_mode = "RATE" | ||
group = "my-neg" | ||
max_rate = { per_endpoint = 1 } | ||
}] | ||
} | ||
} | ||
neg_configs = { | ||
my-neg = { | ||
hybrid = { | ||
zone = var.zone | ||
endpoints = { | ||
e-0 = { | ||
ip_address = module.onprem_ilb_l7.address | ||
port = 80 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
health_check_configs = { | ||
default = { | ||
http = { | ||
port = 80 | ||
} | ||
} | ||
} | ||
vpc_config = { | ||
network = module.apigee_vpc.self_link | ||
subnetwork = module.apigee_vpc.subnet_self_links["${var.region}/subnet"] | ||
} | ||
depends_on = [ | ||
module.apigee_vpc.subnets_proxy_only | ||
] | ||
} | ||
|
||
resource "google_compute_service_attachment" "service_attachment" { | ||
name = "service-attachment" | ||
project = module.apigee_project.project_id | ||
region = var.region | ||
enable_proxy_protocol = false | ||
connection_preference = "ACCEPT_AUTOMATIC" | ||
nat_subnets = [module.apigee_vpc.subnets_psc["${var.region}/subnet-psc"].self_link] | ||
target_service = module.apigee_ilb_l7.forwarding_rule.id | ||
} |
41 changes: 41 additions & 0 deletions
41
blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apiproxy.tf
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,41 @@ | ||
/** | ||
* Copyright 2022 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 "local_file" "target_endpoint_file" { | ||
content = templatefile("${path.module}/templates/targets/default.xml.tpl", { | ||
ip_address = module.apigee.endpoint_attachment_hosts["backend"] | ||
}) | ||
filename = "${path.module}/bundle/apiproxy/targets/default.xml" | ||
file_permission = "0777" | ||
} | ||
|
||
data "archive_file" "bundle" { | ||
type = "zip" | ||
source_dir = "${path.module}/bundle" | ||
output_path = "${path.module}/bundle.zip" | ||
depends_on = [ | ||
local_file.target_endpoint_file | ||
] | ||
} | ||
|
||
resource "local_file" "deploy_apiproxy_file" { | ||
content = templatefile("${path.module}/templates/deploy-apiproxy.sh.tpl", { | ||
organization = module.apigee.org_name | ||
environment = local.environment | ||
}) | ||
filename = "${path.module}/deploy-apiproxy.sh" | ||
file_permission = "0777" | ||
} |
18 changes: 18 additions & 0 deletions
18
...twork-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/bundle/apiproxy/proxies/default.xml
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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<ProxyEndpoint name="default"> | ||
<PreFlow name="PreFlow"> | ||
<Request/> | ||
<Response/> | ||
</PreFlow> | ||
<Flows/> | ||
<PostFlow name="PostFlow"> | ||
<Request/> | ||
<Response/> | ||
</PostFlow> | ||
<HTTPProxyConnection> | ||
<BasePath>/test</BasePath> | ||
</HTTPProxyConnection> | ||
<RouteRule name="default"> | ||
<TargetEndpoint>default</TargetEndpoint> | ||
</RouteRule> | ||
</ProxyEndpoint> |
10 changes: 10 additions & 0 deletions
10
...s/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/bundle/apiproxy/test.xml
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<APIProxy revision="1" name="test"> | ||
<BasePaths>/test</BasePaths> | ||
<ProxyEndpoints> | ||
<ProxyEndpoint>default</ProxyEndpoint> | ||
</ProxyEndpoints> | ||
<TargetEndpoints> | ||
<TargetEndpoint>default</TargetEndpoint> | ||
</TargetEndpoints> | ||
</APIProxy> |
Binary file added
BIN
+49.2 KB
...ints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.