You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
support for tpm and secureboot flags for compute_instance (#452)
# Description
Support for
[TPM](https://openapi-v2.exoscale.com/operation/operation-create-instance#operation-create-instance-body-application-json-tpm-enabled)
and
[SecureBoot](https://openapi-v2.exoscale.com/operation/operation-create-instance#operation-create-instance-body-application-json-secureboot-enabled)
flags for compute_instance
## Checklist
(For exoscale contributors)
* [x] Changelog updated (under *Unreleased* block)
* [x] Acceptance tests OK
* [x] For a new resource, datasource or new attributes: acceptance test
added/updated
## Testing
```
# Providers
# -> providers.tf
# Customizable parameters
locals {
my_zone = "ch-gva-2"
}
data "exoscale_template" "my_template" {
zone = "ch-gva-2"
name = "Linux Ubuntu 22.04 LTS 64-bit"
}
resource "exoscale_compute_instance" "my_instance" {
zone = "ch-gva-2"
name = "my-instance-ho"
enable_tpm = true
enable_secure_boot = true
template_id = data.exoscale_template.my_template.id
type = "standard.medium"
disk_size = 10
}
```
**CREATING**
```
terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# exoscale_compute_instance.my_instance will be created
+ resource "exoscale_compute_instance" "my_instance" {
+ created_at = (known after apply)
+ disk_size = 10
+ enable_secure_boot = true
+ enable_tpm = true
+ id = (known after apply)
+ ipv6 = false
+ ipv6_address = (known after apply)
+ mac_address = (known after apply)
+ name = "my-instance-ho"
+ private = false
+ private_network_ids = (known after apply)
+ public_ip_address = (known after apply)
+ state = (known after apply)
+ template_id = "f9950b1f-8c1b-4957-8be5-22061a0a3a0b"
+ type = "standard.medium"
+ zone = "ch-gva-2"
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
exoscale_compute_instance.my_instance: Creating...
exoscale_compute_instance.my_instance: Still creating... [10s elapsed]
exoscale_compute_instance.my_instance: Creation complete after 13s [id=240e7f09-5d1b-415a-b230-afe7a37bf693]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
```
<img width="1498" height="817" alt="Screenshot 2025-07-21 at 14 45 46"
src="https://github.com/user-attachments/assets/bb0e87bc-a81d-44ab-bb7a-4704ccafbdd0"
/>
**ENABLING TPM**
```
exoscale/terraform terraform apply
data.exoscale_template.my_template: Reading...
data.exoscale_template.my_template: Read complete after 1s [id=f9950b1f-8c1b-4957-8be5-22061a0a3a0b]
exoscale_compute_instance.my_instance: Refreshing state... [id=a53f01f2-597b-417d-8196-174cda068b23]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# exoscale_compute_instance.my_instance will be updated in-place
~ resource "exoscale_compute_instance" "my_instance" {
~ enable_tpm = false -> true
id = "a53f01f2-597b-417d-8196-174cda068b23"
name = "my-instance"
~ security_group_ids = [
- "757ee92c-d1a5-4161-bb7c-4adebe3d388d",
]
# (16 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
exoscale_compute_instance.my_instance: Modifying... [id=a53f01f2-597b-417d-8196-174cda068b23]
exoscale_compute_instance.my_instance: Still modifying... [id=a53f01f2-597b-417d-8196-174cda068b23, 10s elapsed]
exoscale_compute_instance.my_instance: Still modifying... [id=a53f01f2-597b-417d-8196-174cda068b23, 20s elapsed]
exoscale_compute_instance.my_instance: Modifications complete after 26s [id=a53f01f2-597b-417d-8196-174cda068b23]
```
**DISABLING TPM**
```
exoscale/terraform terraform apply
data.exoscale_template.my_template: Reading...
data.exoscale_template.my_template: Read complete after 1s [id=f9950b1f-8c1b-4957-8be5-22061a0a3a0b]
exoscale_compute_instance.my_instance: Refreshing state... [id=43e251de-0da7-4022-a0ec-ee2e99bb9cba]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# exoscale_compute_instance.my_instance will be updated in-place
~ resource "exoscale_compute_instance" "my_instance" {
~ enable_tpm = true -> false
id = "43e251de-0da7-4022-a0ec-ee2e99bb9cba"
name = "my-instance"
# (17 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
exoscale_compute_instance.my_instance: Modifying... [id=43e251de-0da7-4022-a0ec-ee2e99bb9cba]
╷
│ Error: TPM can't be disabled
│
│ with exoscale_compute_instance.my_instance,
│ on main.tf line 14, in resource "exoscale_compute_instance" "my_instance":
│ 14: resource "exoscale_compute_instance" "my_instance" {
│
╵
```
**ENABLING_SECURE_BOOT**
```
exoscale/terraform terraform apply
data.exoscale_template.my_template: Reading...
data.exoscale_template.my_template: Read complete after 1s [id=f9950b1f-8c1b-4957-8be5-22061a0a3a0b]
exoscale_compute_instance.my_instance: Refreshing state... [id=43e251de-0da7-4022-a0ec-ee2e99bb9cba]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
# exoscale_compute_instance.my_instance must be replaced
-/+ resource "exoscale_compute_instance" "my_instance" {
~ created_at = "2025-08-12 11:24:52 +0000 UTC" -> (known after apply)
~ enable_secure_boot = false -> true # forces replacement
~ enable_tpm = true -> false
~ id = "43e251de-0da7-4022-a0ec-ee2e99bb9cba" -> (known after apply)
+ ipv6_address = (known after apply)
- labels = {} -> null
~ mac_address = "06:f1:d6:00:00:6b" -> (known after apply)
name = "my-instance"
~ private_network_ids = [] -> (known after apply)
~ public_ip_address = "159.100.241.212" -> (known after apply)
- security_group_ids = [] -> null
- ssh_keys = [] -> null
~ state = "running" -> (known after apply)
# (8 unchanged attributes hidden)
}
Plan: 1 to add, 0 to change, 1 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
exoscale_compute_instance.my_instance: Destroying... [id=43e251de-0da7-4022-a0ec-ee2e99bb9cba]
exoscale_compute_instance.my_instance: Destruction complete after 4s
exoscale_compute_instance.my_instance: Creating...
exoscale_compute_instance.my_instance: Still creating... [10s elapsed]
exoscale_compute_instance.my_instance: Creation complete after 10s [id=b7b5a18e-9c79-4f4e-b7da-6691daa5222c]
Apply complete! Resources: 1 added, 0 changed, 1 destroyed.
```
**DISABLING SECURE_BOOT**
```
exoscale/terraform terraform apply
data.exoscale_template.my_template: Reading...
data.exoscale_template.my_template: Read complete after 1s [id=f9950b1f-8c1b-4957-8be5-22061a0a3a0b]
exoscale_compute_instance.my_instance: Refreshing state... [id=b7b5a18e-9c79-4f4e-b7da-6691daa5222c]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
# exoscale_compute_instance.my_instance must be replaced
-/+ resource "exoscale_compute_instance" "my_instance" {
~ created_at = "2025-08-12 11:45:46 +0000 UTC" -> (known after apply)
~ enable_secure_boot = true -> false # forces replacement
~ id = "b7b5a18e-9c79-4f4e-b7da-6691daa5222c" -> (known after apply)
+ ipv6_address = (known after apply)
- labels = {} -> null
~ mac_address = "06:86:2e:00:00:6b" -> (known after apply)
name = "my-instance"
~ private_network_ids = [] -> (known after apply)
~ public_ip_address = "159.100.241.212" -> (known after apply)
- security_group_ids = [
- "757ee92c-d1a5-4161-bb7c-4adebe3d388d",
] -> null
- ssh_keys = [] -> null
~ state = "running" -> (known after apply)
# (9 unchanged attributes hidden)
}
Plan: 1 to add, 0 to change, 1 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
exoscale_compute_instance.my_instance: Destroying... [id=b7b5a18e-9c79-4f4e-b7da-6691daa5222c]
exoscale_compute_instance.my_instance: Destruction complete after 6s
exoscale_compute_instance.my_instance: Creating...
exoscale_compute_instance.my_instance: Still creating... [10s elapsed]
exoscale_compute_instance.my_instance: Creation complete after 10s [id=16c98b85-960c-4eb8-8924-fcf8d64e0697]
Apply complete! Resources: 1 added, 0 changed, 1 destroyed.
```
---------
Co-authored-by: Predrag Janosevic <[email protected]>
Copy file name to clipboardExpand all lines: docs/resources/compute_instance.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,6 +55,8 @@ directory for complete configuration examples.
55
55
-`deploy_target_id` (String) ❗ A deploy target ID.
56
56
-`destroy_protected` (Boolean) Mark the instance as protected, the Exoscale API will refuse to delete the instance until the protection is removed (boolean; default: `false`).
57
57
-`elastic_ip_ids` (Set of String) A list of [exoscale_elastic_ip](./elastic_ip.md) (IDs) to attach to the instance.
58
+
-`enable_secure_boot` (Boolean) Indicates whether secure boot is enabled on the instance.
59
+
-`enable_tpm` (Boolean) Indicates whether TPM is enabled on the instance.
58
60
-`ipv6` (Boolean) Enable IPv6 on the instance (boolean; default: `false`).
59
61
-`labels` (Map of String) A map of key/value labels.
60
62
-`network_interface` (Block Set) Private network interfaces (may be specified multiple times). Structure is documented below. (see [below for nested schema](#nestedblock--network_interface))
Description: "Enable secure boot on the instance (boolean; default: `false`). Can not be changed after the creation.",
62
+
Type: schema.TypeBool,
63
+
Optional: true,
64
+
ForceNew: true,
65
+
},
66
+
AttrEnableTPM: {
67
+
Description: "Enable TPM on the instance (boolean; default: `false`). Can not be disabled after the creation. **WARNING**: enabling this attribute stops/restarts the instance.",
68
+
Type: schema.TypeBool,
69
+
Optional: true,
70
+
Default: false,
71
+
},
60
72
AttrIPv6: {
61
73
Description: "Enable IPv6 on the instance (boolean; default: `false`).",
62
74
Type: schema.TypeBool,
@@ -284,6 +296,16 @@ func rCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag
0 commit comments