This repository contains the Terraform code necessary to set up a Landing Zone using the Google Cloud Platform (GCP). It is designed to follow best practices outlined in the Google Cloud Architecture's Security Foundations. By leveraging this code, users can create a secure, scalable, and efficient cloud environment that aligns with Google's recommended practices.
To maintain organization and facilitate navigation, this repository is structured as follows:
repo:
|- 0-bootstrap
|- <terraform_code>
|- 1-org
|- <terraform_code>
|- 2-env
|- <terraform_code>
|- 3-networks
|- <terraform_code>
|- 4-projects
|- <terraform_code>
|- 5-app-infra
|- <terraform_code>
|- 6-anthos
|- <application_manifests>
|- kcc
|- <terraform_code>
|- <resource_manifests>
|- modules
|- <terraform_module_folder_1>
|- <terraform_module_folder_2>
To run the commands described in this document, you need to have the following installed:
- Google Cloud SDK: Version 319.0.0 or later. Install Guide
- Terraform: Version 1.0.9. Download
- Git: Version v2.38.1
Before you begin deploying the Landing Zone, ensure you have the following prerequisites in place:
Note: Consistency in Terraform version is crucial to avoid state lock errors. Follow the steps below to set up your environment correctly:
- Google Cloud Organization: Set up as described here.
- Billing Account: Create and manage as per instructions here. Remember to:
- Note the billing ID.
- Increase the quota for associating projects to 50.
- Authentication: Configure by creating Cloud Identity or Google Workspace groups for admins.
- Permissions: Create a
group_org_admins
group and assign necessary roles includingroles/resourcemanager.projectCreator
roles/resourcemanager.folderCreator
roles/resourcemanager.organizationAdmin
roles/billing.admin
.
- Service Accounts: Ensure GitHub Actions and Cloud Build service accounts are added to the
group_org_admins
.
For a detailed setup, refer to the organization bootstrap module documentation.
Follow the steps to fork or clone the landing zone GITHUB repo on your local machine:
- Create bot machine user and create a personal access token (PAT) on GitHub for user .
Grants access to PAT as following permission
read:org
andread:discussions
.
Goto GitHub profile
>Settings
>Developer Settings
>Personal Access Tokens
>Generate New Token
. Note the new token value. - Create GitHub Token Secret in GitHub as
GH_TOKEN
. - Clone the repo:
git clone https://github.com/ollionorg/gcp-landing-zone.git
The following steps should be executed on your local system to initialize and run the bootstrap phase for the GCP landing zone.
- Ensure the tf variable file inside the file 0-bootstrap/terraform.tfvars are properly set and commit the changes to the repository. For setting the parameters, please refer to the input documentation.
- Add correct billing ID in the
0-bootstrap/terraform.tfvars
file for the initial deployment of the 0-bootstrap stage. - Optional if required, Create Slack WebHook Secret in GitHub
GCF_SLACK_WEBHOOK
. - Setup
GH_TOKEN
as$GITHUB_PAT
environment variable and execute the wrapper script using below commands (Ensure .terraform directories created locally from previous runs are deleted):$ cd ./prerequisites/scripts $ read -s token <enter_github_token_obtained_in_step_9> $ export GITHUB_PAT=$token $ chmod +x wrapper.sh ; ./wrapper.sh
- After execution of wrapper script, add cloudbuild service account from cicd project as a principal in the billing account with
billing.administrator
andbilling.user
- Wrapper script will create following branch protection rules for branch
${bu_name}-main
.Require a pull request before merging. Required two number of approvals before merging Dismiss stale pull request approvals when new commits are pushed Require review from Code Owners Require status checks to pass before merging Require branches to be up to date before merging Require conversation resolution before merging. Require signed commits. Requires administrator Allow auto-merge and allow auto-deletion of branches
- Commit and push changes from
.github/workflows
,build
,0-bootstrap
,README.md
to${bu_name}-init
and ensure everything gets successfully applied. - Start deployment by raising PRs for subsequent stages by pushing the backend.tf changes made by wrapper script for each stage in ${bu_name}-init.
Describe the problem clearly and send an email to lzhelp@ollion.com.