Skip to content

Commit

Permalink
Merge pull request #369 from GoogleCloudPlatform/gh360-day0-deploy-ex…
Browse files Browse the repository at this point in the history
…ample

#360 - 0-bootstrap/1-org to 5-app-infra readme changes
  • Loading branch information
fmichaelobrien committed Apr 23, 2024
2 parents d7a918d + 1e4b3b9 commit 07100b1
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 53 deletions.
16 changes: 8 additions & 8 deletions 0-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ Using Terraform Cloud requires manual creation of the GitHub repositories or Git

**Note:** When deploying with cloud build is also possible to use a [script helper](../helpers/foundation-deployer/README.md) to do the deploy.

1. Clone [terraform-example-foundation](https://github.com/terraform-google-modules/terraform-example-foundation) into your local environment and navigate to the `0-bootstrap` folder.
1. Clone [terraform-example-foundation](https://github.com/GoogleCloudPlatform/pbmm-on-gcp-onboarding) into your local environment and navigate to the `0-bootstrap` folder.

```bash
git clone https://github.com/terraform-google-modules/terraform-example-foundation.git
git clone https://github.com/GoogleCloudPlatform/pbmm-on-gcp-onboarding.git
cd terraform-example-foundation/0-bootstrap
cd pbmm-on-gcp-onboarding/0-bootstrap
```

1. Rename `terraform.example.tfvars` to `terraform.tfvars` and update the file with values from your environment:
Expand Down Expand Up @@ -236,7 +236,7 @@ Using Terraform Cloud requires manual creation of the GitHub repositories or Git
```

1. (Optional) Run `terraform plan` to verify that state is configured correctly. You should see no changes from the previous state.
1. Clone the policy repo and copy contents of policy-library to new repo. Clone the repo at the same level of the `terraform-example-foundation` folder.
1. Clone the policy repo and copy contents of policy-library to new repo. Clone the repo at the same level of the `pbmm-on-gcp-onboarding` folder.

```bash
cd ../..
Expand All @@ -245,7 +245,7 @@ Using Terraform Cloud requires manual creation of the GitHub repositories or Git
cd gcp-policies
git checkout -b main
cp -RT ../terraform-example-foundation/policy-library/ .
cp -RT ../pbmm-on-gcp-onboarding/policy-library/ .
```

1. Commit changes and push your main branch to the policy repo.
Expand All @@ -271,9 +271,9 @@ Using Terraform Cloud requires manual creation of the GitHub repositories or Git
git checkout -b plan
mkdir -p envs/shared
cp -RT ../terraform-example-foundation/0-bootstrap/ ./envs/shared
cp ../terraform-example-foundation/build/cloudbuild-tf-* .
cp ../terraform-example-foundation/build/tf-wrapper.sh .
cp -RT ../pbmm-on-gcp-onboarding/0-bootstrap/ ./envs/shared
cp ../pbmm-on-gcp-onboarding/build/cloudbuild-tf-* .
cp ../pbmm-on-gcp-onboarding/build/tf-wrapper.sh .
chmod 755 ./tf-wrapper.sh
git add .
Expand Down
20 changes: 10 additions & 10 deletions 1-org/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ This module creates and applies [tags](https://cloud.google.com/resource-manager
### Deploying with Cloud Build

1. Clone the `gcp-org` repo based on the Terraform output from the `0-bootstrap` step.
Clone the repo at the same level of the `terraform-example-foundation` folder.
Clone the repo at the same level of the `pbmm-on-gcp-onboarding` folder.
If required, run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get the Cloud Build Project ID.

```bash
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="pbmm-on-gcp-onboarding/0-bootstrap/" output -raw cloudbuild_project_id)
echo ${CLOUD_BUILD_PROJECT_ID}

gcloud source repos clone gcp-org --project=${CLOUD_BUILD_PROJECT_ID}
Expand All @@ -134,9 +134,9 @@ If required, run `terraform output cloudbuild_project_id` in the `0-bootstrap` f
cd gcp-org
git checkout -b plan
cp -RT ../terraform-example-foundation/1-org/ .
cp ../terraform-example-foundation/build/cloudbuild-tf-* .
cp ../terraform-example-foundation/build/tf-wrapper.sh .
cp -RT ../pbmm-on-gcp-onboarding/1-org/ .
cp ../pbmm-on-gcp-onboarding/build/cloudbuild-tf-* .
cp ../pbmm-on-gcp-onboarding/build/tf-wrapper.sh .
chmod 755 ./tf-wrapper.sh
```

Expand All @@ -149,7 +149,7 @@ If required, run `terraform output cloudbuild_project_id` in the `0-bootstrap` f
1. Check if a Security Command Center notification with the default name, **scc-notify**, already exists. If it exists, choose a different value for the `scc_notification_name` variable in the `./envs/shared/terraform.tfvars` file.

```bash
export ORGANIZATION_ID=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -json common_config | jq '.org_id' --raw-output)
export ORGANIZATION_ID=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -json common_config | jq '.org_id' --raw-output)
gcloud scc notifications describe "scc-notify" --organization=${ORGANIZATION_ID}
```

Expand All @@ -163,7 +163,7 @@ If required, run `terraform output cloudbuild_project_id` in the `0-bootstrap` f
1. Update the `envs/shared/terraform.tfvars` file with values from your environment and 0-bootstrap step. If the previous step showed a numeric value, un-comment the variable `create_access_context_manager_access_policy = false`. See the shared folder [README.md](./envs/shared/README.md) for additional information on the values in the `terraform.tfvars` file.

```bash
export backend_bucket=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -raw gcs_bucket_tfstate)
export backend_bucket=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -raw gcs_bucket_tfstate)
echo "remote_state_bucket = ${backend_bucket}"
sed -i'' -e "s/REMOTE_STATE_BUCKET/${backend_bucket}/" ./envs/shared/terraform.tfvars
Expand Down Expand Up @@ -200,7 +200,7 @@ If required, run `terraform output cloudbuild_project_id` in the `0-bootstrap` f
If you received a `PERMISSION_DENIED` error while running the `gcloud access-context-manager` or the `gcloud scc notifications` commands, you can append the following to run the command as the Terraform service account:

```bash
--impersonate-service-account=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -raw organization_step_terraform_service_account_email)
--impersonate-service-account=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -raw organization_step_terraform_service_account_email)
```

### Deploying with Jenkins
Expand All @@ -213,11 +213,11 @@ See `0-bootstrap` [README-GitHub.md](../0-bootstrap/README-GitHub.md#deploying-s

### Running Terraform locally

1. The next instructions assume that you are at the same level of the `terraform-example-foundation` folder.
1. The next instructions assume that you are at the same level of the `pbmm-on-gcp-onboarding` folder.
Change into the `1-org` folder, copy the Terraform wrapper script, and ensure it can be executed.

```bash
cd terraform-example-foundation/1-org
cd pbmm-on-gcp-onboarding/1-org
cp ../build/tf-wrapper.sh .
chmod 755 ./tf-wrapper.sh
```
Expand Down
16 changes: 8 additions & 8 deletions 2-environments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ commands. The `-T` flag is needed for Linux, but causes problems for MacOS.
### Deploying with Cloud Build

1. Clone the `gcp-environments` repo based on the Terraform output from the `0-bootstrap` step.
Clone the repo at the same level of the `terraform-example-foundation` folder, the following instructions assume this layout.
Clone the repo at the same level of the `pbmm-on-gcp-onboarding` folder, the following instructions assume this layout.
Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get the Cloud Build Project ID.

```bash
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="pbmm-on-gcp-onboarding/0-bootstrap/" output -raw cloudbuild_project_id)
echo ${CLOUD_BUILD_PROJECT_ID}

gcloud source repos clone gcp-environments --project=${CLOUD_BUILD_PROJECT_ID}
Expand All @@ -108,9 +108,9 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
cd gcp-environments
git checkout -b plan
cp -RT ../terraform-example-foundation/2-environments/ .
cp ../terraform-example-foundation/build/cloudbuild-tf-* .
cp ../terraform-example-foundation/build/tf-wrapper.sh .
cp -RT ../pbmm-on-gcp-onboarding/2-environments/ .
cp ../pbmm-on-gcp-onboarding/build/cloudbuild-tf-* .
cp ../pbmm-on-gcp-onboarding/build/tf-wrapper.sh .
chmod 755 ./tf-wrapper.sh
```

Expand All @@ -123,7 +123,7 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
1. 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.

```bash
export backend_bucket=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -raw gcs_bucket_tfstate)
export backend_bucket=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -raw gcs_bucket_tfstate)
echo "remote_state_bucket = ${backend_bucket}"
sed -i'' -e "s/REMOTE_STATE_BUCKET/${backend_bucket}/" terraform.tfvars
Expand Down Expand Up @@ -182,10 +182,10 @@ See `0-bootstrap` [README-GitHub.md](../0-bootstrap/README-GitHub.md#deploying-s

### Run Terraform locally

1. The next instructions assume that you are at the same level of the `terraform-example-foundation` folder. Change into `2-environments` folder, copy the Terraform wrapper script and ensure it can be executed.
1. The next instructions assume that you are at the same level of the `pbmm-on-gcp-onboarding` folder. Change into `2-environments` folder, copy the Terraform wrapper script and ensure it can be executed.

```bash
cd terraform-example-foundation/2-environments
cd pbmm-on-gcp-onboarding/2-environments
cp ../build/tf-wrapper.sh .
chmod 755 ./tf-wrapper.sh
```
Expand Down
26 changes: 13 additions & 13 deletions 3-networks-hub-and-spoke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ The purpose of this step is to:
1. 0-bootstrap executed successfully.
1. 1-org executed successfully.
1. 2-environments executed successfully.
1. Obtain the value for the access_context_manager_policy_id variable. It can be obtained by running the following commands. We assume you are at the same level as directory `terraform-example-foundation`, If you run them from another directory, adjust your paths accordingly.
1. Obtain the value for the access_context_manager_policy_id variable. It can be obtained by running the following commands. We assume you are at the same level as directory `pbmm-on-gcp-onboarding`, If you run them from another directory, adjust your paths accordingly.

```bash
export ORGANIZATION_ID=$(terraform -chdir="terraform-example-foundation/0-bootstrap/" output -json common_config | jq '.org_id' --raw-output)
export ORGANIZATION_ID=$(terraform -chdir="pbmm-on-gcp-onboarding/0-bootstrap/" output -json common_config | jq '.org_id' --raw-output)
export ACCESS_CONTEXT_MANAGER_ID=$(gcloud access-context-manager policies list --organization ${ORGANIZATION_ID} --format="value(name)")
echo "access_context_manager_policy_id = ${ACCESS_CONTEXT_MANAGER_ID}"
```
Expand Down Expand Up @@ -146,11 +146,11 @@ If you are not able to use Dedicated or Partner Interconnect, you can also use a
### Deploying with Cloud Build

1. Clone the `gcp-networks` repo based on the Terraform output from the `0-bootstrap` step.
Clone the repo at the same level of the `terraform-example-foundation` folder, the following instructions assume this layout.
Clone the repo at the same level of the `pbmm-on-gcp-onboarding` folder, the following instructions assume this layout.
Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get the Cloud Build Project ID.

```bash
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="pbmm-on-gcp-onboarding/0-bootstrap/" output -raw cloudbuild_project_id)
echo ${CLOUD_BUILD_PROJECT_ID}
gcloud source repos clone gcp-networks --project=${CLOUD_BUILD_PROJECT_ID}
Expand All @@ -162,9 +162,9 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
cd gcp-networks/
git checkout -b plan
cp -RT ../terraform-example-foundation/3-networks-hub-and-spoke/ .
cp ../terraform-example-foundation/build/cloudbuild-tf-* .
cp ../terraform-example-foundation/build/tf-wrapper.sh .
cp -RT ../pbmm-on-gcp-onboarding/3-networks-hub-and-spoke/ .
cp ../pbmm-on-gcp-onboarding/build/cloudbuild-tf-* .
cp ../pbmm-on-gcp-onboarding/build/tf-wrapper.sh .
chmod 755 ./tf-wrapper.sh
```

Expand All @@ -182,13 +182,13 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
Use `terraform output` to get the backend bucket value from 0-bootstrap output.

```bash
export ORGANIZATION_ID=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -json common_config | jq '.org_id' --raw-output)
export ORGANIZATION_ID=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -json common_config | jq '.org_id' --raw-output)
export ACCESS_CONTEXT_MANAGER_ID=$(gcloud access-context-manager policies list --organization ${ORGANIZATION_ID} --format="value(name)")
echo "access_context_manager_policy_id = ${ACCESS_CONTEXT_MANAGER_ID}"
sed -i'' -e "s/ACCESS_CONTEXT_MANAGER_ID/${ACCESS_CONTEXT_MANAGER_ID}/" ./access_context.auto.tfvars
export backend_bucket=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -raw gcs_bucket_tfstate)
export backend_bucket=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -raw gcs_bucket_tfstate)
echo "remote_state_bucket = ${backend_bucket}"
sed -i'' -e "s/REMOTE_STATE_BUCKET/${backend_bucket}/" ./common.auto.tfvars
Expand All @@ -207,10 +207,10 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
1. Use `terraform output` to get the Cloud Build project ID and the networks step Terraform Service Account from 0-bootstrap output. An environment variable `GOOGLE_IMPERSONATE_SERVICE_ACCOUNT` will be set using the Terraform Service Account to enable impersonation.

```bash
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -raw cloudbuild_project_id)
echo ${CLOUD_BUILD_PROJECT_ID}
export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -raw networks_step_terraform_service_account_email)
export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -raw networks_step_terraform_service_account_email)
echo ${GOOGLE_IMPERSONATE_SERVICE_ACCOUNT}
```

Expand Down Expand Up @@ -285,10 +285,10 @@ See `0-bootstrap` [README-GitHub.md](../0-bootstrap/README-GitHub.md#deploying-s

### Run Terraform locally

1. The next instructions assume that you are at the same level of the `terraform-example-foundation` folder. Change into `3-networks-hub-and-spoke` folder, copy the Terraform wrapper script and ensure it can be executed.
1. The next instructions assume that you are at the same level of the `pbmm-on-gcp-onboarding` folder. Change into `3-networks-hub-and-spoke` folder, copy the Terraform wrapper script and ensure it can be executed.

```bash
cd terraform-example-foundation/3-networks-hub-and-spoke
cd pbmm-on-gcp-onboarding/3-networks-hub-and-spoke
cp ../build/tf-wrapper.sh .
chmod 755 ./tf-wrapper.sh
```
Expand Down
14 changes: 7 additions & 7 deletions 4-projects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Clone the repo at the same level of the `terraform-example-foundation` folder, t
Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get the Cloud Build Project ID.

```bash
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="pbmm-on-gcp-onboarding/0-bootstrap/" output -raw cloudbuild_project_id)
echo ${CLOUD_BUILD_PROJECT_ID}

gcloud source repos clone gcp-projects --project=${CLOUD_BUILD_PROJECT_ID}
Expand All @@ -106,9 +106,9 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
cd gcp-projects
git checkout -b plan
cp -RT ../terraform-example-foundation/4-projects/ .
cp ../terraform-example-foundation/build/cloudbuild-tf-* .
cp ../terraform-example-foundation/build/tf-wrapper.sh .
cp -RT ../pbmm-on-gcp-onboarding/4-projects/ .
cp ../pbmm-on-gcp-onboarding/build/cloudbuild-tf-* .
cp ../pbmm-on-gcp-onboarding/build/tf-wrapper.sh .
chmod 755 ./tf-wrapper.sh
```

Expand All @@ -128,7 +128,7 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
1. Use `terraform output` to get the backend bucket value from 0-bootstrap output.

```bash
export remote_state_bucket=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -raw gcs_bucket_tfstate)
export remote_state_bucket=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -raw gcs_bucket_tfstate)
echo "remote_state_bucket = ${remote_state_bucket}"
sed -i'' -e "s/REMOTE_STATE_BUCKET/${remote_state_bucket}/" ./common.auto.tfvars
Expand All @@ -146,10 +146,10 @@ Run `terraform output cloudbuild_project_id` in the `0-bootstrap` folder to get
1. Use `terraform output` to get the Cloud Build project ID and the projects step Terraform Service Account from 0-bootstrap output. An environment variable `GOOGLE_IMPERSONATE_SERVICE_ACCOUNT` will be set using the Terraform Service Account to enable impersonation.

```bash
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -raw cloudbuild_project_id)
export CLOUD_BUILD_PROJECT_ID=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -raw cloudbuild_project_id)
echo ${CLOUD_BUILD_PROJECT_ID}
export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -raw projects_step_terraform_service_account_email)
export GOOGLE_IMPERSONATE_SERVICE_ACCOUNT=$(terraform -chdir="../pbmm-on-gcp-onboarding/0-bootstrap/" output -raw projects_step_terraform_service_account_email)
echo ${GOOGLE_IMPERSONATE_SERVICE_ACCOUNT}
```

Expand Down
Loading

0 comments on commit 07100b1

Please sign in to comment.