Skip to content

Commit 638841c

Browse files
authored
Rename network load balancer modules (GoogleCloudPlatform#1466)
* update LB modules to new names * update LB modules names * update test paths
1 parent 4b6552a commit 638841c

File tree

106 files changed

+189
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+189
-166
lines changed

CHANGELOG.md

Lines changed: 19 additions & 19 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ Contributors are the engine that keeps Fabric alive so if you were or are planni
77
- [I just found a bug / have a feature request](#i-just-found-a-bug--have-a-feature-request)
88
- [Quick developer workflow](#quick-developer-workflow)
99
- [Developer's handbook](#developers-handbook)
10-
* [The Zen of Fabric](#the-zen-of-fabric)
11-
* [Design principles in action](#design-principles-in-action)
12-
* [FAST stage design](#fast-stage-design)
13-
* [Style guide reference](#style-guide-reference)
14-
* [Interacting with checks and tools](#interacting-with-checks-and-tools)
10+
- [The Zen of Fabric](#the-zen-of-fabric)
11+
- [Design principles in action](#design-principles-in-action)
12+
- [FAST stage design](#fast-stage-design)
13+
- [Style guide reference](#style-guide-reference)
14+
- [Interacting with checks and tools](#interacting-with-checks-and-tools)
1515
- [Using and writing tests](#using-and-writing-tests)
16-
* [Testing via README.md example blocks.](#testing-via-readmemd-example-blocks)
17-
+ [Testing examples against an inventory YAML](#testing-examples-against-an-inventory-yaml)
18-
+ [Using external files](#using-external-files)
19-
+ [Running tests for specific examples](#running-tests-for-specific-examples)
20-
+ [Generating the inventory automatically](#generating-the-inventory-automatically)
21-
+ [Building tests for blueprints](#building-tests-for-blueprints)
22-
* [Testing via `tfvars` and `yaml` (aka `tftest`-based tests)](#testing-via-tfvars-and-yaml-aka-tftest-based-tests)
23-
+ [Generating the inventory for `tftest`-based tests](#generating-the-inventory-for-tftest-based-tests)
24-
* [Writing tests in Python (legacy approach)](#writing-tests-in-python-legacy-approach)
25-
* [Running tests from a temporary directory](#running-tests-from-a-temporary-directory)
16+
- [Testing via README.md example blocks.](#testing-via-readmemd-example-blocks)
17+
- [Testing examples against an inventory YAML](#testing-examples-against-an-inventory-yaml)
18+
- [Using external files](#using-external-files)
19+
- [Running tests for specific examples](#running-tests-for-specific-examples)
20+
- [Generating the inventory automatically](#generating-the-inventory-automatically)
21+
- [Building tests for blueprints](#building-tests-for-blueprints)
22+
- [Testing via `tfvars` and `yaml` (aka `tftest`-based tests)](#testing-via-tfvars-and-yaml-aka-tftest-based-tests)
23+
- [Generating the inventory for `tftest`-based tests](#generating-the-inventory-for-tftest-based-tests)
24+
- [Writing tests in Python (legacy approach)](#writing-tests-in-python-legacy-approach)
25+
- [Running tests from a temporary directory](#running-tests-from-a-temporary-directory)
2626
- [Fabric tools](#fabric-tools)
2727

2828
## I just found a bug / have a feature request
@@ -205,11 +205,11 @@ We have several such interfaces defined for IAM, log sinks, organizational polic
205205
#### Design interfaces to support actual usage
206206

207207
> “When developing a module, look for opportunities to take a little bit of extra suffering upon yourself in order to reduce the suffering of your users.”
208-
>
208+
>
209209
> “Providing choice is good, but interfaces should be designed to make the common case as simple as possible”
210-
>
210+
>
211211
> — John Ousterhout in "A Philosophy of Software Design"
212-
212+
213213
Variables should not simply map to the underlying resource attributes, but their **interfaces should be designed to match common use cases** to reduce friction and offer the highest possible degree of legibility.
214214

215215
This translates into different practical approaches:
@@ -300,7 +300,6 @@ module "project" {
300300
>
301301
> — John Ousterhout in "A Philosophy of Software Design"
302302
303-
304303
Designing variable spaces is one of the most complex aspects to get right, as they are the main entry point through which users consume modules, examples and FAST stages. We always strive to **design small variable spaces by leveraging objects and implementing defaults** so that users can quickly produce highly readable code.
305304

306305
One of many examples of this approach comes from disk support in the `compute-vm` module, where preset defaults allow quick VM management with very few lines of code, and optional variables allow progressively expanding the code when more control is needed.
@@ -688,7 +687,7 @@ In the following sections we describe the three testing approaches we currently
688687
- [tfvars-based tests](#testing-via-tfvars-and-yaml): allows you to test a module or blueprint by providing variables via tfvar files and an expected plan result in form of an inventory. This type of test is useful, for example, for FAST stages that don't have any examples within their READMEs.
689688
- [Python-based (legacy) tests](#writing-tests-in-python--legacy-approach-): in some situations you might still want to interact directly with `tftest` via Python, if that's the case, use this method to write custom Python logic to test your module in any way you see fit.
690689

691-
### Testing via README.md example blocks.
690+
### Testing via README.md example blocks
692691

693692
This is the preferred method to write tests for modules and blueprints. Example-based tests are triggered from [HCL Markdown fenced code blocks](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting) in any file named README.md, hence there's no need to create any additional files or revert to Python to write a test. Most of our documentation examples are using this method.
694693

@@ -795,6 +794,7 @@ module "private-dns" {
795794
}
796795
# tftest modules=1 resources=2 files=records
797796
```
797+
798798
```yaml
799799
# tftest-file id=records path=records/example.yaml
800800
A localhost:
@@ -814,6 +814,7 @@ As mentioned before, we use `pytest` as our test runner, so you can use any of t
814814
Example-based test are named based on the section within the README.md that contains them. You can use this name to select specific tests.
815815

816816
Here we show a few commonly used selection commands:
817+
817818
- Run all examples:
818819
- `pytest tests/examples/`
819820
- Run all examples for modules:
@@ -919,7 +920,7 @@ The second approach to testing requires you to:
919920
- define `yaml` "inventory" files with the plan and output results you want to test
920921
- declare which of these files need to be run as tests in a `tftest.yaml` file
921922

922-
Let's go through each step in succession, assuming you are testing the new `net-glb` module.
923+
Let's go through each step in succession, assuming you are testing the new `net-lb-app-ext` module.
923924

924925
First create a new folder under `tests/modules` replacing any dash in the module name with underscores. Note that if you were testing a blueprint the folder would go in `tests/blueprints`.
925926

@@ -973,7 +974,7 @@ Create as many pairs of `tfvars`/`yaml` files as you need to test every scenario
973974

974975
```yaml
975976
# file: tests/modules/net_glb/tftest.yaml
976-
module: modules/net-glb
977+
module: modules/net-lb-app-ext
977978
# if there are variables shared among all tests you can define a common file
978979
# common_tfvars:
979980
# - defaults.tfvars
@@ -1052,22 +1053,24 @@ You can now use this output to create the inventory file for your test. As menti
10521053
Where possible, we recommend using the testing methods described in the previous sections. However, if you need it, you can still write tests using Python directly.
10531054

10541055
In general, you should try to use the `plan_summary` fixture, which runs a a terraform plan and returns a `PlanSummary` object. The most important arguments to `plan_summary` are:
1056+
10551057
- the path of the Terraform module you want to test, relative to the root of the repository
10561058
- a list of paths representing the tfvars file to pass in to terraform. These paths are relative to the python file defining the test.
10571059

10581060
If successful, `plan_summary` will return a `PlanSummary` object with the `values`, `counts` and `outputs` attributes following the same semantics described in the previous section. You can use this fields to write your custom tests.
10591061

1060-
Like before let's imagine we're writing a (python) test for `net-glb` module. First create a new folder under `tests/modules` replacing any dash in the module name with underscores. You also need to create an empty `__init__.py` file in it, to ensure `pytest` discovers you new tests automatically.
1062+
Like before let's imagine we're writing a (python) test for `net-lb-app-ext` module. First create a new folder under `tests/modules` replacing any dash in the module name with underscores. You also need to create an empty `__init__.py` file in it, to ensure `pytest` discovers you new tests automatically.
10611063

10621064
```bash
10631065
mkdir tests/modules/net_glb
10641066
touch tests/modules/net_glb/__init__.py
10651067
```
10661068

10671069
Now create a file containing your tests, e.g. `test_plan.py`:
1070+
10681071
```python
10691072
def test_name(plan_summary, tfvars_to_yaml, tmp_path):
1070-
s = plan_summary('modules/net-glb', tf_var_files=['test-plan.tfvars'])
1073+
s = plan_summary('modules/net-lb-app-ext', tf_var_files=['test-plan.tfvars'])
10711074
address = 'google_compute_url_map.default'
10721075
assert s.values[address]['project'] == 'my-project'
10731076
```
@@ -1081,16 +1084,19 @@ Most of the time you can run tests using the `pytest` command as described in pr
10811084
To enable this option, just define the environment variable `TFTEST_COPY` and any tests using the `plan_summary` fixture will automatically run from a temporary directory.
10821085

10831086
Running tests from temporary directories is useful if:
1087+
10841088
- you're running tests in parallel using `pytest-xdist`. In this case, just run you tests as follows:
1089+
10851090
```bash
10861091
TFTEST_COPY=1 pytest -n 4
10871092
```
1093+
10881094
- you're running tests for the `fast/` directory which contain tfvars and auto.tfvars files (which are read by terraform automatically) making your tests fail. In this case, you can run
1095+
10891096
```
10901097
TFTEST_COPY=1 pytest fast/
10911098
```
10921099

1093-
10941100
## Fabric tools
10951101

10961102
The main tool you will interact with in development is `tfdoc`, used to generate file, output and variable tables in README documents.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The current list of modules supports most of the core foundational and networkin
3030
Currently available modules:
3131

3232
- **foundational** - [billing budget](./modules/billing-budget), [Cloud Identity group](./modules/cloud-identity-group/), [folder](./modules/folder), [service accounts](./modules/iam-service-account), [logging bucket](./modules/logging-bucket), [organization](./modules/organization), [project](./modules/project), [projects-data-source](./modules/projects-data-source)
33-
- **networking** - [DNS](./modules/dns), [DNS Response Policy](./modules/dns-response-policy/), [Cloud Endpoints](./modules/endpoints), [address reservation](./modules/net-address), [NAT](./modules/net-cloudnat), [VLAN Attachment](./modules/net-vlan-attachment/), [Global Load Balancer (classic)](./modules/net-glb/), [L4 ILB](./modules/net-ilb), [L7 ILB](./modules/net-ilb-l7), [IPSec over Interconnect](./modules/net-ipsec-over-interconnect), [Network LB](./modules/net-nlb), [VPC](./modules/net-vpc), [VPC firewall](./modules/net-vpc-firewall), [VPC firewall policy](./modules/net-vpc-firewall-policy), [VPC peering](./modules/net-vpc-peering), [VPN dynamic](./modules/net-vpn-dynamic), [HA VPN](./modules/net-vpn-ha), [VPN static](./modules/net-vpn-static), [Service Directory](./modules/service-directory)
33+
- **networking** - [DNS](./modules/dns), [DNS Response Policy](./modules/dns-response-policy/), [Cloud Endpoints](./modules/endpoints), [address reservation](./modules/net-address), [NAT](./modules/net-cloudnat), [VLAN Attachment](./modules/net-vlan-attachment/), [External Application LB](./modules/net-lb-app-ext/), [External Network Passthrough LB](./modules/net-lb-ext), [Internal Application LB](./modules/net-lb-app-int), [Internal Network Passthrough LB](./modules/net-lb-int), [IPSec over Interconnect](./modules/net-ipsec-over-interconnect), [VPC](./modules/net-vpc), [VPC firewall](./modules/net-vpc-firewall), [VPC firewall policy](./modules/net-vpc-firewall-policy), [VPC peering](./modules/net-vpc-peering), [VPN dynamic](./modules/net-vpn-dynamic), [HA VPN](./modules/net-vpn-ha), [VPN static](./modules/net-vpn-static), [Service Directory](./modules/service-directory)
3434
- **compute** - [VM/VM group](./modules/compute-vm), [MIG](./modules/compute-mig), [COS container](./modules/cloud-config-container/cos-generic-metadata/) (coredns, mysql, onprem, squid), [GKE cluster](./modules/gke-cluster-standard), [GKE hub](./modules/gke-hub), [GKE nodepool](./modules/gke-nodepool)
3535
- **data** - [AlloyDB instance](./modules/alloydb-instance), [BigQuery dataset](./modules/bigquery-dataset), [Bigtable instance](./modules/bigtable-instance), [Cloud Dataplex](./modules/cloud-dataplex), [Cloud SQL instance](./modules/cloudsql-instance), [Data Catalog Policy Tag](./modules/data-catalog-policy-tag), [Datafusion](./modules/datafusion), [Dataproc](./modules/dataproc), [GCS](./modules/gcs), [Pub/Sub](./modules/pubsub)
3636
- **development** - [API Gateway](./modules/api-gateway), [Apigee](./modules/apigee), [Artifact Registry](./modules/artifact-registry), [Container Registry](./modules/container-registry), [Cloud Source Repository](./modules/source-repository)

blueprints/apigee/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ The blueprints in this folder contain a variety of deployment scenarios for Apig
2020

2121
The following blueprints demonstrate a set of networking scenarios that can be implemented for Apigee X deployments.
2222

23-
#### Apigee X - Northbound: GLB with PSC Neg, Southbouth: PSC with ILB (L7) and Hybrid NEG
24-
<a href="./network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg" title="Apigee X - Northbound: GLB with PSC Neg, Southbouth: PSC with ILB (L7) and Hybrid NEG"><img src="./network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/diagram.png" align="left" width="280px"></a>This [blueprint](./network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/) shows how to expose an on-prem target backend to clients in the Internet.
23+
#### Apigee X - Northbound: External Application LB with PSC Neg, Southbouth: PSC with Internal Application LB and Hybrid NEG
24+
25+
<a href="./network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg" title="Northbound: External Application LB with PSC Neg, Southbouth: PSC with Internal Application LB and Hybrid NEG"><img src="./network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/diagram.png" align="left" width="280px"></a>This [blueprint](./network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/) shows how to expose an on-prem target backend to clients in the Internet.

blueprints/apigee/bigquery-analytics/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module "apigee" {
8888
}
8989

9090
module "glb" {
91-
source = "../../../modules/net-glb"
91+
source = "../../../modules/net-lb-app-ext"
9292
name = "glb"
9393
project_id = module.project.project_id
9494
protocol = "HTTPS"

blueprints/apigee/network-patterns/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
The blueprints in this folder demonstrate a set of networking scenarios that can be implemented for Apigee X deployments.
44

5-
## Apigee X - Northbound: GLB with PSC Neg, Southbouth: PSC with ILB (L7) and Hybrid NEG
6-
<a href="./nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg" title="Apigee X - Northbound: GLB with PSC Neg, Southbouth: PSC with ILB (L7) and Hybrid NEG"><img src="./nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/diagram.png" align="left" width="280px"></a>This [blueprint](./nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/) shows how to expose an on-prem target backend to clients in the Internet.g
5+
## Northbound: External Application LB with PSC Neg, Southbouth: PSC with Internal Application LB and Hybrid NEG
6+
7+
<a href="./nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg" title="Northbound: External Application LB with PSC Neg, Southbouth: PSC with Internal Application LB and Hybrid NEG"><img src="./nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/diagram.png" align="left" width="280px"></a>This [blueprint](./nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/) shows how to expose an on-prem target backend to clients in the Internet.g

blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Apigee X - Northbound GLB with PSC Neg, Southbouth PSC with ILB (L7) and Hybrid NEG
1+
# Apigee X - Northbound: External Application LB with PSC Neg, Southbouth: PSC with Internal Application LB and Hybrid NEG
22

33
The following blueprint shows how to expose an on-prem target backend to clients in the Internet.
44

blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee_nb.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
module "glb" {
18-
source = "../../../../modules/net-glb"
18+
source = "../../../../modules/net-lb-app-ext"
1919
name = "glb"
2020
project_id = module.apigee_project.project_id
2121
protocol = "HTTPS"

blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/apigee_sb.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
module "apigee_ilb_l7" {
18-
source = "../../../../modules/net-ilb-l7"
18+
source = "../../../../modules/net-lb-app-int"
1919
name = "apigee-ilb"
2020
project_id = module.apigee_project.project_id
2121
region = var.region

blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg/onprem.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ module "mig" {
116116
}
117117

118118
module "onprem_ilb_l7" {
119-
source = "../../../../modules/net-ilb-l7"
119+
source = "../../../../modules/net-lb-app-int"
120120
name = "ilb"
121121
project_id = module.onprem_project.project_id
122122
region = var.region

0 commit comments

Comments
 (0)