My aim is to launch an instance such that a start-up script is triggered on boot-up to download some configuration files stored in AWS S3. Therefore, in the start-up script, I am setting the S3 bucket details and then, triggering a config.sh
where aws s3 sync
does the actual download. However, the aws
command does not work - it is not found for execution.
User data
I have the following user data when launching an EC2 instance:
#!/bin/bash
# Set command from https://stackoverflow.com/a/34206311/919480
set -e -x
export S3_PREFIX='bucket-name/folder-name'
/home/ubuntu/app/sh/config.sh
The AWS CLI was installed with pip
as described in the documentation.
Observation
I think, the user data script is run with root
user ID. That is why, in the user data I have /home/ubuntu/
because $HOME
did not resolve into /home/ubuntu/
. In fact, the first command in config.sh
is mkdir /home/ubuntu/csv
which creates a directory with owner as root
!
So, would it be right to conclude that, the user data runs under root
user ID?
Resolution
Should I use REST API to download?