Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test documentation examples in the examples/ folder #794

Merged
merged 1 commit into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ You can easily configure the example for this use case:
delegated_role_grants = ["roles/compute.networkUser"]
direct_role_grants = []
restricted_role_grant = "roles/compute.networkAdmin"
# tftest skip
```

This diagram shows the resources and expected behaviour:
Expand Down
24 changes: 21 additions & 3 deletions examples/data-solutions/data-platform-foundations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ We suggest a centralized approach to key management, where Organization Security

To configure the use of Cloud KMS on resources, you have to specify the key id on the `service_encryption_keys` variable. Key locations should match resource locations. Example:

```hcl
```tfvars
service_encryption_keys = {
bq = "KEY_URL_MULTIREGIONAL"
composer = "KEY_URL_REGIONAL"
dataflow = "KEY_URL_REGIONAL"
storage = "KEY_URL_MULTIREGIONAL"
pubsub = "KEY_URL_MULTIREGIONAL"
}
# tftest skip
```

This step is optional and depends on customer policies and security best practices.
Expand Down Expand Up @@ -191,12 +192,13 @@ The Data Platform is meant to be executed by a Service Account (or a regular use

There are three sets of variables you will need to fill in:

```hcl
```tfvars
billing_account_id = "111111-222222-333333"
older_id = "folders/123456789012"
organization_domain = "domain.com"
prefix = "myco"
```
# tftest skip`
``

For more fine details check variables on [`variables.tf`](./variables.tf) and update according to the desired configuration. Remember to create team groups described [below](#groups).

Expand All @@ -207,6 +209,22 @@ terraform init
terraform apply
```

## How to use this example from Terraform

While this example can be used as a standalone deployment, it can also be called directly as a Terraform module by providing the variables values as show below:

```hcl
module "data-platform" {
source = "./fabric/examples/data-solutions/data-platform-foundations"
billing_account_id = var.billing_account_id
folder_id = var.folder_id
organization_domain = "example.com"
prefix = "myprefix"
}

# tftest modules=1 resources=1
```

## Customizations

### Create Cloud Key Management keys as part of the Data Platform
Expand Down
2 changes: 2 additions & 0 deletions examples/factories/project-factory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ module "projects" {
services_iam = try(each.value.services_iam, {})
vpc = try(each.value.vpc, null)
}

# tftest skip
```

### Projects configuration
Expand Down
2 changes: 1 addition & 1 deletion examples/networking/hub-and-spoke-peering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The example configures the peering with the GKE master VPC to export routes for

Change the GKE cluster module and add a new variable after `private_cluster_config`:

```hcl
```tfvars
peering_config = {
export_routes = true
import_routes = false
Expand Down
2 changes: 2 additions & 0 deletions examples/networking/hub-and-spoke-vpn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ module "project" {
disable_dependent_services = false
}
}

# tftest skip
```

## Testing
Expand Down
2 changes: 1 addition & 1 deletion modules/__experimental/net-dns-policy-address/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Since it's currently impossible to fetch those addresses using a GCP data source

```hcl
module "dns-policy-addresses" {
source = "./modules/__experimental/net-dns-policy-addresses"
source = "./fabric/modules/__experimental/net-dns-policy-addresses"
project_id = "myproject"
regions = ["europe-west1", "europe-west3"]
}
Expand Down
2 changes: 1 addition & 1 deletion modules/__experimental/net-neg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Note: this module will integrated into a general-purpose load balancing module i
## Example
```hcl
module "neg" {
source = "./modules/net-neg"
source = "./fabric/modules/net-neg"
project_id = "myproject"
name = "myneg"
network = module.vpc.self_link
Expand Down
6 changes: 3 additions & 3 deletions modules/api-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This module allows creating an API with its associated API config and API gatewa
## Basic example
```hcl
module "gateway" {
source = "./modules/api-gateway"
source = "./fabric/modules/api-gateway"
project_id = "my-project"
api_id = "api"
region = "europe-west1"
Expand All @@ -21,7 +21,7 @@ module "gateway" {
## Basic example + customer service account
```hcl
module "gateway" {
source = "./modules/api-gateway"
source = "./fabric/modules/api-gateway"
project_id = "my-project"
api_id = "api"
region = "europe-west1"
Expand All @@ -40,7 +40,7 @@ module "gateway" {
## Basic example + service account creation
```hcl
module "gateway" {
source = "./modules/api-gateway"
source = "./fabric/modules/api-gateway"
project_id = "my-project"
api_id = "api"
region = "europe-west1"
Expand Down
6 changes: 3 additions & 3 deletions modules/apigee-organization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This module allows managing a single Apigee organization and its environments an

```hcl
module "apigee-organization" {
source = "./modules/apigee-organization"
source = "./fabric/modules/apigee-organization"
project_id = "my-project"
analytics_region = "us-central1"
runtime_type = "CLOUD"
Expand Down Expand Up @@ -36,7 +36,7 @@ module "apigee-organization" {

```hcl
module "apigee-organization" {
source = "./modules/apigee-organization"
source = "./fabric/modules/apigee-organization"
project_id = "my-project"
analytics_region = "us-central1"
runtime_type = "CLOUD"
Expand Down Expand Up @@ -76,7 +76,7 @@ module "apigee-organization" {

```hcl
module "apigee-organization" {
source = "./modules/apigee-organization"
source = "./fabric/modules/apigee-organization"
project_id = "my-project"
analytics_region = "us-central1"
runtime_type = "HYBRID"
Expand Down
4 changes: 2 additions & 2 deletions modules/apigee-x-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This module allows managing a single Apigee X instance and its environment attac

```hcl
module "apigee-x-instance" {
source = "./modules/apigee-x-instance"
source = "./fabric/modules/apigee-x-instance"
name = "my-us-instance"
region = "us-central1"
ip_range = "10.0.0.0/22"
Expand All @@ -26,7 +26,7 @@ module "apigee-x-instance" {

```hcl
module "apigee-x-instance" {
source = "./modules/apigee-x-instance"
source = "./fabric/modules/apigee-x-instance"
name = "my-us-instance"
region = "us-central1"
ip_range = "10.0.0.0/22"
Expand Down
2 changes: 1 addition & 1 deletion modules/artifact-registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Note: Artifact Registry is still in beta, hence this module currently uses the b

```hcl
module "docker_artifact_registry" {
source = "./modules/artifact-registry"
source = "./fabric/modules/artifact-registry"
project_id = "myproject"
location = "europe-west1"
format = "DOCKER"
Expand Down
12 changes: 6 additions & 6 deletions modules/bigquery-dataset/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The access variables are split into `access` and `access_identities` variables,

```hcl
module "bigquery-dataset" {
source = "./modules/bigquery-dataset"
source = "./fabric/modules/bigquery-dataset"
project_id = "my-project"
id = "my-dataset"
access = {
Expand All @@ -44,7 +44,7 @@ Access configuration can also be specified via IAM instead of basic roles via th

```hcl
module "bigquery-dataset" {
source = "./modules/bigquery-dataset"
source = "./fabric/modules/bigquery-dataset"
project_id = "my-project"
id = "my-dataset"
iam = {
Expand All @@ -60,7 +60,7 @@ Dataset options are set via the `options` variable. all options must be specifie

```hcl
module "bigquery-dataset" {
source = "./modules/bigquery-dataset"
source = "./fabric/modules/bigquery-dataset"
project_id = "my-project"
id = "my-dataset"
options = {
Expand All @@ -85,7 +85,7 @@ locals {
}

module "bigquery-dataset" {
source = "./modules/bigquery-dataset"
source = "./fabric/modules/bigquery-dataset"
project_id = "my-project"
id = "my_dataset"
tables = {
Expand Down Expand Up @@ -113,7 +113,7 @@ locals {
}

module "bigquery-dataset" {
source = "./modules/bigquery-dataset"
source = "./fabric/modules/bigquery-dataset"
project_id = "my-project"
id = "my-dataset"
tables = {
Expand Down Expand Up @@ -145,7 +145,7 @@ locals {
}

module "bigquery-dataset" {
source = "./modules/bigquery-dataset"
source = "./fabric/modules/bigquery-dataset"
project_id = "my-project"
id = "my_dataset"
tables = {
Expand Down
2 changes: 1 addition & 1 deletion modules/bigtable-instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This module allows managing a single BigTable instance, including access configu
```hcl

module "bigtable-instance" {
source = "./modules/bigtable-instance"
source = "./fabric/modules/bigtable-instance"
project_id = "my-project"
name = "instance"
cluster_id = "instance"
Expand Down
6 changes: 3 additions & 3 deletions modules/billing-budget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Send a notification to an email when a set of projects reach $100 of spend.

```hcl
module "budget" {
source = "./modules/billing-budget"
source = "./fabric/modules/billing-budget"
billing_account = var.billing_account_id
name = "$100 budget"
amount = 100
Expand All @@ -42,7 +42,7 @@ Send a notification to a PubSub topic the total spend of a billing account reach

```hcl
module "budget" {
source = "./modules/billing-budget"
source = "./fabric/modules/billing-budget"
billing_account = var.billing_account_id
name = "previous period budget"
amount = 0
Expand All @@ -54,7 +54,7 @@ module "budget" {
}

module "pubsub" {
source = "./modules/pubsub"
source = "./fabric/modules/pubsub"
project_id = var.project_id
name = "budget-topic"
}
Expand Down
2 changes: 1 addition & 1 deletion modules/binauthz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This module simplifies the creation of a Binary Authorization policy, attestors

```hcl
module "binauthz" {
source = "./modules/binauthz"
source = "./fabric/modules/binauthz"
project_id = "my_project"
global_policy_evaluation_mode = "DISABLE"
default_admission_rule = {
Expand Down
8 changes: 4 additions & 4 deletions modules/cloud-config-container/coredns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This example will create a `cloud-config` that uses the module's defaults, creat

```hcl
module "cos-coredns" {
source = "./modules/cloud-config-container/coredns"
source = "./fabric/modules/cloud-config-container/coredns"
}

# use it as metadata in a compute instance or template
Expand All @@ -40,8 +40,8 @@ This example will create a `cloud-config` using a custom CoreDNS configuration,

```hcl
module "cos-coredns" {
source = "./modules/cloud-config-container/coredns"
coredns_config = "./modules/cloud-config-container/coredns/Corefile-hosts"
source = "./fabric/modules/cloud-config-container/coredns"
coredns_config = "./fabric/modules/cloud-config-container/coredns/Corefile-hosts"
files = {
"/etc/coredns/example.hosts" = {
content = "127.0.0.2 foo.example.org foo"
Expand All @@ -57,7 +57,7 @@ This example shows how to create the single instance optionally managed by the m

```hcl
module "cos-coredns" {
source = "./modules/cloud-config-container/coredns"
source = "./fabric/modules/cloud-config-container/coredns"
test_instance = {
project_id = "my-project"
zone = "europe-west1-b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This example will create a `cloud-config` that starts [Envoy Proxy](https://www.

```hcl
module "cos-envoy" {
source = "./modules/cos-generic-metadata"
source = "./fabric/modules/cos-generic-metadata"

container_image = "envoyproxy/envoy:v1.14.1"
container_name = "envoy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ This module depends on the [`cos-generic-metadata` module](../cos-generic-metada
```hcl
# Envoy TD config
module "cos-envoy-td" {
source = "./modules/cloud-config-container/envoy-traffic-director"
source = "./fabric/modules/cloud-config-container/envoy-traffic-director"
}

# COS VM
module "vm-cos" {
source = "./modules/compute-vm"
source = "./fabric/modules/compute-vm"
project_id = local.project_id
zone = local.zone
name = "cos-envoy-td"
Expand Down
6 changes: 3 additions & 3 deletions modules/cloud-config-container/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This example will create a `cloud-config` that uses the container's default conf

```hcl
module "cos-mysql" {
source = "./modules/cos-container/mysql"
source = "./fabric/modules/cos-container/mysql"
mysql_password = "foo"
}

Expand All @@ -43,7 +43,7 @@ This example will create a `cloud-config` that uses a custom MySQL configuration

```hcl
module "cos-mysql" {
source = "./modules/cos-container/mysql"
source = "./fabric/modules/cos-container/mysql"
mysql_config = "./my.cnf"
mysql_password = "CiQAsd7WY=="
kms_config = {
Expand All @@ -61,7 +61,7 @@ This example shows how to create the single instance optionally managed by the m

```hcl
module "cos-mysql" {
source = "./modules/cos-container/mysql"
source = "./fabric/modules/cos-container/mysql"
mysql_password = "foo"
test_instance = {
project_id = "my-project"
Expand Down
4 changes: 2 additions & 2 deletions modules/cloud-config-container/nginx-tls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ This module depends on the [`cos-generic-metadata` module](../cos-generic-metada
```hcl
# Nginx with self-signed TLS config
module "cos-nginx-tls" {
source = "./modules/cloud-config-container/nginx-tls"
source = "./fabric/modules/cloud-config-container/nginx-tls"
}

# COS VM
module "vm-nginx-tls" {
source = "./modules/compute-vm"
source = "./fabric/modules/compute-vm"
project_id = local.project_id
zone = local.zone
name = "cos-nginx-tls"
Expand Down
Loading