Parent project
: the GCP project from which the terraform process will run
Child projects
: the GCP projects into which resources will be provisioned
Terraform 1.x
The user running the commands must have write permissions to the terraform state storage bucket (see below), and owner permissions (or a bunch of individual edit permissions which are too many to enumerate) on the child projects.
Terraform won't create the child projects for you (it could, but that gets messy). So create them beforehand. Also, you'll need a GCS bucket (see below)
- First off, you'll need to store the Terraform state somewhere. You could use local state, but it's not recommended, so:
- Create a GCS storage bucket (recommended name: "$PARENT_PROJECT_ID-tfstate")
- Initialize Terraform
terraform init
- At the prompt, enter the name of the GCS bucket that you created for state storage
- Configure Terraform variables
- edit the values in
terraform.tfvars
- the child projects go in
gcp_project_ids
- the child projects go in
- edit the values in
- Run Terraform
terraform apply
- When prompted, type
yes
to apply the configuration- tip: add flag
--auto-approve
to skip confirmation
- tip: add flag
- Identical resources will be configured in every child project
- Change some stuff!
- You can make changes to the terraform resources (edit the
*.tf
files) - Then re-run
terraform apply
to change them; the changes will propagate across all child projects
- You can make changes to the terraform resources (edit the