Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
ae79488
add confidential space
renato-rudnicki Jun 18, 2025
836cf18
add variables and update APIs
renato-rudnicki Jun 18, 2025
a728d6f
change kms resource to module
renato-rudnicki Jun 18, 2025
61b95d0
fix remote
renato-rudnicki Jun 18, 2025
ea77081
creates a new module for confidential space
renato-rudnicki Jun 20, 2025
0ba1a7f
code fixes
renato-rudnicki Jun 20, 2025
49332f8
fixes code review
renato-rudnicki Jun 20, 2025
f6c4042
update docker image build
renato-rudnicki Jun 23, 2025
1c6abb5
Updating SAs and CB infra
renato-rudnicki Jun 23, 2025
da0ab4d
remove comment
renato-rudnicki Jun 23, 2025
de42d46
fix worker_pool_id value
renato-rudnicki Jun 24, 2025
ba8333c
update log buckets
renato-rudnicki Jun 27, 2025
bfae511
fix cloudbuild for confidential space
renato-rudnicki Jun 27, 2025
9edc576
allow confidential computing api
renato-rudnicki Jul 1, 2025
1cfb138
allow cloudbuild workpool use
renato-rudnicki Jul 1, 2025
07cf62b
update confidential space
renato-rudnicki Jul 2, 2025
2684d16
sync with local code
renato-rudnicki Jul 4, 2025
7661264
fix roles
renato-rudnicki Jul 16, 2025
d31ee08
fix header
renato-rudnicki Jul 16, 2025
6628e32
add soft link for confidential space
renato-rudnicki Jul 17, 2025
40cfa4f
remove hardcode value
renato-rudnicki Jul 17, 2025
b2f59c1
Improved description for image_digest variable
renato-rudnicki Jul 17, 2025
29b6ff4
remove output
renato-rudnicki Jul 17, 2025
3307062
move workload SA and roles to step-4
renato-rudnicki Jul 18, 2025
8a570b7
remove comment
renato-rudnicki Jul 18, 2025
9fed2c2
update code
renato-rudnicki Aug 1, 2025
8efe5d4
fix lint
renato-rudnicki Aug 4, 2025
164c68c
adds header to salary.go
renato-rudnicki Aug 4, 2025
e3fc96d
add readme for confidential space
renato-rudnicki Aug 4, 2025
bb022da
Update 4-project
renato-rudnicki Aug 4, 2025
38482e7
update README
renato-rudnicki Aug 5, 2025
b86f124
update README
renato-rudnicki Aug 5, 2025
d46463f
add links in the readme
renato-rudnicki Aug 5, 2025
51607af
add integration tests
renato-rudnicki Aug 5, 2025
6028d87
update readme
renato-rudnicki Aug 5, 2025
cff60ba
code update
renato-rudnicki Aug 15, 2025
3016463
update 4-projects/README.md
renato-rudnicki Aug 15, 2025
f33d11c
code update for helper
renato-rudnicki Aug 15, 2025
3f5a009
update README and permissions for helper deploy
renato-rudnicki Aug 20, 2025
71635bf
remove duplicated code
renato-rudnicki Aug 20, 2025
30f19cd
add builder role to tf-cb-builder-sa
renato-rudnicki Aug 21, 2025
9868414
update google_project_iam_member roles
renato-rudnicki Aug 26, 2025
316aa78
fix roles and SA
renato-rudnicki Aug 27, 2025
df74f43
updates 1 from code-review
renato-rudnicki Aug 29, 2025
f8fd2d0
fix code review-2
renato-rudnicki Sep 1, 2025
f471283
remove code not used
renato-rudnicki Sep 1, 2025
ed6904a
update integration tests
renato-rudnicki Sep 4, 2025
9707d23
fix lint
renato-rudnicki Sep 5, 2025
59aab46
Merge branch 'main' into confidential-space
renato-rudnicki Sep 5, 2025
92113e5
fix build submit cmd
renato-rudnicki Sep 8, 2025
a7d8408
fix key value for log_buckets
renato-rudnicki Sep 8, 2025
5a9c174
fix storage bucket project
renato-rudnicki Sep 8, 2025
a04b4c9
fix bucket syntax name
renato-rudnicki Sep 8, 2025
0a81171
fix roles and propagation
renato-rudnicki Sep 10, 2025
339b91d
fix storage role for projects SA
renato-rudnicki Sep 10, 2025
6ad60ab
fix roles for 4-projects
renato-rudnicki Sep 11, 2025
340c7d0
remove cloudbuild_bucket_admin resource -test
renato-rudnicki Sep 11, 2025
ac8bc2e
add missing variable for projects_test.go
renato-rudnicki Sep 12, 2025
1ff8ed8
fix image_digest variable
renato-rudnicki Sep 12, 2025
263c75e
update image_digest variable
renato-rudnicki Sep 12, 2025
5265adf
Merge branch 'main' into confidential-space
renato-rudnicki Sep 12, 2025
834d3e6
Merge branch 'main' into confidential-space
renato-rudnicki Sep 15, 2025
1ae2a99
Merge branch 'main' into confidential-space
renato-rudnicki Sep 18, 2025
d4a9927
fix confidential project ID for integration tests
renato-rudnicki Sep 18, 2025
5c6c8c0
fix confidential instance name
renato-rudnicki Sep 19, 2025
5dad2e7
update app_infra test
renato-rudnicki Sep 22, 2025
3024385
fix integration test app-infra
renato-rudnicki Sep 23, 2025
4ceee3e
fix list for confidential instance output
renato-rudnicki Sep 23, 2025
01e91f6
fix computeInstanceList
renato-rudnicki Sep 24, 2025
ffaafa2
add output for confidential instance
renato-rudnicki Sep 24, 2025
68e6c23
fix workload identity test
renato-rudnicki Sep 24, 2025
16a9fd6
fix test for workload pool
renato-rudnicki Sep 24, 2025
1677a26
fix for workload pool provider
renato-rudnicki Sep 24, 2025
2774bf3
update integration tests app-infra
renato-rudnicki Sep 25, 2025
2a96062
update test
renato-rudnicki Sep 25, 2025
08bb4e0
fix integration test
renato-rudnicki Sep 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions 4-projects/business_unit_1/development/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
* limitations under the License.
*/

output "confidential_space_project" { ///added
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove ///added

description = "Confidential Space project id."
value = module.env.confidential_space_project
}

output "confidential_space_project_number" { ///added
description = "Confidential Space project number."
value = module.env.confidential_space_project_number
}

output "floating_project" {
description = "Project sample floating project."
value = module.env.floating_project
Expand Down
10 changes: 10 additions & 0 deletions 4-projects/business_unit_1/nonproduction/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
* limitations under the License.
*/

output "confidential_space_project" { ///added
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove ///added

description = "Confidential Space project id."
value = module.env.confidential_space_project
}

output "confidential_space_project_number" { ///added
description = "Confidential Space project number."
value = module.env.confidential_space_project_number
}

output "floating_project" {
description = "Project sample floating project."
value = module.env.floating_project
Expand Down
10 changes: 10 additions & 0 deletions 4-projects/business_unit_1/production/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
* limitations under the License.
*/

output "confidential_space_project" { ///added
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove ///added

description = "Confidential Space project id."
value = module.env.confidential_space_project
}

output "confidential_space_project_number" { ///added
description = "Confidential Space project number."
value = module.env.confidential_space_project_number
}

output "floating_project" {
description = "Project sample floating project."
value = module.env.floating_project
Expand Down
56 changes: 56 additions & 0 deletions 4-projects/modules/base_env/example_confidential_space_project.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Copyright 2021 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.
*/

module "confidential_space_project" {
source = "../single_project"

org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.env_business_unit.name
environment = var.env
vpc = "svpc"
shared_vpc_host_project_id = local.shared_vpc_host_project_id
shared_vpc_subnets = local.subnets_self_links
project_budget = var.project_budget
project_prefix = local.project_prefix
project_deletion_policy = var.project_deletion_policy

enable_cloudbuild_deploy = local.enable_cloudbuild_deploy
app_infra_pipeline_service_accounts = local.app_infra_pipeline_service_accounts

sa_roles = {
"${var.business_code}-confidential-instance" = [
"roles/compute.instanceAdmin.v1",
"roles/iam.serviceAccountUser",
"roles/iam.serviceAccountAdmin",
]
}

activate_apis = ["accesscontextmanager.googleapis.com"]
vpc_service_control_attach_enabled = local.enforce_vpcsc ? "true" : "false"
vpc_service_control_attach_dry_run = !local.enforce_vpcsc ? "true" : "false"
vpc_service_control_perimeter_name = "accessPolicies/${local.access_context_manager_policy_id}/servicePerimeters/${local.perimeter_name}"
vpc_service_control_sleep_duration = "60s"

# Metadata
project_suffix = "conf-space" //add
application_name = "${var.business_code}-sample-instance"
billing_code = "1234"
primary_contact = "[email protected]"
secondary_contact = "[email protected]"
business_code = var.business_code
}

10 changes: 10 additions & 0 deletions 4-projects/modules/base_env/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
* limitations under the License.
*/

output "confidential_space_project" { ///added
description = "Confidential Space project id."
value = module.confidential_space_project.project_id
}

output "confidential_space_project_number" { ///added
description = "Confidential Space project number."
value = module.confidential_space_project.project_number
}

output "floating_project" {
description = "Project sample floating project."
value = module.floating_project.project_id
Expand Down
1 change: 1 addition & 0 deletions 4-projects/modules/base_env/remote.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ locals {
perimeter_name = data.terraform_remote_state.network_env.outputs.service_perimeter_name
network_self_link = data.terraform_remote_state.network_env.outputs.network_self_link
shared_vpc_host_project_id = data.terraform_remote_state.network_env.outputs.shared_vpc_host_project_id
confidential_space_project_id = data.terraform_remote_state.network_env.outputs.shared_vpc_host_project_id
subnets_self_links = data.terraform_remote_state.network_env.outputs.subnets_self_links
access_context_manager_policy_id = data.terraform_remote_state.network_env.outputs.access_context_manager_policy_id
enforce_vpcsc = data.terraform_remote_state.network_env.outputs.enforce_vpcsc
Expand Down
10 changes: 10 additions & 0 deletions 5-app-infra/business_unit_1/development/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ module "peering_gce_instance" {
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}

module "confidential_space_instance" {
source = "../../modules/env_base"

environment = local.environment
business_unit = local.business_unit
project_suffix = "conf-space"
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}
10 changes: 10 additions & 0 deletions 5-app-infra/business_unit_1/nonproduction/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ module "peering_gce_instance" {
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}

module "confidential_space_instance" {
source = "../../modules/env_base"

environment = local.environment
business_unit = local.business_unit
project_suffix = "conf-space"
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}
10 changes: 10 additions & 0 deletions 5-app-infra/business_unit_1/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,13 @@ module "peering_gce_instance" {
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}

module "confidential_space_instance" {
source = "../../modules/env_base"

environment = local.environment
business_unit = local.business_unit
project_suffix = "conf-space"
region = coalesce(var.instance_region, local.default_region)
remote_state_bucket = var.remote_state_bucket
}
128 changes: 128 additions & 0 deletions 5-app-infra/modules/env_base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ locals {
"sample-floating" = data.terraform_remote_state.projects_env.outputs.floating_project,
"sample-peering" = data.terraform_remote_state.projects_env.outputs.peering_project,
"sample-svpc" = data.terraform_remote_state.projects_env.outputs.shared_vpc_project,
"conf-space" = data.terraform_remote_state.projects_env.outputs.confidential_space_project,//added
}
env_project_subnets = {
"sample-floating" = local.svpc_subnetwork_self_link,
"sample-peering" = data.terraform_remote_state.projects_env.outputs.peering_subnetwork_self_link,
"sample-svpc" = local.svpc_subnetwork_self_link,
"conf-space" = local.svpc_subnetwork_self_link, //added
}
env_project_resource_manager_tags = {
"sample-floating" = null,
"sample-peering" = data.terraform_remote_state.projects_env.outputs.iap_firewall_tags,
"sample-svpc" = null,
"conf-space" = null,//added
}

subnetwork_self_links = data.terraform_remote_state.projects_env.outputs.subnets_self_links
Expand Down Expand Up @@ -88,3 +91,128 @@ module "compute_instance" {
instance_template = module.instance_template.self_link
resource_manager_tags = local.resource_manager_tags
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pode remover essa linha extra



///confidential space
////
module "confidential_instance_template" {
source = "terraform-google-modules/vm/google//modules/instance_template"
version = "~> 13.0"

region = var.region
project_id = local.env_project_id
subnetwork = local.subnetwork_self_link

#name_prefix = "confidential-space-template"
source_image_project = "confidential-space-images"
source_image = "confidential-space"
machine_type = "n2d-standard-2"
min_cpu_platform = "AMD Milan"
enable_confidential_vm = true
confidential_instance_type = "SEV"

shielded_instance_config = {
enable_secure_boot = true
enable_vtpm = true
enable_integrity_monitoring = true
}

metadata = {
tee-image-reference = "us-central1-docker.pkg.dev/prj-p-bu1-sample-peering-cue4/prj-p-bu1-sample-repo/prj-p-bu1-repo:latest"

}

service_account = {
email = google_service_account.compute_engine_service_account.email
scopes = ["cloud-platform"]
}
}

module "confidential_compute_instance" {
source = "terraform-google-modules/vm/google//modules/compute_instance"
version = "~> 13.0"

region = var.region
subnetwork_project = local.subnetwork_project
subnetwork = local.subnetwork_self_link
num_instances = var.num_instances
hostname = "confidential-instance"
instance_template = module.confidential_instance_template.self_link
resource_manager_tags = local.resource_manager_tags
}

resource "google_service_account" "workload_sa" {
account_id = "confidential-space-workload-sa"
display_name = "Workload Service Account for confidential space"
project = local.env_project_id
}

resource "google_project_service" "enabled_services" {
project = local.env_project_id

service = [
"cloudkms.googleapis.com",
"artifactregistry.googleapis.com",
"iamcredentials.googleapis.com",
"compute.googleapis.com",
"confidentialcomputing.googleapis.com"
]
}

resource "google_project_iam_member" "workload_sa_user" {
project = local.env_project_id
role = "roles/iam.serviceAccountUser"
member = "user:${data.google_client_config.default.account_id}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
member = "user:${data.google_client_config.default.account_id}"
member = var.confidential_space_workload_operator"

não existe data.google_client_config no codigo e vc tem que perguntar para o usuario

}

resource "google_project_iam_member" "workload_sa_confidential_user" {
project = local.env_project_id
role = "roles/confidentialcomputing.workloadUser"
member = "serviceAccount:${google_service_account.workload_sa.email}"
}

resource "google_project_iam_member" "workload_sa_logging_writer" {
project = local.env_project_id
role = "roles/logging.logWriter"
member = "serviceAccount:${google_service_account.workload_sa.email}"
}

resource "google_artifact_registry_repository" "ar_confidential_space" {
repository_id = "ar-confidential-space"
format = "DOCKER"
location = "us"
project = local.env_project_id
}

resource "google_artifact_registry_repository_iam_member" "artifact_registry_reader" {
repository = google_artifact_registry_repository.ar_confidential_space.id
location = google_artifact_registry_repository.ar_confidential_space.location
role = "roles/artifactregistry.reader"
member = "serviceAccount:${google_service_account.workload_sa.email}"
}

resource "google_kms_key_ring" "workload_keyring" {
name = "workload-key-ring"
location = "global"
project = local.env_project_id
}

resource "google_kms_crypto_key" "workload_key" {
name = "workload-key"
key_ring = google_kms_key_ring.workload_keyring.id
purpose = "ENCRYPT_DECRYPT"
}

resource "google_kms_crypto_key_iam_member" "key_decrypter" {
crypto_key_id = google_kms_crypto_key.workload_key.id
role = "roles/cloudkms.cryptoKeyDecrypter"
member = "serviceAccount:${google_service_account.workload_sa.email}"

condition {
expression = "request.auth.claims.google.container.image_digest == 'sha256:HASH-GERADO-PELO-DIGEST'"
title = "RequireAttestedImage"
description = "OnlyAllowTrustedImage"
}
}

Loading