Search code examples
cloud-init

What user does cloud-config run as?


When spinning up an AWS or other cloud vendor instance, and using cloud-init to configure the host, what user do bash scripts that get called run as?


Solution

  • Building an instance with the following config:

    #cloud-config
    write_files:
      - path: /root/test.sh
        content: |
            #!/bin/bash
            set -x
            set -e
            whoami
    runcmd:
      - bash /root/test.sh
    

    I got an output of:

    + whoami
    root
    

    Ubuntu cloud-config runs as root.