12

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?

J0hnG4lt
  • 4,337
  • 5
  • 24
  • 40

1 Answers1

13

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.

J0hnG4lt
  • 4,337
  • 5
  • 24
  • 40