How to validate user data cloud config

The two most common issues with cloud config user data are:

  1. Incorrectly formatted YAML

  2. The first line does not start with #cloud-config

Static user data validation

Cloud-init is capable of validating cloud config user data directly from its datasource (i.e. on a running cloud instance). To do this, you can run:

sudo cloud-init schema --system --annotate

Or, to test YAML in a specific file:

cloud-init schema -c test.yml --annotate

Example output:

$ cloud-init schema --config-file=test.yaml --annotate
  - name: holmanb        # E1,E2,E3
    gecos: Brett Holman
    primary_group: holmanb
    lock_passwd: false
    invalid_key: true

# Errors: -------------
# E1: Additional properties are not allowed ('invalid_key' was unexpected)
# E2: {'name': 'holmanb', 'gecos': 'Brett Holman', 'primary_group': 'holmanb', 'lock_passwd': False, 'invalid_key': True} is not of type 'array'
# E3: {'name': 'holmanb', 'gecos': 'Brett Holman', 'primary_group': 'holmanb', 'lock_passwd': False, 'invalid_key': True} is not of type 'string'


If your user-data cloud config is correct according to the cloud-init schema command, but you are still having issues, then please refer to our debugging guide.

To report any bugs you find, refer to this guide.