|
|
|
|
@@ -8,6 +8,7 @@ This module can operate in two distinct modes:
|
|
|
|
|
In both modes, an optional service account can be created and assigned to either instances or template. If you need a managed instance group when using the module in template mode, refer to the [`compute-mig`](../compute-mig) module.
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
- [Instance using defaults](#instance-using-defaults)
|
|
|
|
|
- [Service account management](#service-account-management)
|
|
|
|
|
- [Disk management](#disk-management)
|
|
|
|
|
@@ -25,7 +26,6 @@ In both modes, an optional service account can be created and assigned to either
|
|
|
|
|
- [Instance template](#instance-template)
|
|
|
|
|
- [Instance group](#instance-group)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Instance using defaults
|
|
|
|
|
|
|
|
|
|
The simplest example leverages defaults for the boot disk image and size, and uses a service account created by the module. Multiple instances can be managed via the `instance_count` variable.
|
|
|
|
|
@@ -48,6 +48,7 @@ module "simple-vm-example" {
|
|
|
|
|
### Service account management
|
|
|
|
|
|
|
|
|
|
VM service accounts can be managed in three different ways:
|
|
|
|
|
|
|
|
|
|
- You can let the module create a service account for you by settting `service_account_create = true`
|
|
|
|
|
- You can use an existing service account by setting `service_account_create = false` (the default value) and passing the full email address of the service account to the `service_account` variable. This is useful, for example, if you want to reuse the service account from another previously created instance, or if you want to create the service account manually with the `iam-service-account` module. In this case, you probably also want to set `service_account_scopes` to `cloud-platform`.
|
|
|
|
|
- Lastly, you can use the default compute service account by setting `service_account_crate = false`. Please note that using the default compute service account is not recommended.
|
|
|
|
|
@@ -285,8 +286,10 @@ module "vm-with-gvnic" {
|
|
|
|
|
zone = "europe-west1-b"
|
|
|
|
|
name = "test"
|
|
|
|
|
boot_disk = {
|
|
|
|
|
image = google_compute_image.cos-gvnic.self_link
|
|
|
|
|
type = "pd-ssd"
|
|
|
|
|
initialize_params = {
|
|
|
|
|
image = google_compute_image.cos-gvnic.self_link
|
|
|
|
|
type = "pd-ssd"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
network_interfaces = [{
|
|
|
|
|
network = var.vpc.self_link
|
|
|
|
|
@@ -428,9 +431,6 @@ module "kms-vm-example" {
|
|
|
|
|
size = 10
|
|
|
|
|
}]
|
|
|
|
|
service_account_create = true
|
|
|
|
|
boot_disk = {
|
|
|
|
|
image = "projects/debian-cloud/global/images/family/debian-10"
|
|
|
|
|
}
|
|
|
|
|
encryption = {
|
|
|
|
|
encrypt_boot = true
|
|
|
|
|
kms_key_self_link = var.kms_key.self_link
|
|
|
|
|
@@ -439,7 +439,6 @@ module "kms-vm-example" {
|
|
|
|
|
# tftest modules=1 resources=3 inventory=cmek.yaml
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Instance template
|
|
|
|
|
|
|
|
|
|
This example shows how to use the module to manage an instance template that defines an additional attached disk for each instance, and overrides defaults for the boot disk image and service account.
|
|
|
|
|
@@ -455,7 +454,9 @@ module "cos-test" {
|
|
|
|
|
subnetwork = var.subnet.self_link
|
|
|
|
|
}]
|
|
|
|
|
boot_disk = {
|
|
|
|
|
image = "projects/cos-cloud/global/images/family/cos-stable"
|
|
|
|
|
initialize_params = {
|
|
|
|
|
image = "projects/cos-cloud/global/images/family/cos-stable"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
attached_disks = [
|
|
|
|
|
{
|
|
|
|
|
@@ -505,34 +506,34 @@ module "instance-group" {
|
|
|
|
|
|
|
|
|
|
| name | description | type | required | default |
|
|
|
|
|
|---|---|:---:|:---:|:---:|
|
|
|
|
|
| [name](variables.tf#L181) | Instance name. | <code>string</code> | ✓ | |
|
|
|
|
|
| [network_interfaces](variables.tf#L186) | Network interfaces configuration. Use self links for Shared VPC, set addresses to null if not needed. | <code title="list(object({ nat = optional(bool, false) network = string subnetwork = string addresses = optional(object({ internal = string external = string }), null) alias_ips = optional(map(string), {}) nic_type = optional(string) }))">list(object({…}))</code> | ✓ | |
|
|
|
|
|
| [project_id](variables.tf#L223) | Project id. | <code>string</code> | ✓ | |
|
|
|
|
|
| [zone](variables.tf#L282) | Compute zone. | <code>string</code> | ✓ | |
|
|
|
|
|
| [name](variables.tf#L182) | Instance name. | <code>string</code> | ✓ | |
|
|
|
|
|
| [network_interfaces](variables.tf#L187) | Network interfaces configuration. Use self links for Shared VPC, set addresses to null if not needed. | <code title="list(object({ nat = optional(bool, false) network = string subnetwork = string addresses = optional(object({ internal = string external = string }), null) alias_ips = optional(map(string), {}) nic_type = optional(string) }))">list(object({…}))</code> | ✓ | |
|
|
|
|
|
| [project_id](variables.tf#L224) | Project id. | <code>string</code> | ✓ | |
|
|
|
|
|
| [zone](variables.tf#L283) | Compute zone. | <code>string</code> | ✓ | |
|
|
|
|
|
| [attached_disk_defaults](variables.tf#L17) | Defaults for attached disks options. | <code title="object({ auto_delete = optional(bool, false) mode = string replica_zone = string type = string })">object({…})</code> | | <code title="{ auto_delete = true mode = "READ_WRITE" replica_zone = null type = "pd-balanced" }">{…}</code> |
|
|
|
|
|
| [attached_disks](variables.tf#L38) | Additional disks, if options is null defaults will be used in its place. Source type is one of 'image' (zonal disks in vms and template), 'snapshot' (vm), 'existing', and null. | <code title="list(object({ name = string device_name = optional(string) size = string source = optional(string) source_type = optional(string) options = optional( object({ auto_delete = optional(bool, false) mode = optional(string, "READ_WRITE") replica_zone = optional(string) type = optional(string, "pd-balanced") }), { auto_delete = true mode = "READ_WRITE" replica_zone = null type = "pd-balanced" } ) }))">list(object({…}))</code> | | <code>[]</code> |
|
|
|
|
|
| [boot_disk](variables.tf#L82) | Boot disk properties. | <code title="object({ auto_delete = optional(bool, true) image = optional(string, "projects/debian-cloud/global/images/family/debian-11") size = optional(number, 10) type = optional(string, "pd-balanced") })">object({…})</code> | | <code title="{ auto_delete = true image = "projects/debian-cloud/global/images/family/debian-11" type = "pd-balanced" size = 10 }">{…}</code> |
|
|
|
|
|
| [can_ip_forward](variables.tf#L98) | Enable IP forwarding. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [confidential_compute](variables.tf#L104) | Enable Confidential Compute for these instances. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [create_template](variables.tf#L110) | Create instance template instead of instances. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [description](variables.tf#L115) | Description of a Compute Instance. | <code>string</code> | | <code>"Managed by the compute-vm Terraform module."</code> |
|
|
|
|
|
| [enable_display](variables.tf#L121) | Enable virtual display on the instances. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [encryption](variables.tf#L127) | Encryption options. Only one of kms_key_self_link and disk_encryption_key_raw may be set. If needed, you can specify to encrypt or not the boot disk. | <code title="object({ encrypt_boot = optional(bool, false) disk_encryption_key_raw = optional(string) kms_key_self_link = optional(string) })">object({…})</code> | | <code>null</code> |
|
|
|
|
|
| [group](variables.tf#L137) | Define this variable to create an instance group for instances. Disabled for template use. | <code title="object({ named_ports = map(number) })">object({…})</code> | | <code>null</code> |
|
|
|
|
|
| [hostname](variables.tf#L145) | Instance FQDN name. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [iam](variables.tf#L151) | IAM bindings in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
|
|
|
|
| [instance_type](variables.tf#L157) | Instance type. | <code>string</code> | | <code>"f1-micro"</code> |
|
|
|
|
|
| [labels](variables.tf#L163) | Instance labels. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [metadata](variables.tf#L169) | Instance metadata. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [min_cpu_platform](variables.tf#L175) | Minimum CPU platform. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [options](variables.tf#L201) | Instance options. | <code title="object({ allow_stopping_for_update = optional(bool, true) deletion_protection = optional(bool, false) spot = optional(bool, false) termination_action = optional(string) })">object({…})</code> | | <code title="{ allow_stopping_for_update = true deletion_protection = false spot = false termination_action = null }">{…}</code> |
|
|
|
|
|
| [scratch_disks](variables.tf#L228) | Scratch disks configuration. | <code title="object({ count = number interface = string })">object({…})</code> | | <code title="{ count = 0 interface = "NVME" }">{…}</code> |
|
|
|
|
|
| [service_account](variables.tf#L240) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [service_account_create](variables.tf#L246) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [service_account_scopes](variables.tf#L254) | Scopes applied to service account. | <code>list(string)</code> | | <code>[]</code> |
|
|
|
|
|
| [shielded_config](variables.tf#L260) | Shielded VM configuration of the instances. | <code title="object({ enable_secure_boot = bool enable_vtpm = bool enable_integrity_monitoring = bool })">object({…})</code> | | <code>null</code> |
|
|
|
|
|
| [tag_bindings](variables.tf#L270) | Tag bindings for this instance, in key => tag value id format. | <code>map(string)</code> | | <code>null</code> |
|
|
|
|
|
| [tags](variables.tf#L276) | Instance network tags for firewall rule targets. | <code>list(string)</code> | | <code>[]</code> |
|
|
|
|
|
| [boot_disk](variables.tf#L82) | Boot disk properties. | <code title="object({ auto_delete = optional(bool, true) source = optional(string) initialize_params = optional(object({ image = optional(string, "projects/debian-cloud/global/images/family/debian-11") size = optional(number, 10) type = optional(string, "pd-balanced") })) })">object({…})</code> | | <code title="{ initialize_params = {} }">{…}</code> |
|
|
|
|
|
| [can_ip_forward](variables.tf#L99) | Enable IP forwarding. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [confidential_compute](variables.tf#L105) | Enable Confidential Compute for these instances. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [create_template](variables.tf#L111) | Create instance template instead of instances. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [description](variables.tf#L116) | Description of a Compute Instance. | <code>string</code> | | <code>"Managed by the compute-vm Terraform module."</code> |
|
|
|
|
|
| [enable_display](variables.tf#L122) | Enable virtual display on the instances. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [encryption](variables.tf#L128) | Encryption options. Only one of kms_key_self_link and disk_encryption_key_raw may be set. If needed, you can specify to encrypt or not the boot disk. | <code title="object({ encrypt_boot = optional(bool, false) disk_encryption_key_raw = optional(string) kms_key_self_link = optional(string) })">object({…})</code> | | <code>null</code> |
|
|
|
|
|
| [group](variables.tf#L138) | Define this variable to create an instance group for instances. Disabled for template use. | <code title="object({ named_ports = map(number) })">object({…})</code> | | <code>null</code> |
|
|
|
|
|
| [hostname](variables.tf#L146) | Instance FQDN name. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [iam](variables.tf#L152) | IAM bindings in {ROLE => [MEMBERS]} format. | <code>map(list(string))</code> | | <code>{}</code> |
|
|
|
|
|
| [instance_type](variables.tf#L158) | Instance type. | <code>string</code> | | <code>"f1-micro"</code> |
|
|
|
|
|
| [labels](variables.tf#L164) | Instance labels. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [metadata](variables.tf#L170) | Instance metadata. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [min_cpu_platform](variables.tf#L176) | Minimum CPU platform. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [options](variables.tf#L202) | Instance options. | <code title="object({ allow_stopping_for_update = optional(bool, true) deletion_protection = optional(bool, false) spot = optional(bool, false) termination_action = optional(string) })">object({…})</code> | | <code title="{ allow_stopping_for_update = true deletion_protection = false spot = false termination_action = null }">{…}</code> |
|
|
|
|
|
| [scratch_disks](variables.tf#L229) | Scratch disks configuration. | <code title="object({ count = number interface = string })">object({…})</code> | | <code title="{ count = 0 interface = "NVME" }">{…}</code> |
|
|
|
|
|
| [service_account](variables.tf#L241) | Service account email. Unused if service account is auto-created. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [service_account_create](variables.tf#L247) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
|
|
|
|
|
| [service_account_scopes](variables.tf#L255) | Scopes applied to service account. | <code>list(string)</code> | | <code>[]</code> |
|
|
|
|
|
| [shielded_config](variables.tf#L261) | Shielded VM configuration of the instances. | <code title="object({ enable_secure_boot = bool enable_vtpm = bool enable_integrity_monitoring = bool })">object({…})</code> | | <code>null</code> |
|
|
|
|
|
| [tag_bindings](variables.tf#L271) | Tag bindings for this instance, in key => tag value id format. | <code>map(string)</code> | | <code>null</code> |
|
|
|
|
|
| [tags](variables.tf#L277) | Instance network tags for firewall rule targets. | <code>list(string)</code> | | <code>[]</code> |
|
|
|
|
|
|
|
|
|
|
## Outputs
|
|
|
|
|
|
|
|
|
|
|