Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

ucd-aws ignores #!/bin/bash and #cloud-config #54

@m1keil

Description

@m1keil

According to the docs:

If the user-data starts with #!, it is assumed that the user-data is a generic shell script, and cloud-init will attempt to execute the data as a script

When testing this:

$ curl http://169.254.169.254/latest/user-data
#!/bin/bash

touch /tmp/USERDATA_WAS_HERE

ucd-aws logs shows:

$ sudo journalctl -b -u ucd-aws
-- Journal begins at Fri 2021-10-22 02:02:16 UTC, ends at Fri 2021-10-22 02:05:50 UTC. --
systemd[1]: Starting micro-config-drive job for AWS...
[3.268514] micro-config-drive version: 45
[3.268635] userdata: Looking for shebang file /var/lib/cloud/aws-user-data
[3.268675] userdata: Shebang found #cloud-config
[3.268682] Parsing user data file /var/lib/cloud/aws-user-data
[3.269054] An error occurred while the yaml file was parsed.
...
systemd[1]: Finished micro-config-drive job for AWS.

The file looks like this:

$ sudo cat /var/lib/cloud/aws-user-data
#cloud-config
users:
  - name: clear
    groups: wheelnopw
ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7VLvf7oKsafgenvyYVnnCHDqakHCtq/SpTzxniaMceh0QPNl8B78qqsJBgspvTNFbVSKLNeUbODQeeC9tgb11q1nvW7ZXZRSY0B957+VmCxGQ681X+YbeYM4RoipGLg1QruzjkLITcARar7tRfUP65WBRo8s5UhyqMwA1cYwLUPNL7OZAUkpOdMVF2wdmjVMGooY9S2JUztFYEnIDsEFeH12yzGkEM9W/d8gEpQDGus+aBgKRoABpqxlCZiEfL7y4Xlcu7YoC6UouqiGPdwz1iocyTH2iTkVio8b/AGVgkoo1WMFo/rGFHAPpuW4RcVcgfOby29BFmap28CYYlqRN msverdlik
#!/bin/bash

touch /tmp/USERDATA_WAS_HERE

It looks like the userdata supplied by the user is appended to some auto-generated userdata (probably by ucd?).

A similar problem occurs with #cloud-init. The entire userdata is appended to the end of /var/lib/cloud/aws-user-data.
So in order to run cloud-init style config, the user actually needs to avoid supplying any first line stanza:

curl http://169.254.169.254/latest/user-data
runcmd:
    - touch /home/clear/hello_world

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions