Deploy in Google Cloud (one or more) VMs with none, one or more data disks using HashiCorp Terraform
- Internal Address (you can specify an IP)
- External Address (with decision to use or not)
- Boot Disk
- Data Disks (with decidion: none, one or more)
- Atacched Disk (how many you need according data disks)
- Google Compute Instance (how many you need)
Describes requirements for using this module.
The following dependencies must be available:
- Terraform>= v0.13.5.
- Terraform google provider>= v3.87.0.
- Terraform google-beta provider>= v3.87.0.
Ensure the you have a service account with following roles:
-
Clone the repository:
git clone https://github.com/taynantofanini/terraform-gcp-multiples-vms-and-data-disks.git
-
Go to module folder
cd terraform-gcp-multiples-vms-and-data-disks
-
Change variable values in terraform.tfvars and backend path in settings.tf for your envrionment.
-
Run the following Terraform commands:
-
Examine configuration files:
terraform init terraform validate terraform plan
-
Apply the configurations:
terraform apply
-
Confirm configurations:
terraform output terraform show
-
To destroy resources:
terraform plan -destroy terraform destroy terraform show
-
gcp_auth_file = "auth/authfile.json" # put your auth file name
project_id = "your-project-id"
allvms = {
"vm1" = {
vm_name = "vm-name-1"
machine_type = "n1-standard-1"
region = "us-east1"
zone = "us-east1-c"
disk_image = "ubuntu-os-cloud/ubuntu-1804-lts"
disk_type = "pd-standard"
disk_size = "10"
network = "default"
subnetwork = "default"
vm_internal_ip = null # set a internal ip or null
vm_external_ip_enabeled = "yes" # yes to create external ip or no
data_disks = { # how many you want, duplicating the block "data-disk"
"data-disk-1" = {
data_disk_type = "pd-standard"
data_disk_size = "10"
}
# "data-disk-2" = {
# data_disk_type = "pd-standard"
# data_disk_size = "20"
# }
}
}
"vm2" = {
vm_name = "vm-name-2"
machine_type = "n1-standard-1"
region = "us-east1"
zone = "us-east1-c"
disk_image = "ubuntu-os-cloud/ubuntu-1804-lts"
disk_type = "pd-standard"
disk_size = "10"
network = "default"
subnetwork = "default"
vm_internal_ip = null
vm_external_ip_enabeled = "no"
data_disks = {
"data-disk-1" = {
data_disk_type = "pd-standard"
data_disk_size = "10"
}
"data-disk-2" = {
data_disk_type = "pd-standard"
data_disk_size = "20"
}
"data-disk-3" = {
data_disk_type = "pd-standard"
data_disk_size = "25"
}
}
}
}