New Linux Virtual Machine Scale Set and Custom Data/cloud-init

Hi

I have successfully set up a new Linux virtual machine scale set. However, the devs would like a custom script running to update several packages.

When the previous VMSS was set up manually this was added into the custom data property.

#cloud-config
package-update: true
package_upgrade: true
packages:

I can see there is a variable to use but I have no idea how to put the above in it so it runs.

custom_data = bases64Encode ()

I’ve done some google research but I cannot find anything conclusive nor any good examples.

Any help would be appreciated.

Regards
Paul

1 Like

This is how I managed it.

1 - Copied my cloud-init.txt file to the local repo on my laptop.

2 - Synced that up to Devops and Terraform Cloud.

3 - Added this data point into the terrform code on the vmss file I am using.

data “local_file” “cloudinit” {

filename = “${path.module}/cloud-init.txt”

}

4 - Added this argument within the vmss block.

custom_data = base64encode(data.local_file.cloudinit.content)

5 - Pushed that change up to TF cloud and it worked a treat.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.