Closed silex27 closed 2 months ago
Hello, Thanks for reporting the issue.
If you are trying to add tags like this:
dynamic "block_device_mappings" {
for_each = each.value.volumes
content {
device_name = block_device_mappings.value.device_name
tags {
key = "Name"
value = "ah"
}
bsu {
volume_size = block_device_mappings.value.size
volume_type = try(block_device_mappings.value.disk_type, var.default_disk_type)
delete_on_vm_deletion = true
iops = try(block_device_mappings.value.iops, 13000)
}
}
}
Then you are not trying to add a tag to a volume, but to the block_device_mappings
elements of the Vms.
Documented here: https://registry.terraform.io/providers/outscale/outscale/latest/docs/resources/vm#block_device_mappings.
Otherwise, this issue seems hard to reproduce not knowing what is inside local.vm_map
, and not knowing how you try to add tags.
Also according to documentation, tags are available inside Images
and Vms
, but not inside block_device_mappings
Hello tf var's
//VM LIST
vm_list = flatten([
for category_key, category in local.categories_list : [
for vm in category.vms : {
"category_name" = category.name
"vm_type" = category.vm_type
"image_id" = try(category.image_id , var.image_id)
"vm_details" = vm
"volumes" = category.volumes
}
]
])
// VM MAP GROUP BY VM_NAME
vm_map = { for vm in local.vm_list : vm.vm_details.name => vm }
This is what I use in values :
prefix: "DB-TEST-OUTSCALE"
- name: TEST-UPGRADE-DB
vm_type: tinav5.c2r4p1
volumes:
- device_name: /dev/sda1
size: 10
vms:
- name: TEST-UPGRADE-DB-1
private_ip: 10.0.13.170
security_groups: []
external_security_groups:
["VPC1--SSH-SG"]
state: "running"
tags:
- key: "ENV"
value: "TEST"
- key: "APP"
value: "TEST-UPGRADE-DB"
I tried to add tags in bsu {} and contents {} level and also dynamic "block_device_mappings" {} level. I want to end up with tags on my volumes. Currently I managed to add only to my instances.
instance tags working great :
resource "outscale_vm" "instance" {
for_each = local.vm_map
image_id = each.value.image_id
vm_type = each.value.vm_type
keypair_name = "key-admin"
nics {
nic_id = outscale_nic.nic_outscale[each.key].nic_id
device_number = "0"
}
tags {
key = "name"
value = "${local.prefix}-${each.key}"
}
If you try that:
dynamic "block_device_mappings" {
for_each = each.value.volumes
content {
device_name = "div name"
bsu {
volume_size = block_device_mappings.value.size
volume_type = try(block_device_mappings.value.disk_type, var.default_disk_type)
delete_on_vm_deletion = true
iops = try(block_device_mappings.value.iops, 13000)
tags {
key = "Name"
value = "ja"
}
}
}
}
So with tags inside bsu
does it work ?
If not, what errors do you get ?
Thanks.
│ Error: Unsupported block type │ │ on .terraform/modules/outscale_module/main.tf line 61, in resource "outscale_vm" "instance": │ 61: tags { │ │ Blocks of type "tags" are not expected here.
for this :
dynamic "block_device_mappings" {
for_each = each.value.volumes
content {
device_name = "div name"
bsu {
volume_size = block_device_mappings.value.size
volume_type = try(block_device_mappings.value.disk_type, var.default_disk_type)
delete_on_vm_deletion = true
iops = try(block_device_mappings.value.iops, 13000)
tags {
key = "Name"
value = "ja"
}}}}
But its the same error always, like there :
dynamic "block_device_mappings" {
tags {
key = "Name"
value = "ja"}
or like this :
content {
device_name = block_device_mappings.value.device_name
tags {
key = "Name"
value = "ja"
}
bsu {
volume_size = block_device_mappings.value.size
volume_type = try(block_device_mappings.value.disk_type, var.default_disk_type)
delete_on_vm_deletion = true
iops = try(block_device_mappings.value.iops, 13000)
}
OK, the tags
in bsu
block is merged on master branch, but sadly not present on v0.
And we don't have a release date yet for a V1. (but should be in the next few months).
In the meantime, I guess you can try using a local-exec block and create the tags using osc-cli/oapi-cli/curl
Or compiling the plugin yourself.
I'm sorry I can't help you further on this issue.
Understood, thank you, then local-exec is my only way, I was hoping that im just using tags at the wrong place.
Hello
I keep getting not expected key everywhere within block_device_mappings Based on the documentation, tag is available , but i had no luck with it.
https://registry.terraform.io/providers/outscale/outscale/latest/docs/resources/image I use this code to provision my instance and volume and I just want to add tag to created volumes. I tried to put tags inside content / bsu / after bsu block. No luck.