Trying to create a VM with cloudinit but without any success.
Docs on terraform doesnt provide any usefull information how to do it on Azure.
Found this post and tried to do the same:
Using cloud-init on an Azure VM to mount a data disk fails
also tried Terraform docs:
https://www.terraform.io/docs/providers/template/d/cloudinit_config.html
Each time I try I receive the following error:
An argument named "cloud_init_template" is not expected here.
or
An argument named "user_data_base64" is not expected here.
Block of code with relevant code:
provider "azurerm" {
version = "2.2.0"
features{}
}
#############################
# Cloud config configuration#
#############################
data "template_file" "cloudconfig" {
template = file("${path.module}/cloud-init.tpl")
vars {
timezone = var.timezone
password = data.azurerm_key_vault_secret.vaultsecret.value
tpot_flavor = var.tpot_flavor
web_user = var.web_user
web_password = var.web_password
}
}
data "template_cloudinit_config" "config" {
gzip = true
base64_encode = true
part {
content_type = "text/cloud-config"
content = data.template_file.cloudconfig.rendered
}
}
module "azure-vms" {
source = "./modules/azure-vms"
tpot_hostname = "${var.name}-Tpot"
location = azurerm_resource_group.rg.location
rg-name = azurerm_resource_group.rg.name
admin_password = data.azurerm_key_vault_secret.vaultsecret.value
cloud_init_template = data.template_cloudinit_config.config.rendered
}
I've also tried the same with user_data_base64
It's the same error message.
I'll appreciate if someone knows what is the right way to deploy a vm with cloudinit on azure.
The correct way to use cloud config in the VM resource provider is:
cloud_init_template = data.template_cloudinit_config.config.rendered