I've been trying to launch an ec2 instance which is an Ubuntu AMI using aws-cli and I want to copy my code from an s3 bucket that I created.
I am attaching the command below that I used to spin my EC2 instance:
aws ec2 run-instances --image-id *ubuntu image id* --count 1 --instance-type t2.micro --key-name new_instance --security-group-ids mysecurity --user-data file://aws.txt
My aws.txt file contents :
`#!/bin/bash
sudo apt-get update
sudo apt-get install -y apache2 php7.0 php7.0-curl php7.0-cli
sudo service apache2 start
sudo apt-get install -y python3 python-pip
sudo apt-get update && sudo pip install --upgrade --user awscli
mkdir ~/.aws && cd ~/.aws
touch credentials && touch config
echo "[default]" > credentials
echo "aws_access_key_id = *id here*" >> credentials
echo "aws_secret_access_key = *secret key*" >> credentials
echo "[default]" > config
echo "output = json" >> config
echo "region = ap-south-1" >> config`enter code here`
sudo aws s3 sync s3://*bucket name* var/www/html`
With this,only apache2 and php are getting installed and mkdir isnt working and awscli isn't being installed and because of that I am not able to sync my d3 bucket code with ebs volume, what should I do in this case?
A help will be much appreciated, Thanks in Advance :)