-
Notifications
You must be signed in to change notification settings - Fork 778
feat: add confidential space #1435
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
Merged
apeabody
merged 6 commits into
terraform-google-modules:main
from
renato-rudnicki:confidential_space_instance
Oct 3, 2025
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5fb198f
Feat: add confidential space
renato-rudnicki 610a07d
fixes for PR review
renato-rudnicki 5d09b1a
Merge branch 'main' into confidential_space_instance
renato-rudnicki e61c776
added gemini-code review
renato-rudnicki 456592f
change roler for terraform-image-iam resource
renato-rudnicki ae775b5
update documentai.googleapis.com
renato-rudnicki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ data "terraform_remote_state" "bootstrap" { | |
prefix = "terraform/bootstrap/state" | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ data "terraform_remote_state" "bootstrap" { | |
prefix = "terraform/bootstrap/state" | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ data "terraform_remote_state" "bootstrap" { | |
prefix = "terraform/bootstrap/state" | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2025 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM alpine:latest | ||
renato-rudnicki marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
WORKDIR /confidential | ||
COPY confidential_data /confidential | ||
ENTRYPOINT ["/confidential/confidential_data"] | ||
CMD [] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright 2025 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
renato-rudnicki marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
|
||
#!/bin/bash | ||
echo "Confidential space is running!" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,60 @@ | |
*/ | ||
|
||
locals { | ||
repo_names = ["bu1-example-app"] | ||
repo_names = ["bu1-example-app"] | ||
cmd_prompt = "gcloud builds submit . --tag ${local.confidential_space_image_tag} --project=${local.cloudbuild_project_id} --service-account=projects/${local.cloudbuild_project_id}/serviceAccounts/tf-cb-builder-sa@${local.cloudbuild_project_id}.iam.gserviceaccount.com --gcs-log-dir=gs://${module.infra_pipelines[0].log_buckets["bu1-example-app"]} --worker-pool=${local.cloud_build_private_worker_pool_id} || ( sleep 46 && gcloud builds submit . --tag ${local.confidential_space_image_tag} --project=${local.cloudbuild_project_id} --service-account=projects/${local.cloudbuild_project_id}/serviceAccounts/tf-cb-builder-sa@${local.cloudbuild_project_id}.iam.gserviceaccount.com --gcs-log-dir=gs://${module.infra_pipelines[0].log_buckets["bu1-example-app"]} --worker-pool=${local.cloud_build_private_worker_pool_id})" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
confidential_space_image_version = "latest" | ||
confidential_space_image_tag = "${var.default_region}-docker.pkg.dev/${local.cloudbuild_project_id}/tf-runners/confidential_space_image:${local.confidential_space_image_version}" | ||
|
||
iam_roles_build = [ | ||
"roles/storage.objectAdmin", | ||
"roles/cloudbuild.builds.builder", | ||
] | ||
} | ||
|
||
resource "google_project_iam_member" "build_roles" { | ||
for_each = toset(local.iam_roles_build) | ||
project = local.cloudbuild_project_id | ||
role = each.key | ||
member = "serviceAccount:tf-cb-builder-sa@${local.cloudbuild_project_id}.iam.gserviceaccount.com" | ||
} | ||
|
||
resource "google_project_iam_member" "bucket_admin_binding" { | ||
project = local.cloudbuild_project_id | ||
role = "roles/storage.objectAdmin" | ||
member = "serviceAccount:${local.projects_terraform_sa}" | ||
} | ||
|
||
resource "google_artifact_registry_repository_iam_member" "builder_on_artifact_registry" { | ||
project = local.cloudbuild_project_id | ||
location = var.default_region | ||
repository = "tf-runners" | ||
role = "roles/artifactregistry.repoAdmin" | ||
member = "serviceAccount:${module.app_infra_cloudbuild_project[0].sa}" | ||
} | ||
|
||
resource "google_project_iam_member" "cloudbuild_logging" { | ||
project = local.cloudbuild_project_id | ||
role = "roles/logging.logWriter" | ||
member = "serviceAccount:${module.app_infra_cloudbuild_project[0].sa}" | ||
} | ||
|
||
resource "google_project_iam_member" "workload_identity_admin" { | ||
project = module.app_infra_cloudbuild_project[0].project_id | ||
role = "roles/iam.workloadIdentityPoolAdmin" | ||
member = "serviceAccount:${module.app_infra_cloudbuild_project[0].sa}" | ||
} | ||
|
||
resource "google_storage_bucket_iam_member" "cloudbuild_storage_read" { | ||
bucket = module.infra_pipelines[0].log_buckets["bu1-example-app"] | ||
role = "roles/storage.admin" | ||
member = "serviceAccount:${module.app_infra_cloudbuild_project[0].sa}" | ||
} | ||
|
||
resource "google_storage_bucket_iam_member" "cloudbuild_sa_storage_admin" { | ||
bucket = module.infra_pipelines[0].log_buckets["bu1-example-app"] | ||
role = "roles/storage.admin" | ||
member = "serviceAccount:tf-cb-builder-sa@${local.cloudbuild_project_id}.iam.gserviceaccount.com" | ||
} | ||
|
||
module "app_infra_cloudbuild_project" { | ||
|
@@ -37,7 +90,8 @@ module "app_infra_cloudbuild_project" { | |
"cloudkms.googleapis.com", | ||
"iam.googleapis.com", | ||
"artifactregistry.googleapis.com", | ||
"cloudresourcemanager.googleapis.com" | ||
"cloudresourcemanager.googleapis.com", | ||
"confidentialcomputing.googleapis.com" | ||
] | ||
# Metadata | ||
project_suffix = "infra-pipeline" | ||
|
@@ -62,6 +116,35 @@ module "infra_pipelines" { | |
private_worker_pool_id = local.cloud_build_private_worker_pool_id | ||
} | ||
|
||
resource "time_sleep" "wait_iam_propagation" { | ||
create_duration = "60s" | ||
|
||
depends_on = [ | ||
module.infra_pipelines, | ||
module.app_infra_cloudbuild_project, | ||
google_project_iam_member.bucket_admin_binding, | ||
google_storage_bucket_iam_member.cloudbuild_storage_read, | ||
google_artifact_registry_repository_iam_member.builder_on_artifact_registry, | ||
google_project_iam_member.cloudbuild_logging, | ||
google_storage_bucket_iam_member.cloudbuild_sa_storage_admin, | ||
] | ||
} | ||
renato-rudnicki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
module "build_confidential_space_image" { | ||
source = "terraform-google-modules/gcloud/google" | ||
version = "~> 4.0" | ||
upgrade = false | ||
module_depends_on = [time_sleep.wait_iam_propagation] | ||
|
||
create_cmd_triggers = { | ||
"tag_version" = local.confidential_space_image_version | ||
"cmd_prompt" = local.cmd_prompt | ||
} | ||
|
||
create_cmd_entrypoint = "bash" | ||
create_cmd_body = "${local.cmd_prompt} || ( sleep 45 && ${local.cmd_prompt})" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
/** | ||
* When Jenkins CI/CD is used for deployment this resource | ||
* is created to terraform validation works. | ||
|
@@ -72,3 +155,5 @@ module "infra_pipelines" { | |
resource "null_resource" "jenkins_cicd" { | ||
count = !local.enable_cloudbuild_deploy ? 1 : 0 | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,4 @@ variable "project_deletion_policy" { | |
type = string | ||
default = "PREVENT" | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.