-1

I need to upload the updated files into multiple ec2 instace which is under single LB. My problem is I missed some ec2 instance and it broke my webpage. Is there any tool available to upload the multiple files to multiple EC2 windows server in a single click.

I will update my files weekly or some times daily. I checked with Elastic beanstalk , Amazon Code Deploy and Amazon EFS. But the are hard to use. Anyone please help

Rahmathullah
  • 97
  • 13

3 Answers3

4

I will suggest use AWS S3 and AWS CLI. What you can do is install AWS CLI on all the EC2 instance. Create a Bucket in AWS S3.

Start a Cron Job on each EC2 instance with below syntax.

aws s3 sync s3://bucket-name/folder-on-bucket /path/to/local/folder 

So what will happen is when you upload new images to the S3 bucket all images will automatically sync with all the EC2 instances behind your load balancer. And also AWS s3 will be central directory where you upload and delete images.

error2007s
  • 12,666
  • 5
  • 31
  • 47
1

You could leverage the AWS CLI, you could run something like

aws elb describe-load-balancers --load-balancer-name <name_of_your_lb> --query LoadBalancerDescriptions[].Instances --output text |\ 
xargs -I {} aws ec2 describe-instances --instance-id {} --query Reservations[].Instances[].PublicIpAddress |\
xargs -I {} scp <name_of_your_file> <your_username>@{}:/some/remote/directory 

basically it goes like this:

  1. find out all the ec2 instances connected to your Load Balancer
  2. for each of the ec2 instances, find out the PublicIPAddress (supposedly you have since you can connect to them through scp)
  3. run scp command to copy 1 files somewhere on the ec2 server

you can copy also copy folder if you need to push many files , it might be easier

Amazon ElasticFileSystem would probably now be the easiest option, you would create your file system and attach it to all your ec2 instances that are attached to the Load Balancer, and when you transfer files to the EFS it will be available to all the ec2 instances where the EFS is attached (the setup to create EFS and mount it to your ec2 instances has to be done once only)

Community
  • 1
  • 1
Frederic Henri
  • 48,743
  • 7
  • 106
  • 131
0

Create a script containing some robocopy commands and run it when you want to update the files on your servers. Something like this:

robocopy Source Destination1 files
robocopy Source Destination2 files

You will also need to share the folder you want to copy to with the user on your machine.

Mahdi
  • 3,048
  • 2
  • 24
  • 34