A script to run remote scripts in amazon ec2 instance.
- Get the instanceid of the machine
- Get the
AWS_ACCESS_KEY_ID
ANDAWS_SECRET_KEY
values
Write your scripts in internal/scripts.txt file, comma separated commands. Like the example below:
touch /home/ubuntu/a.txt,
echo 'Hello from SSM command!' > /home/ubuntu/a.txt,
pwd,
ls -lah /home/ubuntu
Add your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in the environment.
export AWS_SECRET_ACCESS_KEY=**************
export AWS_ACCESS_KEY_ID=******************
git clone https://github.com/Jkarage/EC2update.git
go run cmd/ec2/main.go --region eu-west-3 --instance-id i-04493d3e5d3001e32
Providing Custom Script file
go run cmd/ec2/main.go --region eu-west-3 --instance-id i-04493d3e5d3001e32 --script a.txt