-
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 1 commit
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 |
|---|---|---|
|
|
@@ -14,6 +14,16 @@ | |
| * limitations under the License. | ||
| */ | ||
|
|
||
| output "confidential_space_project" { ///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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,16 @@ | |
| * limitations under the License. | ||
| */ | ||
|
|
||
| output "confidential_space_project" { ///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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /** | ||
| * Copyright 2021 Google LLC | ||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * 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"] | ||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
|
@@ -88,3 +91,128 @@ module "compute_instance" { | |||||
| instance_template = module.instance_template.self_link | ||||||
| resource_manager_tags = local.resource_manager_tags | ||||||
| } | ||||||
|
|
||||||
daniel-cit marked this conversation as resolved.
Show resolved
Hide resolved
Collaborator
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. 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" | ||||||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| source_image_project = "confidential-space-images" | ||||||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| source_image = "confidential-space" | ||||||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| machine_type = "n2d-standard-2" | ||||||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| min_cpu_platform = "AMD Milan" | ||||||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| enable_confidential_vm = true | ||||||
| confidential_instance_type = "SEV" | ||||||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| 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" | ||||||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| } | ||||||
|
|
||||||
| 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" | ||||||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| 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" | ||||||
| ] | ||||||
daniel-cit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| } | ||||||
|
|
||||||
| 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}" | ||||||
|
||||||
| 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
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.
remove
///added