Skip to content

Commit

Permalink
Rename lb-http-backend to backend and similar for frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
q2w committed Oct 29, 2024
1 parent 1c3069b commit 2cdb8e6
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 95 deletions.
8 changes: 2 additions & 6 deletions examples/lb-http-separate-frontend-and-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

[![button](http://gstatic.com/cloudssh/images/open-btn.png)](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/terraform-google-lb-http&working_dir=examples/lb-http-separate-frontend-and-backend&page=shell&tutorial=README.md)

This example creates a global HTTP forwarding rule to forward traffic to instance groups in the us-west1 and us-east1 regions. The `google_compute_backend_service` and its dependencies are created as part of `lb-http-backend` module.
The forwarding rules and its dependecies are created as part of `lb-http-frontend` modules.
This example creates a global HTTP forwarding rule to forward traffic to instance groups in the us-west1 and us-east1 regions. The `google_compute_backend_service` and its dependencies are created as part of `backend` module.
The forwarding rules and its dependecies are created as part of `frontend` modules.

## Change to the example directory

Expand Down Expand Up @@ -83,11 +83,7 @@ terraform destroy

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| group1\_region | n/a | `string` | `"us-west1"` | no |
| group2\_region | n/a | `string` | `"us-east1"` | no |
| network\_prefix | n/a | `string` | `"lb-http-separate-frontend-and-backend"` | no |
| project\_id | n/a | `string` | n/a | yes |
| target\_size | n/a | `number` | `2` | no |

## Outputs

Expand Down
36 changes: 18 additions & 18 deletions examples/lb-http-separate-frontend-and-backend/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2017 Google LLC
* 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.
Expand All @@ -15,67 +15,67 @@
*/

resource "google_compute_network" "default" {
name = var.network_prefix
name = "lb-http-separate-frontend-and-backend"
auto_create_subnetworks = "false"
}

resource "google_compute_subnetwork" "group1" {
name = "${var.network_prefix}-group1"
name = "lb-http-separate-frontend-and-backend-group1"
ip_cidr_range = "10.126.0.0/20"
network = google_compute_network.default.self_link
region = var.group1_region
region = "us-west1"
private_ip_google_access = true
}

# Router and Cloud NAT are required for installing packages from repos (apache, php etc)
resource "google_compute_router" "group1" {
name = "${var.network_prefix}-gw-group1"
name = "lb-http-separate-frontend-and-backend-gw-group1"
network = google_compute_network.default.self_link
region = var.group1_region
region = "us-west1"
}

module "cloud-nat-group1" {
source = "terraform-google-modules/cloud-nat/google"
version = "~> 5.0"
router = google_compute_router.group1.name
project_id = var.project_id
region = var.group1_region
name = "${var.network_prefix}-cloud-nat-group1"
region = "us-west1"
name = "lb-http-separate-frontend-and-backend-cloud-nat-group1"
}

resource "google_compute_subnetwork" "group2" {
name = "${var.network_prefix}-group2"
name = "lb-http-separate-frontend-and-backend-group2"
ip_cidr_range = "10.127.0.0/20"
network = google_compute_network.default.self_link
region = var.group2_region
region = "us-east1"
private_ip_google_access = true
}

# Router and Cloud NAT are required for installing packages from repos (apache, php etc)
resource "google_compute_router" "group2" {
name = "${var.network_prefix}-gw-group2"
name = "lb-http-separate-frontend-and-backend-gw-group2"
network = google_compute_network.default.self_link
region = var.group2_region
region = "us-east1"
}

module "cloud-nat-group2" {
source = "terraform-google-modules/cloud-nat/google"
version = "~> 5.0"
router = google_compute_router.group2.name
project_id = var.project_id
region = var.group2_region
name = "${var.network_prefix}-cloud-nat-group2"
region = "us-east1"
name = "lb-http-separate-frontend-and-backend-cloud-nat-group2"
}

module "lb-http-backend" {
source = "terraform-google-modules/lb-http/google//modules/lb-http-backend"
source = "terraform-google-modules/lb-http/google//modules/backend"
version = "~> 12.0"
project_id = var.project_id
name = "backend-lb"
target_tags = [
"${var.network_prefix}-group1",
"lb-http-separate-frontend-and-backend-group1",
module.cloud-nat-group1.router_name,
"${var.network_prefix}-group2",
"lb-http-separate-frontend-and-backend-group2",
module.cloud-nat-group2.router_name
]
firewall_networks = [google_compute_network.default.name]
Expand Down Expand Up @@ -109,7 +109,7 @@ module "lb-http-backend" {
}

module "lb-http-frontend" {
source = "terraform-google-modules/lb-http/google//modules/lb-http-frontend"
source = "terraform-google-modules/lb-http/google//modules/frontend"
version = "~> 12.0"
project_id = var.project_id
name = "frontend-lb"
Expand Down
22 changes: 11 additions & 11 deletions examples/lb-http-separate-frontend-and-backend/mig.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2017 Google LLC
* 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.
Expand Down Expand Up @@ -39,12 +39,12 @@ module "mig1_template" {
email = ""
scopes = ["cloud-platform"]
}
name_prefix = "${var.network_prefix}-group1"
name_prefix = "lb-http-separate-frontend-and-backend-group1"
startup_script = data.template_file.group-startup-script.rendered
source_image_family = "ubuntu-2004-lts"
source_image_project = "ubuntu-os-cloud"
tags = [
"${var.network_prefix}-group1",
"lb-http-separate-frontend-and-backend-group1",
module.cloud-nat-group1.router_name
]
}
Expand All @@ -53,9 +53,9 @@ module "mig1" {
source = "terraform-google-modules/vm/google//modules/mig"
version = "~> 12.0"
instance_template = module.mig1_template.self_link
region = var.group1_region
hostname = "${var.network_prefix}-group1"
target_size = var.target_size
region = "us-west1"
hostname = "lb-http-separate-frontend-and-backend-group1"
target_size = 2
named_ports = [{
name = "http",
port = 80
Expand All @@ -71,10 +71,10 @@ module "mig2_template" {
email = ""
scopes = ["cloud-platform"]
}
name_prefix = "${var.network_prefix}-group2"
name_prefix = "lb-http-separate-frontend-and-backend-group2"
startup_script = data.template_file.group-startup-script.rendered
tags = [
"${var.network_prefix}-group2",
"lb-http-separate-frontend-and-backend-group2",
module.cloud-nat-group2.router_name
]
}
Expand All @@ -83,9 +83,9 @@ module "mig2" {
source = "terraform-google-modules/vm/google//modules/mig"
version = "~> 12.0"
instance_template = module.mig2_template.self_link
region = var.group2_region
hostname = "${var.network_prefix}-group2"
target_size = var.target_size
region = "us-east1"
hostname = "lb-http-separate-frontend-and-backend-group2"
target_size = 2
named_ports = [{
name = "http",
port = 80
Expand Down
2 changes: 1 addition & 1 deletion examples/lb-http-separate-frontend-and-backend/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019 Google LLC
* 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.
Expand Down
22 changes: 1 addition & 21 deletions examples/lb-http-separate-frontend-and-backend/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019 Google LLC
* 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.
Expand All @@ -17,23 +17,3 @@
variable "project_id" {
type = string
}

variable "target_size" {
type = number
default = 2
}

variable "group1_region" {
type = string
default = "us-west1"
}

variable "group2_region" {
type = string
default = "us-east1"
}

variable "network_prefix" {
type = string
default = "lb-http-separate-frontend-and-backend"
}
2 changes: 1 addition & 1 deletion examples/lb-http-separate-frontend-and-backend/versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2020 Google LLC
* 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.
Expand Down
10 changes: 6 additions & 4 deletions metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ spec:
description: {}
content:
subBlueprints:
- name: backend
location: modules/backend
- name: dynamic_backends
location: modules/dynamic_backends
- name: lb-http-backend
location: modules/lb-http-backend
- name: lb-http-frontend
location: modules/lb-http-frontend
- name: frontend
location: modules/frontend
- name: serverless_negs
location: modules/serverless_negs
examples:
Expand All @@ -58,6 +58,8 @@ spec:
location: examples/https-gke
- name: https-redirect
location: examples/https-redirect
- name: lb-http-separate-frontend-and-backend
location: examples/lb-http-separate-frontend-and-backend
- name: mig-nat-http-lb
location: examples/mig-nat-http-lb
- name: multi-backend-multi-mig-bucket-https-lb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# HTTP Load balancer backend module
This module creates `google_compute_backend_service` resource and its dependencies. This module can be used with `modules/lb-http-frontend`. The separation of the modules makes it easier for creating backend and frontend resources independent of each other. The logical separation helps in improved maintainability.
This module creates `google_compute_backend_service` resource and its dependencies. This module can be used with `modules/frontend`. The separation of the modules makes it easier for creating backend and frontend resources independent of each other. The logical separation helps in improved maintainability.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintMetadata
metadata:
name: terraform-google-lb-http-lb-http-backend-display
name: terraform-google-lb-http-backend-display
annotations:
config.kubernetes.io/local-config: "true"
spec:
Expand All @@ -24,7 +24,7 @@ spec:
source:
repo: https://github.com/terraform-google-modules/terraform-google-lb-http.git
sourceType: git
dir: /modules/lb-http-backend
dir: /modules/backend
ui:
input:
variables:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintMetadata
metadata:
name: terraform-google-lb-http-lb-http-backend
name: terraform-google-lb-http-backend
annotations:
config.kubernetes.io/local-config: "true"
spec:
Expand All @@ -24,7 +24,7 @@ spec:
source:
repo: https://github.com/terraform-google-modules/terraform-google-lb-http.git
sourceType: git
dir: /modules/lb-http-backend
dir: /modules/backend
version: 12.0.0
actuationTool:
flavor: Terraform
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* 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.
Expand Down Expand Up @@ -33,11 +33,11 @@ terraform {
}

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-lb-http:lb-http-backend/v12.0.0"
module_name = "blueprints/terraform/terraform-google-lb-http:backend/v12.0.0"
}

provider_meta "google-beta" {
module_name = "blueprints/terraform/terraform-google-lb-http:lb-http-backend/v12.0.0"
module_name = "blueprints/terraform/terraform-google-lb-http:backend/v12.0.0"
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# HTTP Load balancer frontend module
This module creates `HTTP(S) forwarding rule` and its dependencies. This modules doesn't create `google_compute_backend_service` which can be created by using `modules/lb-http-frontend`. The separation of the modules makes it easier for creating backend and frontend resources independent of each other. The logical separation helps in improved maintainability.
This module creates `HTTP(S) forwarding rule` and its dependencies. This modules doesn't create `google_compute_backend_service` which can be created by using `modules/frontend`. The separation of the modules makes it easier for creating backend and frontend resources independent of each other. The logical separation helps in improved maintainability.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintMetadata
metadata:
name: terraform-google-lb-http-lb-http-frontend-display
name: terraform-google-lb-http-frontend-display
annotations:
config.kubernetes.io/local-config: "true"
spec:
Expand All @@ -24,7 +24,7 @@ spec:
source:
repo: https://github.com/terraform-google-modules/terraform-google-lb-http.git
sourceType: git
dir: /modules/lb-http-frontend
dir: /modules/frontend
ui:
input:
variables:
Expand All @@ -49,9 +49,6 @@ spec:
create_url_map:
name: create_url_map
title: Create Url Map
edge_security_policy:
name: edge_security_policy
title: Edge Security Policy
enable_ipv6:
name: enable_ipv6
title: Enable Ipv6
Expand Down Expand Up @@ -100,9 +97,6 @@ spec:
random_certificate_suffix:
name: random_certificate_suffix
title: Random Certificate Suffix
security_policy:
name: security_policy
title: Security Policy
server_tls_policy:
name: server_tls_policy
title: Server Tls Policy
Expand Down
Loading

0 comments on commit 2cdb8e6

Please sign in to comment.