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 blueprints from README files #1143

Merged
merged 23 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
32 changes: 32 additions & 0 deletions blueprints/apigee/bigquery-analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,35 @@ Do the following to verify that everything works as expected.
| [ip_address](outputs.tf#L17) | IP address. | |

<!-- END TFDOC -->
## Test

```hcl
module "test" {
source = "./fabric/blueprints/apigee/bigquery-analytics"
project_create = {
billing_account_id = "12345-12345-12345"
parent = "folders/123456789"
}
project_id = "my-project"
envgroups = {
test = ["test.cool-demos.space"]
}
environments = {
apis-test = {
envgroups = ["test"]
}
}
instances = {
instance-ew1 = {
region = "europe-west1"
environments = ["apis-test"]
runtime_ip_cidr_range = "10.0.4.0/22"
troubleshooting_ip_cidr_range = "10.1.0.0/28"
}
}
psc_config = {
europe-west1 = "10.0.0.0/28"
}
}
# tftest modules=10 resources=62
```
21 changes: 18 additions & 3 deletions blueprints/apigee/hybrid-gke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ The diagram below depicts the architecture.
terraform apply
```

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.
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.

5. Install Apigee hybrid using de ansible playbook that is in the ansible folder by running this command

ansible-playbook playbook.yaml -vvvß
ansible-playbook playbook.yaml -vvv

## Testing the blueprint

Expand Down Expand Up @@ -67,3 +67,18 @@ The diagram below depicts the architecture.
| [ip_address](outputs.tf#L17) | GLB IP address. | |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/apigee/hybrid-gke"
project_create = {
billing_account_id = "12345-12345-12345"
parent = "folders/123456789"
}
project_id = "my-project"
hostname = "test.myorg.org"
}
# tftest modules=18 resources=59
```
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,17 @@ Do the following to verify that everything works as expected.
| [ip_address](outputs.tf#L17) | GLB IP address. | |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/apigee/network-patterns/nb-glb-psc-neg-sb-psc-ilbl7-hybrid-neg"
billing_account_id = "12345-12345-12345"
parent = "folders/123456789"
apigee_project_id = "my-apigee-project"
onprem_project_id = "my-onprem-project"
hostname = "test.myorg.org"
}
# tftest modules=14 resources=73
```
17 changes: 17 additions & 0 deletions blueprints/cloud-operations/adfs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,20 @@ Once done testing, you can clean up resources by running `terraform destroy`.
| [ip_address](outputs.tf#L15) | IP address. | |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/adfs"
prefix = "test"
project_create = {
billing_account_id = "12345-12345-12345"
parent = "folders/123456789"
}
project_id = "project-1"
ad_dns_domain_name = "example.com"
adfs_dns_domain_name = "adfs.example.com"
}
# tftest modules=5 resources=18
```
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,15 @@ Run the `subscription_pull` command until it returns nothing, then run the follo
| [tag_show](outputs.tf#L49) | Instance add tag command. | |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/asset-inventory-feed-remediation"
project_create = true
project_id = "project-1"
}

# tftest modules=7 resources=21
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* Copyright 2023 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 @@ -82,7 +82,7 @@ module "cf" {
location = var.region
}
bundle_config = {
source_dir = "cf"
source_dir = "${path.module}/cf"
output_path = var.bundle_path
}
service_account = module.service-account.email
Expand Down
12 changes: 12 additions & 0 deletions blueprints/cloud-operations/dns-fine-grained-iam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,15 @@ dig app1.svc.example.org +short
| [vms](outputs.tf#L25) | VM names. | |

<!-- END TFDOC -->

## Test

```hcl
module "test1" {
source = "./fabric/blueprints/cloud-operations/dns-fine-grained-iam"
name = "dns-sd-test"
project_create = true
project_id = "test"
}
# tftest modules=9 resources=25
```
14 changes: 14 additions & 0 deletions blueprints/cloud-operations/dns-shared-vpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,17 @@ Note that Terraform 0.13 at least is required due to the use of `for_each` with
| [teams](outputs.tf#L17) | Team resources. | |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/dns-shared-vpc"
billing_account_id = "111111-222222-333333"
folder_id = "folders/1234567890"
prefix = "test"
shared_vpc_link = "https://www.googleapis.com/compute/v1/projects/test-dns/global/networks/default"
teams = ["team1", "team2"]
}
# tftest modules=9 resources=12
```
12 changes: 12 additions & 0 deletions blueprints/cloud-operations/iam-delegated-role-grants/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,15 @@ If you get any warnings, check the roles and remove any of them granting any of
| [restricted_role_grant](variables.tf#L78) | Role grant to which the restrictions will apply. | <code>string</code> | | <code>&#34;roles&#47;resourcemanager.projectIamAdmin&#34;</code> |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/iam-delegated-role-grants"
project_create = true
project_id = "project-1"
project_administrators = ["user:[email protected]"]
}
# tftest modules=2 resources=4
```
11 changes: 11 additions & 0 deletions blueprints/cloud-operations/onprem-sa-key-management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,14 @@ terraform destroy -var project_id=$GOOGLE_CLOUD_PROJECT
| [sa-credentials](outputs.tf#L17) | SA json key templates. | |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/onprem-sa-key-management"
project_create = true
project_id = "test"
}
# tftest modules=4 resources=7
```
24 changes: 24 additions & 0 deletions blueprints/cloud-operations/packer-image-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,27 @@ address for security reasons, Internet connectivity is done with [Cloud NAT](htt
| [compute_zone](outputs.tf#L32) | Name of a compute engine zone for Packer's temporary VM. | |

<!-- END TFDOC -->

## Test

```tpl
# tftest-file id=pkrvars path=packer/build.pkrvars.tpl
# Packer variables file template.
# Used by Terraform to generate Packer variable file.
project_id = "${PROJECT_ID}"
compute_zone = "${COMPUTE_ZONE}"
builder_sa = "${BUILDER_SA}"
compute_sa = "${COMPUTE_SA}"
compute_subnetwork = "${COMPUTE_SUBNETWORK}"
use_iap = ${USE_IAP}
```

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/packer-image-builder"
project_id = "test-project"
packer_account_users = ["user:[email protected]"]
create_packer_vars = true
}
# tftest modules=7 resources=17 files=pkrvars
```
12 changes: 12 additions & 0 deletions blueprints/cloud-operations/quota-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,15 @@ Clone this repository or [open it in cloud shell](https://ssh.cloud.google.com/c
| [schedule_config](variables.tf#L66) | Schedule timer configuration in crontab format. | <code>string</code> | | <code>&#34;0 &#42; &#42; &#42; &#42;&#34;</code> |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/quota-monitoring"
name = "name"
project_create = true
project_id = "test"
}
# tftest modules=4 resources=14
```
4 changes: 2 additions & 2 deletions blueprints/cloud-operations/quota-monitoring/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* Copyright 2023 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 @@ -55,7 +55,7 @@ module "cf" {
location = var.region
}
bundle_config = {
source_dir = "cf"
source_dir = "${path.module}/cf"
output_path = var.bundle_path
}
# https://github.com/hashicorp/terraform-provider-archive/issues/40
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,29 @@ This is an optional part, created if `cai_gcs_export` is set to `true`. The high
| [cloud-function](outputs.tf#L22) | Cloud Function instance details. | |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/scheduled-asset-inventory-export-bq"
billing_account = "1234-ABCD-1234"
cai_config = {
bq_dataset = "my-dataset"
bq_table = "my_table"
bq_table_overwrite = "true"
target_node = "organization/1234567890"
}
cai_gcs_export = true
file_config = {
bucket = "my-bucket"
filename = "my-folder/myfile.json"
format = "NEWLINE_DELIMITED_JSON"
bq_dataset = "my-dataset"
bq_table = "my_table"
}
project_create = true
project_id = "project-1"
}
# tftest modules=8 resources=34
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2022 Google LLC
* Copyright 2023 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 @@ -94,7 +94,7 @@ module "cf" {
location = var.region
}
bundle_config = {
source_dir = "cf"
source_dir = "${path.module}/cf"
output_path = var.bundle_path
}
service_account = module.service-account.email
Expand All @@ -118,7 +118,7 @@ module "cffile" {
lifecycle_delete_age_days = null
}
bundle_config = {
source_dir = "cffile"
source_dir = "${path.module}/cffile"
output_path = var.bundle_path_cffile
excludes = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,4 @@ terraform apply
As a result we have a successfully deployed GCS bucket from Terraform Cloud workflow using Workload Identity Federation.

Once done testing, you can clean up resources by running `terraform destroy` first in the `tfc-workflow-using-wif` and then `gcp-workload-identity-provider` folders.

Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,22 @@ The codebase provisions the following list of resources:
| [tfc_workspace_wariables](outputs.tf#L20) | Variables to be set on the TFC workspace. | |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/terraform-cloud-dynamic-credentials/gcp-workload-identity-provider"
billing_account = "1234-ABCD-1234"
project_create = true
project_id = "project-1"
parent = "folders/12345"
tfc_organization_id = "org-123"
tfc_workspace_id = "ws-123"
workload_identity_pool_id = "tfe-pool"
workload_identity_pool_provider_id = "tf-provider"
issuer_uri = "https://app.terraform.io/"
}

# tftest modules=3 resources=12
```
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,15 @@ gcloud compute ssh --zone europe-west1-b nginx-test -- 'uptime'
| [pubsub-topic](outputs.tf#L26) | Restarter PubSub topic. | |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/unmanaged-instances-healthcheck"
project_id = "project-1"
billing_account = "123456-123456-123456"
project_create = true
}
# tftest modules=11 resources=35
```
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,30 @@ This sample creates\updates several distinct groups of resources:
| [m4ce_gmanaged_service_account](outputs.tf#L15) | Google managed service account created automatically during the migrate connector registration.. It is used by M4CE to perform activities on target projects. | |

<!-- END TFDOC -->

## Test

```hcl
module "test" {
source = "./fabric/blueprints/cloud-operations/vm-migration/host-target-projects"
project_create = {
billing_account_id = "1234-ABCD-1234"
parent = "folders/1234563"
}
migration_admin_users = ["user:[email protected]"]
migration_viewer_users = ["user:[email protected]"]
migration_target_projects = [module.test-target-project.name]
depends_on = [
module.test-target-project
]
}

module "test-target-project" {
source = "./fabric/modules/project"
billing_account = "1234-ABCD-1234"
name = "test-target-project"
project_create = true
}

# tftest modules=5 resources=24
```
Loading