I am trying to launch an ec2 instance using aws-cli and i want to copy my code from a s3 bucket.

0 votes

The command i used is as follows:-

aws ec2 run-instances --image-id *ubuntu image id* --count 1 --instance-type t2.micro --key-name new_instance --security-group-ids mysecuity --user-data file://aws.txt

The Aws.txt contained the following things:-

`#!/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`

But only Apache and PHP are getting installed, and mkdir is also not working. Can someone please analyse the snippet and let me know as what is the mistake?

Jul 17, 2018 in AWS by bug_seeker
• 15,310 points
165 views

1 answer to this question.

0 votes

It might be throwing an error on mkdir ~/.aws && cd ~/.aws line because "~" refers to different location sometime Instead use mkdir /home/*username here*/.aws && cd /home/*username here*/.aws. It should work and try n use sudo with last aws line.

answered Aug 7, 2018 by Priyaj
• 56,160 points

Related Questions In AWS

+1 vote
2 answers

How to launch and access an instance using AWS-CLI?

aws ec2 run-instances --image-id ami-id --key-name yourkeyname ...READ MORE

answered Feb 23 in AWS by Shashank
• 1,350 points
96 views
0 votes
1 answer
+1 vote
2 answers

Want my AWS s3 Bucket to read Name from CloudWatch Event

CloudTrail events for S3 bucket level operations ...READ MORE

answered May 28, 2018 in AWS by Cloud gunner
• 4,260 points
148 views
+13 votes
2 answers
+1 vote
2 answers

AWS CloudWatch Logs in Docker

The awslogs works without using ECS. you need to configure ...READ MORE

answered Sep 6, 2018 in AWS by bug_seeker
• 15,310 points
271 views
0 votes
1 answer
0 votes
1 answer

How to create a S3 bucket using AWS CLI?

You can use the following command:- C:\Users\priyj_kumar>aws s3api ...READ MORE

answered Feb 15 in AWS by Priyaj
• 56,160 points
93 views