How to copy a folder from S3 to Elastic Beanstalk instance on its creation?

0 votes

I'm running a Django web-app on AWS Elastic Beanstalk that needs specific files available to it to run (in fact, an nltk corpus of stopwords). Since instances are created and terminated randomly, I copied the needed folder to the S3 bucket that was created by my elastic beanstalk and planned to add a copy command using awscli to my elastic beanstalk configuration file. But It is not working..

Beanstalk also created an IAM role aws-elasticbeanstalk-ec2-role which is an instance profile that is attached to every instance it launches. This role includes the AWSElasticBeanstalkWebTier policy which seems to grant both read and write access to the S3 bucket:

  "Version": "2012-10-17",
  "Statement": [
      "Sid": "BucketAccess",
      "Action": [
      "Effect": "Allow",
      "Resource": [

I added the following command to .ebextensions/my_app.config:

commands: 01_copy_nltk_data: command: aws s3 cp s3://<my_bucket>/nltk_data /usr/local/share/

But I get the following error when I try to deploy even though I can see the folder in my S3 console

Command failed on instance. Return code: 1 Output: An error occurred (404) when calling the HeadObject operation: Key "nltk_data" does not exist

Any ideas?

Aug 24, 2018 in AWS by datageek
• 2,430 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

I had encountered similar problem. But i found this solution posted by AWS support. My  folder had subfolders and files inside so asw s3 cp command needed --recursive option.

Try it out. It will work.

answered Aug 24, 2018 by Archana
• 4,090 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How can i copy tables from one database to other on AWS?

You can use AWS Data pipeline to ...READ MORE

answered Jul 5, 2018 in AWS by Priyaj
• 56,140 points
0 votes
1 answer

How to copy .csv file from Amazon S3 bucket?

Boto3 is the library to use for ...READ MORE

answered Jul 6, 2018 in AWS by Priyaj
• 56,140 points
0 votes
1 answer

AWS Elastic Beanstalk - How to increase instance disk capacity?

The 8 GB diskthat you are seeing ...READ MORE

answered Sep 3, 2018 in AWS by anonymous
+1 vote
1 answer

How to make an application private on AWS Elastic Beanstalk?

Like you said by default, your application ...READ MORE

answered Oct 25, 2018 in AWS by Archana
• 5,360 points
0 votes
1 answer

How to download a file from EC2 instance to local computer?

You need to specify your download location. ...READ MORE

answered Oct 10, 2018 in AWS by Archana
• 4,090 points
0 votes
2 answers

How to access files in S3 bucket from R?

You can take a look at the ...READ MORE

answered Aug 10, 2018 in AWS by Deepthi
• 300 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.