I would like to run some code whenever my AWS EC2 instance starts. The code should pull down data from Amazon S3, do some work on the data, and then copy the data back to S3. I created a makefile to do this, which works fine if I call it while I'm logged into the instance. I then placed a script in /ect/rc.local
(this scripts runs every time the instance starts) that will call the makefile. This scripts successfully runs on instance startup. The problem I'm having is that when the makefile is called from the startup script it does not pull data from or copy data to s3. I read here that setting your access keys solves this problem with a Windows server, but this does not work for me. It looks like the code just stops when it tries to call any aws commands because in the log file the output is always the first line of code from the makefile. Below is what my log file says:
aws s3 sync s3:<s3 bucket to get data from> <location to save data to>
Here is the relelvant code from my makefile:
### Download all data
get_data:
aws s3 sync s3:<s3 bucket to get data from> <location to save data to>
### Copy data back to s3
copy_data_to_s3:
aws s3 sync <location of data to copy to s3> s3:<s3 bucket data is copied to>
Here is my script in /etc/rc.local:
#!/bin/bash
#
# rc.local
#
make -f <location of makefile>/Makefile > <location to save log file>/log.txt
exit 0
Any help would be appreciated.