Skip to content

Commit

Permalink
Add Confidential Computing examples to google_compute_instance and go…
Browse files Browse the repository at this point in the history
…ogle_compute_instance_template resources (#11518)
  • Loading branch information
arthurlapertosa authored Aug 22, 2024
1 parent 4f4a488 commit 20924a3
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,57 @@ resource "google_compute_instance" "default" {
}
```

## Example usage - Confidential Computing

Example with [Confidential Mode](https://cloud.google.com/confidential-computing/confidential-vm/docs/confidential-vm-overview) activated.

```tf
resource "google_service_account" "default" {
account_id = "my-custom-sa"
display_name = "Custom SA for VM Instance"
}
resource "google_compute_instance" "confidential_instance" {
name = "my-confidential-instance"
zone = "us-central1-a"
machine_type = "n2d-standard-2"
min_cpu_platform = "AMD Milan"
confidential_instance_config {
enable_confidential_compute = true
confidential_instance_type = "SEV"
}
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-2004-lts"
labels = {
my_label = "value"
}
}
}
// Local SSD disk
scratch_disk {
interface = "NVME"
}
network_interface {
network = "default"
access_config {
// Ephemeral public IP
}
}
service_account {
# Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles.
email = google_service_account.default.email
scopes = ["cloud-platform"]
}
}
```

## Argument Reference

The following arguments are supported:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,47 @@ With this setup Terraform generates a unique name for your Instance
Template and can then update the Instance Group manager without conflict before
destroying the previous Instance Template.

## Example usage - Confidential Computing

Example with [Confidential Mode](https://cloud.google.com/confidential-computing/confidential-vm/docs/confidential-vm-overview) activated.

```tf
resource "google_service_account" "default" {
account_id = "my-custom-sa"
display_name = "Custom SA for VM Instance"
}
resource "google_compute_instance_template" "confidential_instance_template" {
name = "my-confidential-instance-template"
region = "us-central1"
machine_type = "n2d-standard-2"
min_cpu_platform = "AMD Milan"
confidential_instance_config {
enable_confidential_compute = true
confidential_instance_type = "SEV"
}
disk {
source_image = "ubuntu-os-cloud/ubuntu-2004-lts"
}
network_interface {
network = "default"
access_config {
// Ephemeral public IP
}
}
service_account {
# Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles.
email = google_service_account.default.email
scopes = ["cloud-platform"]
}
}
```

## Deploying the Latest Image

A common way to use instance templates and managed instance groups is to deploy the
Expand Down

0 comments on commit 20924a3

Please sign in to comment.