Open dschemp opened 3 weeks ago
Hi @dschemp, You can do it by passing user_data with cloud-init file:
resource "opentelekomcloud_compute_instance_v2" "my_server" {
name = "my-server"
image_name = "Standard_Debian_11_latest"
availability_zone = "eu-de-01"
flavor_id = "s3.medium.1"
key_pair = "terraform-as"
security_groups = ["default"]
user_data = file("cloud-init.yml")
network {
uuid = data.opentelekomcloud_vpc_subnet_v1.shared_subnet.network_id
}
}
cloud-init.yml:
#cloud-config
hostname: new-hostname
fqdn: new-hostname.example.com
manage_etc_hosts: true
You can refer on openstack documentation in case of openstack API: https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_instance_v2#instance-with-user-data-cloud-init
Ah, didn't know that. We thought you could only set the hostname (in a cloud-init way, and by that I don't mean runcmd or bootcmd) via the instances metadata (which we dont control) and not via the userdata. Great.
Is there any way to set the description of the ECS VM with TF?
We have a use-case in which we want to set the systems hostname differently (FQDN) as is it shown in the management UI (without any domain). For now I have not seen any way to change the hostname besides changing the VMs name. And: as it seems the description field of the ECS cannot be set via the
compute_instance_v2
resource but is set automatically (at least initially) to the VMs name.We've tried setting it via the
metadata
variable and its propagated into the VM, but not applied and, by the looks of cloud init, set at the wrong spot for it to work.