Skip to content

[AVM Module Issue]: custom_data validation rejects gzipped cloud-init #207

@V1TO-C

Description

@V1TO-C

Check for previous/existing GitHub issues

  • I have checked for previous/existing GitHub issues

Issue Type?

Bug

(Optional) Module Version

0.19.3

(Optional) Correlation Id

No response

Description

When passing gzipped, base64-encoded cloud-init user data (via data.cloudinit_config.rendered with gzip = true) to the module’s custom_data input, variable validation fails. Azure VMs and cloud-init support gzipped user-data, so the module should accept it.

Example

data "cloudinit_config" "this" {
  gzip          = true
  base64_encode = true

  part {
    content_type = "text/cloud-config"
    content      = file("cloud-init.yaml")
  }
}

module "virtual_machine" {
  source  = "Azure/avm-res-compute-virtualmachine/azurerm"
  version = "0.19.3"

  # … other inputs …
  custom_data = data.cloudinit_config.this.rendered
} 

Actual behavior

Terraform fails during variable validation for custom_data, indicating the value is invalid because the decoded bytes are not valid UTF-8 when gzip is enabled.

│ Error: Invalid value for variable
│ 
│   on main.tf line 15, in module "virtual_machine":
│   15:   custom_data                = data.cloudinit_config.this.rendered
│     ├────────────────
│     │ var.custom_data is "xxx"
│ 
│ The `custom_data` must be either `null` or a valid Base64-Encoded string.
│ 
│ This was checked by the validation rule at
│ .terraform/modules/virtual_machine/variables.tf:443,3-13.

Expected behavior

The module should accept gzipped, base64-encoded custom_data and pass it to the VM resource unchanged so cloud-init can decompress and process it on first boot.

  • Gzip is commonly used with cloud-init to stay under Azure’s 64 KB customData limit after decoding, so blocking gzip prevents standard usage patterns.

  • Azure/cloud-init handle gzip automatically on supported Linux images, so the module’s validation should not prohibit this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions