-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add confidential space #131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 33 commits
ae79488
836cf18
a728d6f
61b95d0
ea77081
0ba1a7f
49332f8
f6c4042
1c6abb5
da0ab4d
de42d46
ba8333c
bfae511
9edc576
1cfb138
07cf62b
2684d16
7661264
d31ee08
6628e32
40cfa4f
b2f59c1
29b6ff4
3307062
8a570b7
9fed2c2
8efe5d4
164c68c
e3fc96d
bb022da
38482e7
b86f124
d46463f
51607af
6028d87
cff60ba
3016463
f33d11c
3f5a009
71635bf
30f19cd
9868414
316aa78
df74f43
f8fd2d0
f471283
ed6904a
9707d23
59aab46
92113e5
a7d8408
5a9c174
a04b4c9
0a81171
339b91d
6ad60ab
340c7d0
ac8bc2e
1ff8ed8
263c75e
5265adf
834d3e6
1ae2a99
d4a9927
5c6c8c0
5dad2e7
3024385
4ceee3e
01e91f6
ffaafa2
68e6c23
16a9fd6
1677a26
2774bf3
2a96062
08bb4e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,7 +57,7 @@ For an overview of the architecture and the parts, see the | |
|
|
||
| The purpose of this step is to set up the folder structure, projects, and infrastructure pipelines for applications that are connected as service projects to the shared VPC created in the previous stage. | ||
|
|
||
| For each business unit, a shared `infra-pipeline` project is created along with Cloud Build triggers, CSRs for application infrastructure code and Google Cloud Storage buckets for state storage. | ||
| For each business unit, a shared `infra-pipeline` project is created along with Cloud Build triggers, CSRs for application infrastructure code and Google Cloud Storage buckets for state storage. A new Docker image will be built for the Confidential Space environment, which will be used in the `5-app-infra` step. | ||
|
|
||
| This step follows the same [conventions](https://github.com/terraform-google-modules/terraform-example-foundation#branching-strategy) as the Foundation pipeline deployed in [0-bootstrap](https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/0-bootstrap/README.md). | ||
| A custom [workspace](https://github.com/terraform-google-modules/terraform-google-bootstrap/blob/master/modules/tf_cloudbuild_workspace/README.md) (`bu1-example-app`) is created by this pipeline and necessary roles are granted to the Terraform Service Account of this workspace by enabling variable `sa_roles` as shown in this [example](https://github.com/terraform-google-modules/terraform-example-foundation/blob/master/4-projects/modules/base_env/example_shared_vpc_project.tf). | ||
|
|
@@ -201,6 +201,13 @@ grep -rl 10.3.64.0 business_unit_2/ | xargs sed -i 's/10.3.64.0/10.4.64.0/g' | |
| git checkout -b production | ||
| git push origin production | ||
| ``` | ||
| 1. Run `terraform init` in the `production` folder to generate the outputs required by step `5-app-infra`. | ||
|
|
||
| ```bash | ||
| cd business_unit_1/production | ||
| terraform init | ||
| cd ../.. | ||
| ``` | ||
|
||
|
|
||
| 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), | ||
|
|
@@ -211,6 +218,14 @@ grep -rl 10.3.64.0 business_unit_2/ | xargs sed -i 's/10.3.64.0/10.4.64.0/g' | |
| git push origin development | ||
| ``` | ||
|
|
||
| 1. Run `terraform init` in the `development` folder to generate the outputs required by step `5-app-infra`. | ||
|
|
||
| ```bash | ||
| cd business_unit_1/development | ||
| terraform init | ||
| cd ../.. | ||
| ``` | ||
|
||
|
|
||
| 1. After development has been applied, apply nonproduction. | ||
| 1. Merge changes to nonproduction. 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_. Review the apply output in your Cloud Build project. https://console.cloud.google.com/cloud-build/builds;region=DEFAULT_REGION?project=YOUR_CLOUD_BUILD_PROJECT_ID | ||
|
|
@@ -220,6 +235,14 @@ grep -rl 10.3.64.0 business_unit_2/ | xargs sed -i 's/10.3.64.0/10.4.64.0/g' | |
| git push origin nonproduction | ||
| ``` | ||
|
|
||
| 1. Run `terraform init` in the `nonproduction` folder to generate the outputs required by step `5-app-infra`. | ||
|
|
||
| ```bash | ||
| cd business_unit_1/nonproduction | ||
| terraform init | ||
| cd ../.. | ||
| ``` | ||
|
|
||
|
||
| 1. Before executing the next step, unset the `GOOGLE_IMPERSONATE_SERVICE_ACCOUNT` environment variable. | ||
|
|
||
| ```bash | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,3 +38,88 @@ module "env" { | |
| project_deletion_policy = var.project_deletion_policy | ||
| folder_deletion_protection = var.folder_deletion_protection | ||
| } | ||
|
|
||
| resource "google_service_account" "workload_sa" { | ||
| account_id = "confidential-space-workload-sa" | ||
| display_name = "Workload Service Account for confidential space" | ||
| project = module.env.confidential_space_project | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "service_usage_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/serviceusage.serviceUsageAdmin" | ||
| member = google_service_account.workload_sa.member | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "service_account_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/iam.serviceAccountAdmin" | ||
| member = google_service_account.workload_sa.member | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "workload_kms_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/cloudkms.admin" | ||
| member = google_service_account.workload_sa.member | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "workload_instance_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/compute.instanceAdmin.v1" | ||
| member = google_service_account.workload_sa.member | ||
| } | ||
|
||
|
|
||
| resource "google_project_iam_member" "cb_workload_identity_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/iam.workloadIdentityPoolAdmin" | ||
| member = "serviceAccount:${module.env.cloudbuild_sa}" | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "cb_service_usage_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/serviceusage.serviceUsageAdmin" | ||
| member = "serviceAccount:${module.env.cloudbuild_sa}" | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "cb_service_account_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/iam.serviceAccountAdmin" | ||
| member = "serviceAccount:${module.env.cloudbuild_sa}" | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "cloudbuild_kms_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/cloudkms.admin" | ||
| member = "serviceAccount:${module.env.cloudbuild_sa}" | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "cloudbuild_instance_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/compute.instanceAdmin.v1" | ||
| member = "serviceAccount:${module.env.cloudbuild_sa}" | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "cloudbuild_gcs_admin_sa" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/storage.admin" | ||
| member = "serviceAccount:${module.env.cloudbuild_sa}" | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "cloudbuild_project_iam_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/resourcemanager.projectIamAdmin" | ||
| member = "serviceAccount:${module.env.cloudbuild_sa}" | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "workload_identity_admin" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/iam.workloadIdentityPoolAdmin" | ||
| member = "serviceAccount:${google_service_account.workload_sa.email}" | ||
| } | ||
|
|
||
| resource "google_project_iam_member" "workload_identity_admin_cb" { | ||
| project = module.env.confidential_space_project | ||
| role = "roles/iam.workloadIdentityPoolAdmin" | ||
| member = "serviceAccount:${module.env.cloudbuild_sa}" | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,11 @@ | |
| */ | ||
|
|
||
| locals { | ||
| default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region | ||
| default_region_2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2 | ||
| default_region_gcs = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_gcs | ||
| default_region_kms = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_kms | ||
| default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region | ||
| default_region_2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2 | ||
| default_region_gcs = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_gcs | ||
| default_region_kms = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_kms | ||
| cloudbuild_project_id = data.terraform_remote_state.bootstrap.outputs.cloudbuild_project_id | ||
|
||
| } | ||
|
|
||
| data "terraform_remote_state" "bootstrap" { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.