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,510 points
2,934 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
• 58,020 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, 2019 in AWS by Shashank
• 1,370 points
1,917 views
0 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,034 views
+1 vote
2 answers

AWS CloudWatch Logs in Docker

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

answered Sep 7, 2018 in AWS by bug_seeker
• 15,510 points
2,031 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, 2019 in AWS by Priyaj
• 58,020 points
6,126 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP