Skip to content

Commit

Permalink
chore: README review for stages 2,3,4,5 README and Troubleshooting en…
Browse files Browse the repository at this point in the history
…try for remote state (terraform-google-modules#792)

* fix links in 2-environments

* revert name branch link fix

* fix links

* fix typos

* add export of impersonated service account in manual steps

* add information about remote state to Troubleshooting and 0-bootstrap README

* add cross reference to troubleshooting unsupported attribute error
  • Loading branch information
daniel-cit authored Sep 9, 2022
1 parent ca0a4b3 commit e13625a
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 58 deletions.
2 changes: 1 addition & 1 deletion 0-bootstrap/README-Jenkins.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Here you will configure a VPN Network tunnel to enable connectivity between the
### IV. Configure the Git repositories and Multibranch Pipelines in your Jenkins Controller
- **Note:** this section is considered out of the scope of this document. Since there are multiple options on how to configure the Git repositories and **Multibranch Pipeline** in your Jenkins Controller, here we can only provide some guidance that you should keep in mind while completing this step. Visit the [Jenkins website](http://jenkins.io) for more information, there are plenty of Jenkins Plugins that could help with the task.
- **Note:** this section is considered out of the scope of this document. Since there are multiple options on how to configure the Git repositories and **Multibranch Pipeline** in your Jenkins Controller, here we can only provide some guidance that you should keep in mind while completing this step. Visit the [Jenkins website](https://jenkins.io) for more information, there are plenty of Jenkins Plugins that could help with the task.
- You need to configure a **"Multibranch Pipeline"**. Note that the `Jenkinsfile` and `tf-wrapper.sh` files use the `$BRANCH_NAME` environment variable. **the `$BRANCH_NAME` variable is only available in Jenkins' Multibranch Pipelines**.
Expand Down
4 changes: 3 additions & 1 deletion 0-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ your current Jenkins manager (controller) environment.
1. (Optional) Run `terraform apply` to verify that state is configured
correctly. You should see no changes from the previous state.
**Note:** After the deploy, even if you did not receive the project quota error described in the [Troubleshooting guide](../docs/TROUBLESHOOTING.md#project-quota-exceeded), we recommend that you request 50 additional projects for the four service accounts created in this step.
**Note 1:** The stages after `0-bootstrap` use `terraform_remote_state` data source to read common configuration like the organization ID from the output of the `0-bootstrap` stage. They will [fail](../docs/TROUBLESHOOTING.md#error-unsupported-attribute) if the state is not copied to the Cloud Storage bucket.
**Note 2:** After the deploy, even if you did not receive the project quota error described in the [Troubleshooting guide](../docs/TROUBLESHOOTING.md#project-quota-exceeded), we recommend that you request 50 additional projects for the four service accounts created in this step.
## Running Terraform locally
Expand Down
9 changes: 5 additions & 4 deletions 1-org/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to see
git commit -m 'Your message'
```
1. Push your plan branch to trigger a plan for all environments. Because the
_plan_ branch is not a [named environment branch](./docs/FAQ.md), pushing your _plan_
_plan_ branch is not a [named environment branch](../docs/FAQ.md#what-is-a-named-branch), pushing your _plan_
branch triggers _terraform plan_ but not _terraform apply_.
```
git push --set-upstream origin plan
```
1. Review the plan output in your Cloud Build project. https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
1. Merge changes to production branch. Because the _production_ branch is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
1. Merge changes to production branch. Because the _production_ branch is a [named environment branch](../docs/FAQ.md#what-is-a-named-branch),
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
```
git checkout -b production
Expand Down Expand Up @@ -232,7 +232,7 @@ to run the command as the Terraform service account.
```
_TF_SA_EMAIL
_STATE_BUCKET_NAME
_PROJECT_ID (the cicd project id)
_PROJECT_ID (the CI/CD project ID)
```
1. Copy Terraform wrapper script to the root of your new repository.
```
Expand All @@ -253,7 +253,7 @@ to run the command as the Terraform service account.
git commit -m 'Your message'
```
1. Push your plan branch.
- Assuming you configured an automatic trigger in your Jenkins Controller (see [Jenkins sub-module README](../0-bootstrap/modules/jenkins-agent)), this will trigger a plan. You can also trigger a Jenkins job manually. Given the many options to do this in Jenkins, it is out of the scope of this document see [Jenkins website](http://www.jenkins.io) for more details.
- Assuming you configured an automatic trigger in your Jenkins Controller (see [Jenkins sub-module README](../0-bootstrap/modules/jenkins-agent)), this will trigger a plan. You can also trigger a Jenkins job manually. Given the many options to do this in Jenkins, it is out of the scope of this document see [Jenkins website](https://www.jenkins.io) for more details.
```
git push --set-upstream origin plan
```
Expand Down Expand Up @@ -286,6 +286,7 @@ When using Cloud Build or Jenkins as your CI/CD tool each environment correspond
To use the `validate` option of the `tf-wrapper.sh` script, please follow the [instructions](https://cloud.google.com/docs/terraform/policy-validation/validate-policies#install) to install the terraform-tools component.
1. Export the projects (`terraform-org-sa`) service account for impersonation `export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT="<IMPERSONATE_SERVICE_ACCOUNT>"`
1. Run `./tf-wrapper.sh init production`.
2. Run `./tf-wrapper.sh plan production` and review output.
3. Run `./tf-wrapper.sh validate production $(pwd)/../policy-library <YOUR_CLOUD_BUILD_PROJECT_ID>` and check for violations.
Expand Down
24 changes: 12 additions & 12 deletions 2-environments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

This repo is part of a multi-part guide that shows how to configure and deploy
the example.com reference architecture described in
[Google Cloud security foundations guide](https://services.google.com/fh/files/misc/google-cloud-security-foundations-guide.pdf)
(PDF). The following table lists the parts of the guide.
[Google Cloud security foundations guide](https://cloud.google.com/architecture/security-foundations). The following table lists the parts of the guide.

<table>
<tbody>
Expand Down Expand Up @@ -104,34 +103,34 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
```
chmod 755 ./tf-wrapper.sh
```
1. Rename `terraform.example.tfvars` to `terraform.tfvars` and update the file with values from your environment and bootstrap (you can re-run `terraform output` in the 0-bootstrap directory to find these values). See any of the envs folder [README.md](./envs/production/README.md) files for additional information on the values in the `terraform.tfvars` file.
1. Rename `terraform.example.tfvars` to `terraform.tfvars` and update the file with values from your environment and bootstrap (you can re-run `terraform output` in the 0-bootstrap directory to find these values). See any of the envs folder [README.md](./envs/production/README.md#inputs) files for additional information on the values in the `terraform.tfvars` file.
1. Commit changes.
```
git add .
git commit -m 'Your message'
```
1. Push your plan branch to trigger a plan for all environments. Because the
_plan_ branch is not a [named environment branch](./docs/FAQ.md), pushing your _plan_
_plan_ branch is not a [named environment branch](../docs/FAQ.md#what-is-a-named-branch), pushing your _plan_
branch triggers _terraform plan_ but not _terraform apply_.
```
git push --set-upstream origin plan
```
1. Review the plan output in your cloud build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
1. Merge changes to development branch. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
1. Merge changes to development branch. Because this is a [named environment branch](../docs/FAQ.md#what-is-a-named-branch),
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
```
git checkout -b development
git push origin development
```
1. Review the apply output in your cloud build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
1. Merge changes to non-production. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
1. Merge changes to non-production. Because this is a [named environment branch](../docs/FAQ.md#what-is-a-named-branch),
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
```
git checkout -b non-production
git push origin non-production
```
1. Review the apply output in your cloud build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
1. Merge changes to production branch. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
1. Merge changes to production branch. Because this is a [named environment branch](../docs/FAQ.md#what-is-a-named-branch),
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
```
git checkout -b production
Expand Down Expand Up @@ -166,7 +165,7 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
```
_TF_SA_EMAIL
_STATE_BUCKET_NAME
_PROJECT_ID (the CI/CD project id)
_PROJECT_ID (the CI/CD project ID)
```
1. Copy Terraform wrapper script to the root of your new repository.
```
Expand All @@ -176,7 +175,7 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
```
chmod 755 ./tf-wrapper.sh
```
1. Rename `terraform.example.tfvars` to `terraform.tfvars` and update the file with values from your environment and bootstrap (you can re-run `terraform output` in the 0-bootstrap directory to find these values). See any of the envs folder [README.md](./envs/production/README.md) files for additional information on the values in the `terraform.tfvars` file.
1. Rename `terraform.example.tfvars` to `terraform.tfvars` and update the file with values from your environment and bootstrap (you can re-run `terraform output` in the 0-bootstrap directory to find these values). See any of the envs folder [README.md](./envs/production/README.md#inputs) files for additional information on the values in the `terraform.tfvars` file.
1. Commit changes.
```
git add .
Expand All @@ -186,7 +185,7 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
```
git push --set-upstream origin plan
```
- Assuming you configured an automatic trigger in your Jenkins Controller (see [Jenkins sub-module README](../0-bootstrap/modules/jenkins-agent)), this will trigger a plan. You can also trigger a Jenkins job manually. Given the many options to do this in Jenkins, it is out of the scope of this document see [Jenkins website](http://www.jenkins.io) for more details.
- Assuming you configured an automatic trigger in your Jenkins Controller (see [Jenkins sub-module README](../0-bootstrap/modules/jenkins-agent/README.md)), this will trigger a plan. You can also trigger a Jenkins job manually. Given the many options to do this in Jenkins, it is out of the scope of this document see [Jenkins website](https://www.jenkins.io) for more details.
1. Review the plan output in your Controller's web UI.
1. Merge changes to development.
```
Expand All @@ -212,8 +211,8 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
1. Change into 2-environments folder.
1. Run `cp ../build/tf-wrapper.sh .`
1. Run `chmod 755 ./tf-wrapper.sh`.
1. Rename `terraform.example.tfvars` to `terraform.tfvars` and update the file with values from your environment and bootstrap. See any of the envs folder [README.md](./envs/production/README.md) files for additional information on the values in the `terraform.tfvars` file.
1. Update backend.tf with your bucket from bootstrap.
1. Rename `terraform.example.tfvars` to `terraform.tfvars` and update the file with values from your environment and bootstrap. See any of the envs folder [README.md](./envs/production/README.md#inputs) files for additional information on the values in the `terraform.tfvars` file.
1. Update `backend.tf` with your bucket from bootstrap.
```
for i in `find -name 'backend.tf'`; do sed -i 's/UPDATE_ME/<YOUR-BUCKET-NAME>/' $i; done
```
Expand All @@ -224,6 +223,7 @@ When using Cloud Build or Jenkins as your CI/CD tool each environment correspond
To use the `validate` option of the `tf-wrapper.sh` script, please follow the [instructions](https://cloud.google.com/docs/terraform/policy-validation/validate-policies#install) to install the terraform-tools component.
1. Export the projects (`terraform-env-sa`) service account for impersonation `export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT="<IMPERSONATE_SERVICE_ACCOUNT>"`
1. Run `./tf-wrapper.sh init development`.
2. Run `./tf-wrapper.sh plan development` and review output.
3. Run `./tf-wrapper.sh validate development $(pwd)/../policy-library <YOUR_CLOUD_BUILD_PROJECT_ID>` and check for violations.
Expand Down
23 changes: 12 additions & 11 deletions 3-networks-dual-svpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

This repo is part of a multi-part guide that shows how to configure and deploy
the example.com reference architecture described in
[Google Cloud security foundations guide](https://services.google.com/fh/files/misc/google-cloud-security-foundations-guide.pdf)
(PDF). The following table lists the parts of the guide.
[Google Cloud security foundations guide](https://cloud.google.com/architecture/security-foundations). The following table lists the parts of the guide.

<table>
<tbody>
Expand Down Expand Up @@ -87,7 +86,7 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.

### Networking Architecture

This step makes use of the **Dual Shared VPC** architecture, and more details can be found described at the **Networking** section of the [Google cloud security foundations guide](https://cloud.google.com/architecture/security-foundations/networking). To see the version that makes use the Hub and Spoce mode, check the step [3-networks-hub-and-spoke](../3-networks-hub-and-spoke).
This step makes use of the **Dual Shared VPC** architecture, and more details can be found described at the **Networking** section of the [Google cloud security foundations guide](https://cloud.google.com/architecture/security-foundations/networking). To see the version that makes use the Hub and Spoke mode, check the step [3-networks-hub-and-spoke](../3-networks-hub-and-spoke).


### Using Dedicated Interconnect
Expand All @@ -111,11 +110,11 @@ If you provisioned the prerequisites listed in the [Partner Interconnect README]
If you are not able to use Dedicated or Partner Interconnect, you can also use an HA Cloud VPN to access on-premises resources.

1. Rename `vpn.tf.example` to `vpn.tf` in base-env folder in `3-networks-dual-svpc/modules/base_env`.
1. Create secret for VPN private preshared key.
1. Create secret for VPN private pre-shared key.
```
echo '<YOUR-PRESHARED-KEY-SECRET>' | gcloud secrets create <VPN_PRIVATE_PSK_SECRET_NAME> --project <ENV_SECRETS_PROJECT> --replication-policy=automatic --data-file=-
```
1. Create secret for VPN restricted preshared key.
1. Create secret for VPN restricted pre-shared key.
```
echo '<YOUR-PRESHARED-KEY-SECRET>' | gcloud secrets create <VPN_RESTRICTED_PSK_SECRET_NAME> --project <ENV_SECRETS_PROJECT> --replication-policy=automatic --data-file=-
```
Expand Down Expand Up @@ -166,30 +165,30 @@ If you are not able to use Dedicated or Partner Interconnect, you can also use a
1. Run `terraform apply`.
1. If you would like the bucket to be replaced by Cloud Build at run time, change the bucket name back to `UPDATE_ME`.
1. Push your plan branch to trigger a plan for all environments. Because the
_plan_ branch is not a [named environment branch](./docs/FAQ.md), pushing your _plan_
_plan_ branch is not a [named environment branch](../docs/FAQ.md#what-is-a-named-branch), pushing your _plan_
branch triggers _terraform plan_ but not _terraform apply_.
```
cd ../../
git push --set-upstream origin plan
```
1. Review the plan output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
1. Merge changes to production. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
1. Merge changes to production. Because this is a [named environment branch](../docs/FAQ.md#what-is-a-named-branch),
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
```
git checkout -b production
git push origin production
```
1. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
1. After production has been applied, apply development.
1. Merge changes to development. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
1. Merge changes to development. Because this is a [named environment branch](../docs/FAQ.md#what-is-a-named-branch),
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
```
git checkout -b development
git push origin development
```
1. Review the apply output in your Cloud Build project https://console.cloud.google.com/cloud-build/builds?project=YOUR_CLOUD_BUILD_PROJECT_ID
1. After development has been applied, apply non-production.
1. Merge changes to non-production. Because this is a [named environment branch](./docs/FAQ.md#what-is-a-named-branch),
1. Merge changes to non-production. Because this is a [named environment branch](../docs/FAQ.md#what-is-a-named-branch),
pushing to this branch triggers both _terraform plan_ and _terraform apply_.
```
git checkout -b non-production
Expand Down Expand Up @@ -223,7 +222,7 @@ If you are not able to use Dedicated or Partner Interconnect, you can also use a
```
_TF_SA_EMAIL
_STATE_BUCKET_NAME
_PROJECT_ID (the cicd project id)
_PROJECT_ID (the CI/CD project ID)
```
1. Copy Terraform wrapper script to the root of your new repository.
```
Expand All @@ -244,6 +243,7 @@ If you are not able to use Dedicated or Partner Interconnect, you can also use a
1. You must manually plan and apply the `shared` environment (only once) since the `development`, `non-production` and `production` environments depend on it.
1. Run `cd ./envs/shared/`.
1. Update `backend.tf` with your bucket name from the bootstrap step.
1. Export the network (`terraform-net-sa`) service account for impersonation `export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT="<IMPERSONATE_SERVICE_ACCOUNT>"`
1. Run `terraform init`.
1. Run `terraform plan` and review output.
1. Run `terraform apply`.
Expand All @@ -252,7 +252,7 @@ If you are not able to use Dedicated or Partner Interconnect, you can also use a
```
git push --set-upstream origin plan
```
- Assuming you configured an automatic trigger in your Jenkins Controller (see [Jenkins sub-module README](../0-bootstrap/modules/jenkins-agent)), this will trigger a plan. You can also trigger a Jenkins job manually. Given the many options to do this in Jenkins, it is out of the scope of this document see [Jenkins website](http://www.jenkins.io) for more details.
- Assuming you configured an automatic trigger in your Jenkins Controller (see [Jenkins sub-module README](../0-bootstrap/modules/jenkins-agent)), this will trigger a plan. You can also trigger a Jenkins job manually. Given the many options to do this in Jenkins, it is out of the scope of this document see [Jenkins website](https://www.jenkins.io) for more details.
1. Review the plan output in your Controller's web UI.
1. Merge changes to production branch.
```
Expand Down Expand Up @@ -294,6 +294,7 @@ and only the corresponding environment is applied.
To use the `validate` option of the `tf-wrapper.sh` script, please follow the [instructions](https://cloud.google.com/docs/terraform/policy-validation/validate-policies#install) to install the terraform-tools component.
1. Export the network (`terraform-net-sa`) service account for impersonation `export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT="<IMPERSONATE_SERVICE_ACCOUNT>"`
1. Run `./tf-wrapper.sh init shared`.
1. Run `./tf-wrapper.sh plan shared` and review output.
1. Run `./tf-wrapper.sh validate shared $(pwd)/../policy-library <YOUR_CLOUD_BUILD_PROJECT_ID>` and check for violations.
Expand Down
Loading

0 comments on commit e13625a

Please sign in to comment.