-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add validation functions for foundation deploy tasks (#953)
- Loading branch information
1 parent
c5615ec
commit 27b87f8
Showing
9 changed files
with
1,532 additions
and
12 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,88 @@ | ||
# Terraform Example Foundation deploy helper | ||
|
||
Helper tool to deploy the Terraform example foundation. | ||
|
||
## Usage | ||
|
||
- Check if required tools, Go 1.18+, Terraform 1.3.0+, gcloud 393.0.0+, and Git 2.28.0+, are installed: | ||
|
||
```bash | ||
go version | ||
|
||
terraform -version | ||
|
||
gcloud --version | ||
|
||
git --version | ||
``` | ||
|
||
- Create a directory in the file system to host the Cloud Source repositories the will be created and a copy of the terraform example foundation. | ||
- Clone the `terraform-example-foundation` repository on this directory. | ||
|
||
```text | ||
deploy-directory/ | ||
└── terraform-example-foundation | ||
``` | ||
|
||
- Copy the file [global.tfvars.example](./global.tfvars.example) as `global.tfvars` to the same directory. | ||
|
||
```text | ||
deploy-directory/ | ||
└── global.tfvars | ||
└── terraform-example-foundation | ||
``` | ||
|
||
- Update `global.tfvars` with values from your environment. | ||
See the READMEs for the stages for additional information: | ||
- [0-bootstrap](https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/0-bootstrap/README.md) | ||
- [1-org](https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/1-org/README.md) | ||
- [2-environments](https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/2-environments/README.md) | ||
- [3-networks-dual-svpc](https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/3-networks-dual-svpc) | ||
- [3-networks-hub-and-spoke](https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/3-networks-hub-and-spoke) | ||
- [4-projects](https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/4-projects) | ||
- [5-app-infra](https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/5-app-infra) | ||
|
||
- Variable `code_checkout_path` is the full path to `deploy-directory` directory. | ||
- Variable `foundation_code_path` is the full path to `terraform-example-foundation` directory. | ||
- Build the helper: | ||
|
||
```bash | ||
go build | ||
``` | ||
|
||
- Validate the tfvars file: | ||
|
||
```bash | ||
./deployer -tfvars_file <PATH TO 'global.tfvars' FILE> -validate | ||
``` | ||
|
||
### Supported flags | ||
|
||
```bash | ||
-tfvars_file file | ||
Full path to the Terraform .tfvars file with the configuration to be used. | ||
-steps_file file | ||
Path to the steps file to be used to save progress. (default ".steps.json") | ||
-list_steps | ||
List the existing steps. | ||
-reset_step step | ||
Name of a step to be reset. | ||
-validate | ||
Validate tfvars file inputs | ||
-quiet | ||
If true, additional output is suppressed. | ||
-disable_prompt | ||
Disable interactive prompt. | ||
-destroy | ||
Destroy the deployment. | ||
-help | ||
Prints this help text and exits. | ||
``` | ||
|
||
## Requirements | ||
|
||
- [Go](https://go.dev/doc/install) 1.18+ | ||
- [Google Cloud SDK](https://cloud.google.com/sdk/install) version 393.0.0+ | ||
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) version 2.28.0+ | ||
- [Terraform](https://www.terraform.io/downloads.html) version 1.3.0+ | ||
- See `0-bootstrap` README for additional IAM [requirements](../../0-bootstrap/README.md#prerequisites) on the user deploying the Foundation. |
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,119 @@ | ||
/** | ||
* 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. | ||
* 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. | ||
*/ | ||
|
||
// General inputs | ||
|
||
// The directory where the helper will git clone the Google Source Repositories that will | ||
// host the code for each one of the stages | ||
code_checkout_path = "FULL_PATH_TO_FOLDER_WHERE_TO_CHECK_OUT_THE_SOURCE_REPOSITORIES" | ||
|
||
// The directory where the user has created a fresh git clone of the Terraform Example Foundation repository | ||
foundation_code_path = "FULL_PATH_TO_FOLDER_WHERE_THE_EXAMPLE_FOUNDATION_CODE_WAS_CHECKED_OUT" | ||
|
||
// An existing project configured as the default project in the local Cloud SDK configuration | ||
// See https://cloud.google.com/sdk/gcloud/reference/config/set#EXAMPLES | ||
validator_project_id = "EXISTING_PROJECT_ID" | ||
|
||
|
||
// 0-bootstrap inputs | ||
// https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/0-bootstrap/README.md#inputs | ||
|
||
org_id = "REPLACE_ME" # format "000000000000" | ||
billing_account = "REPLACE_ME" # format "000000-000000-000000" | ||
default_region = "us-central1" | ||
|
||
group_org_admins = "REPLACE_ME" # "[email protected]" | ||
group_billing_admins = "REPLACE_ME" # "[email protected]" | ||
|
||
bucket_force_destroy = false | ||
project_prefix = "prj" | ||
folder_prefix = "fldr" | ||
|
||
// Optional - for an organization with existing projects or for development/validation. | ||
// Uncomment this variable to place all the example foundation resources under | ||
// the provided folder instead of the root organization. | ||
// The variable value is the numeric folder ID | ||
// The folder must already exist. | ||
|
||
//parent_folder = "01234567890" | ||
|
||
|
||
// 1-org inputs | ||
// https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/1-org/envs/shared/README.md#inputs | ||
|
||
audit_data_users = "REPLACE_ME" # "[email protected]" | ||
billing_data_users = "REPLACE_ME" # "[email protected]" | ||
|
||
domains_to_allow = ["example.com"] # Must include the domain of the organization you are deploying the foundation. | ||
essential_contacts_domains_to_allow = ["@example.com"] | ||
|
||
scc_notification_name = "scc-notify" | ||
audit_logs_table_delete_contents_on_destroy = false | ||
log_export_storage_force_destroy = false | ||
|
||
// Choose witch network architecture to use: | ||
// Dual Shared VPC: https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/3-networks-dual-svpc/README.md | ||
// Hub And Spoke: https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/3-networks-hub-and-spoke/README.md | ||
|
||
enable_hub_and_spoke = false | ||
|
||
// Optional - If you are deploying Foundation Example in a parent folder | ||
// consider setting 'create_unique_tag_key' to 'true' because as Tag Keys are | ||
// unique organization-wide it will add a random suffix at each tag key | ||
|
||
create_unique_tag_key = false | ||
|
||
|
||
|
||
// 2-environments inputs | ||
// https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/2-environments/envs/production/README.md#inputs | ||
|
||
monitoring_workspace_users = "REPLACE_ME" # "[email protected]" | ||
|
||
|
||
// 3-networks inputs | ||
// https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/3-networks-hub-and-spoke/envs/production/README.md#inputs | ||
// https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/3-networks-hub-and-spoke/envs/shared/README.md#inputs | ||
|
||
domain = "example.com." # The DNS name of peering managed zone. Must end with a period. | ||
|
||
// Add you email in the perimeter_additional_members list. | ||
// You must be in this list to be able to view/access resources in the project protected by the VPC service controls. | ||
|
||
perimeter_additional_members = ["user:[email protected]"] | ||
|
||
enable_hub_and_spoke_transitivity = false | ||
|
||
// List of IPv4 address of target name servers for the forwarding zone configuration. | ||
// See https://cloud.google.com/dns/docs/overview#dns-forwarding-zones | ||
|
||
target_name_server_addresses = [ | ||
{ | ||
ipv4_address = "192.168.0.1", | ||
forwarding_path = "default" | ||
}, | ||
{ | ||
ipv4_address = "192.168.0.2", | ||
forwarding_path = "default" | ||
} | ||
] | ||
|
||
|
||
// 4-projects inputs | ||
// https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/4-projects/business_unit_1/production/README.md#inputs | ||
|
||
projects_gcs_location = "US" | ||
projects_kms_location = "us" |
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
Oops, something went wrong.