-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Terraform Version
Terraform v1.9.8
on darwin_arm64
Terraform Configuration
data "outscale_snapshots" "root" {
filter {
name = "tag_keys"
values = ["Name"]
}
filter {
name = "tag_keys"
values = ["VolumeType"]
}
filter {
name = "tag_values"
values = ["root"]
}
}
data "outscale_snapshots" "app" {
filter {
name = "tag_keys"
values = ["Name"]
}
filter {
name = "tag_keys"
values = ["VolumeType"]
}
filter {
name = "tag_values"
values = ["application"]
}
}
locals {
snapshots_by_vm = {
for vm in var.vms : vm.vm_name => {
root = reverse([
for s in data.outscale_snapshots.root.snapshots :
s.snapshot_id
if lookup({ for t in s.tags : t.key => t.value }, "Name", "") == vm.vm_name
])
app = reverse([
for s in data.outscale_snapshots.app.snapshots :
s.snapshot_id
if lookup({ for t in s.tags : t.key => t.value }, "Name", "") == vm.vm_name
])
}
}
}
resource "outscale_vm" "vm-001" {
for_each = { for vm in var.vms : vm.vm_name => vm }
image_id = each.value.image_id
vm_type = each.value.vm_type
private_ips = each.value.private_ip
keypair_name = each.value.keypair_name
subnet_id = each.value.subnet_id
security_group_ids = [each.value.sg_id]
dynamic "block_device_mappings" {
for_each = try(each.value.block_devices, [])
content {
device_name = block_device_mappings.value.device_name
bsu {
snapshot_id = var.env == "pra" ? (
block_device_mappings.value.device_name != "/dev/sda1"
? try(lookup(local.snapshots_by_vm, each.key, { root = [], app = [] }).root[0], null)
: try(lookup(local.snapshots_by_vm, each.key, { root = [], app = [] }).app[0], null)
) : null
volume_size = try(block_device_mappings.value.volume_size, null)
volume_type = block_device_mappings.value.volume_type
iops = lookup(block_device_mappings.value, "iops", null)
delete_on_vm_deletion = lookup(block_device_mappings.value, "delete_on_vm_deletion", null)
dynamic "tags" {
for_each = block_device_mappings.value.tags == null ? {} : block_device_mappings.value.tags
content {
key = tags.key
value = tags.value
}
}
}
}
}
dynamic "tags" {
for_each = try(each.value.tags, {})
content {
key = tags.key
value = tags.value
}
}
}
Debug Output (optional)
No response
Crash Output (if applicable)
No response
Expected Behavior
i expected that terraform will create à VM with 2 disks (root+data) from snapshots
Actual Behavior
Error 8016
│ Error: error launching source VM: 400 Bad Request: {"Errors":[{"Type":"OperationNotSupported","Details":"","Code":"8016"}],"ResponseContext":{"RequestId":"86bb0487-085d-439a-8b0c-ffbdfc371a23"}}
│
│ with outscale_vm.vm-001["pgtrust01.mid.prod.dc03.ce"],
│ on main.tf line 48, in resource "outscale_vm" "vm-001":
│ 48: resource "outscale_vm" "vm-001" {
Steps to Reproduce
terraform init
terraform plan
terraform apply
Additional Context
I have tested with OAPI-CLI (osc-cli) and this operation was succeded
References
No response