I have a requirement to attach drives to a windows server VM in GCP and this has to be done in terraform. I am using terraform version 12.
We have 3 database servers that we need to get into terraform. The existing servers have drives mapped like this:
Data: E
Log: F
Backup: G
Currently the servers that I am building have the drives attached in this incorrect order and have the wrong letters assigned:
Log: D
Backup: E
Data: F
This is the code that I am using to create and attach the volumes:
// Create Data Disk
resource "google_compute_disk" "datadisk_instance1" {
name = var.data_disk_name_instance1
type = var.disk_type
size = var.data_disk_size
zone = var.zone1
snapshot = var.data_snapshot_name_instance1
physical_block_size_bytes = 4096
}
// Create Log Disk
resource "google_compute_disk" "logdisk_instance1" {
name = var.log_disk_name_instance1
type = var.disk_type
size = var.log_disk_size
zone = var.zone1
snapshot = var.log_snapshot_name_instance1
physical_block_size_bytes = 4096
}
// Create Backup Disk
resource "google_compute_disk" "backupdisk_instance1" {
name = var.backup_disk_name_instance1
type = var.disk_type
size = var.backup_disk_size
zone = var.zone1
snapshot = var.backup_snapshot_name_instance1
physical_block_size_bytes = 4096
}
// Attach Data disk
resource "google_compute_attached_disk" "datadiskattach_instance1" {
disk = google_compute_disk.datadisk_instance1.id
instance = google_compute_instance.instance1.id
}
// Attach Log Disk
resource "google_compute_attached_disk" "logdiskattach_instance1" {
disk = google_compute_disk.logdisk_instance1.id
instance = google_compute_instance.instance1.id
}
// Attach Backup disk
resource "google_compute_attached_disk" "backupdiskattach_instance1" {
disk = google_compute_disk.backupdisk_instance1.id
instance = google_compute_instance.instance1.id
}
The disks are being created from snapshots and the data must be preserved.
How can I attach these disks in the correct order and assign the correct drive letters?