Skip to content

intel/terraform-intel-gcp-vm

Intel Logo

Intel® Optimized Cloud Modules for Terraform

© Copyright 2024, Intel Corporation

GCP VM module

This module provides the functionality to ensure that you are utilizing Intel's latest generation processor in the creation of a virtual machine in GCP.

Performance Data

Find all the information below plus even more by navigating our full library

Link Link

Link

Link

Link

Link

Link

Link

Link

Link

=======

Usage

See examples folder for code ./examples/gcp-linux-vm/main.tf

Example of main.tf

# You will need to provide value of the variable project, which is your GCP project id when you do terraform apply

module "linux_vm" {
  source              = "intel/gcp-vm/intel"
  project             = var.project
  boot_image_family   = "ubuntu-2204-lts"
  name                = "this-is-a-linux-vm"
  access_config = [{
    nat_ip                 = null
    public_ptr_domain_name = null
    network_tier           = "PREMIUM"
  }, ]
}

Run Terraform

terraform init  
terraform plan
terraform apply -var="project=<your_your_gcp_project_id>"

Note that this example may create resources. Run terraform destroy when you don't need these resources anymore.

Considerations

  • The VM is created using the default network
  • The VM has a public IP address. If you want your VM to not have a public IP

Requirements

Name Version
terraform >= 1.6
google ~> 6.5

Providers

Name Version
google ~> 6.5

Modules

No modules.

Resources

Name Type
google_compute_instance.instance resource
google_compute_image.image data source

Inputs

Name Description Type Default Required
access_config Access configurations, i.e. IPs via which this instance can be accessed via the Internet. Omit to ensure that the instance is not accessible from the Internet. If omitted, ssh provisioners will not work unless Terraform can send traffic to the instance's network. This can be represented as multiple maps
list(object({
nat_ip = optional(string, null)
public_ptr_domain_name = optional(string)
network_tier = optional(string)
}))
[] no
allow_stopping_for_update If true, allows Terraform to stop the instance to update its properties bool null no
automatic_restart Specifies if the instance should be restarted if it was terminated by Compute Engine (not a user). bool true no
boot_disk_auto_delete Whether the disk will be auto-deleted when the instance is deleted. bool true no
boot_disk_byo_encryption_key A 256-bit [customer-supplied encryption key] (https://cloud.google.com/compute/docs/disks/customer-supplied-encryption), encoded in RFC 4648 base64 to encrypt this disk. string null no
boot_disk_labels A set of key/value label pairs assigned to the disk. This field is only applicable for persistent disks. map(string) {} no
boot_disk_mode The mode in which to attach this disk, either READ_WRITE or READ_ONLY. string "READ_WRITE" no
boot_disk_size Size of the OS disk number 500 no
boot_disk_source The name or self_link of the existing disk (such as those managed by google_compute_disk) or disk image. string null no
boot_disk_type Disk type associated with the OS disk. Values can be either pd-ssd, local-ssd, or pd-standard string null no
boot_image_family The image from which to initialize this disk string "ubuntu-2204-lts" no
boot_image_project The ID of the project in which the source image resides. string "ubuntu-os-cloud" no
can_ip_forward Conditional that allows sending and receiving of packets with non-matching source or destination IPs. bool false no
confidential_instance_type n/a string null no
deletion_protection Enable deletion protection on this instance bool false no
description A brief description of this resource string "Intel accelerated virtual machine." no
desired_status Desired status of the instance. string "RUNNING" no
enable_confidential_compute n/a bool false no
enable_integrity_monitoring Compare the most recent boot measurements to the integrity policy baseline and return a pair of pass/fail results depending on whether they match or not. bool true no
enable_nested_virtualization Boolean that specifies if nested virtualization should be enabled or disabled on the instance. bool false no
enable_secure_boot Verify the digital signature of all boot components, and halt the boot process if signature verification fails. bool false no
enable_vtpm Use a virtualized trusted platform module, which is a specialized computer chip you can use to encrypt objects like keys and certificates. bool true no
hostname A custom hostname for the instance. Must be a fully qualified DNS name and RFC-1035-valid string null no
ipv6_access_config Access configurations, i.e. IPs via which this instance can be accessed via the Internet. Omit to ensure that the instance is not accessible from the Internet. If omitted, ssh provisioners will not work unless Terraform can send traffic to the instance's network. This can be represented as multiple maps
list(object({
public_ptr_domain_name = optional(string, null)
network_tier = optional(string, null)
}))
[] no
machine_type The machine type to create string "c4-standard-4" no
name A unique name for the resource, required by GCE. Changing this forces a new resource to be created. string n/a yes
network The name or self_link of the network to attach this interface to. string "default" no
network_ip The private IP address to assign to the instance. If empty, the address will be automatically assigned. string "" no
nic_type The type of vNIC to be used on this compute instance. string null no
on_host_maintenance Describes maintenance behavior for the instance. Can be MIGRATE or TERMINATE string "MIGRATE" no
preemptible Specifies if the instance is preemptible. If this field is set to true, then automatic_restart must be set to false. bool false no
project The ID of the project in which the resource resides. string "" no
provisioning_model Describe the type of preemptible VM. This field accepts the value STANDARD or SPOT string "STANDARD" no
service_account Service account and scopes that will be associated with the GCE instance.
object({
service_email = optional(string, null)
scopes = optional(set(string), [])
})
{} no
stack_type he stack type for this network interface to identify whether the IPv6 feature is enabled or not. string "IPV4_ONLY" no
subnetwork The name or self_link of the subnetwork to attach this interface to. Either network or subnetwork must be provided. string null no
subnetwork_project The project in which the subnetwork belongs. If the subnetwork is a name and this field is not provided, the provider project is used. string null no
tags A list of network tags to attach to the instance list(string) [] no
termination_action The action that will be applied to the instance when it is terminated. string null no
threads_per_core The action that will be applied to the instance when it is terminated. number null no
user_data User data to be placed on the instance. Used to place cloud-init on VMs string null no
visible_core_count The number of physical cores to expose to an instance. number null no
zone The zone that the machine should be created in. If it is not provided, the provider zone is used. string null no

Outputs

Name Description
boot_disk_size Size of the boot disk of the instance
cpu_platform The CPU platform of the VM instance
current_status Current status of the VM instance
id An identifier for the resource
instance_id The server-assigned unique identifier of this instance
machine_type Type of the machine created
min_cpu_platform Minimum CPU platform for the VM instance
name Unique name of the instance created
private_ip Internal IP address of the instance
public_ip Public IP address of the instance
self_link The URI of the created resource