Files downloaded with user-data deleted?

Viewed 11

I have a user-data bootstrap script that creates a folder called content in root directory and downloads files from an S3 bucket.

#!/bin/bash
sudo yum update -y
sudo yum search docker
sudo yum install docker -y
sudo usermod -a -G docker ec2-user
id ec2-user
newgrp docker
sudo yum install python3-pip -y
sudo pip3 install docker-compose
sudo systemctl enable docker.service
sudo systemctl start docker.service
export PATH=$PATH:/usr/local/bin
mkdir content
docker network create web_todos
docker run -d -p 80:80 --name nginx-proxy --network=web_todos -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy
aws s3 cp s3://jv-pocho/docker-compose.yaml .
aws s3 cp s3://jv-pocho/backup.sql .
aws s3 cp s3://jv-pocho/dns-updater.sh .
aws s3 sync s3://jv-pocho/images/ ./content/images
aws s3 sync s3://jv-pocho/themes/ ./content/themes
docker-compose up -d
sleep 30
docker exec -i db_jv sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD"' < backup.sql
rm backup.sql
chmod +x dns-updater.sh

This bootstrap works ok, it creates the folder and download the files (it has permissions to download the files) i.e.:

download: s3://jv-pocho/dns-updater.sh to ./dns-updater.sh
[   92.739262] cloud-init[3203]: Completed 32.0 KiB/727.2 KiB (273.1 KiB/s) with 25 file(s) remaining

so it's copying all the files correctly. The thing is that when i enter via SSH to the instance, i don't have any files inside

[ec2-user@ip-x-x-x-x ~]$ ls
[ec2-user@ip-x-x-x-x ~]$ ls -l
total 0

all commands worked as expected, all the yum installs, python, docker, etc were successfully installed, but no files. Are files deleted after the bootstrap script ran?

thanks!

0 Answers
Related