When I tried to set one of the services into AWS Elastic Beanstalk, the problem appeared. One of our python pip dependencies set up on private repository was causing errors during deployment process, since it was not accessible for pip process. Bellow I present description how we solved this issue.
It is worth to mention that there are other solutions that bind SSH keys used during deployment, to application project git repository. I find them a bit dirty, so I would like to share this one that allows to keep SSH keys separated in S3 bucket, separated from application git repository.
Works on: "64bit Amazon Linux 2015.09 v2.0.6 running Python 3.4" for dependency from private bitbucket repository. it may be modified for github, etc.
Add you private dependency to pip requirements.txt:
Generate public & private SSH keys (HOWTO can be found elsewhere) so you have id_rsa (private) and id_rsa.pub (public) key files.
On bitbucket.org project tab, find settings and go under "Deployment keys". Use form to set your public SSH key there.
Upload both generated keys (just private should be enough) on S3 bucket using amazon AWS console:
Where bucket-with-keys/bitbucket - is [BUCKET_NAME]/[PATH].
Add packages file to your project: project_name/.ebextensions/packages.config
Add configuration file to your project: project_name/.ebextensions/03-pip-install-from-bitbucket.config:
If you modify this file, keep in mind that:
Go to AWS console IAM (Identity & Access Management) "policies" tab and find AmazonS3FullAccess on a list and attache it for aws-elasticbeanstalk-ec2-role. If you cannot find policy you can create one like below:
Look for "Create and Attach Your First Customer Managed Policy" Tutorial if needed. This policy is quite open and it is advised to create one that would be more narrow... aws-elasticbeanstalk-ec2-role is role created by default by Elastic Beanstalk but you can use your own as long as it is set with CLI tool eb config under: "IamInstanceProfile: aws-elasticbeanstalk-ec2-role"
Now you can create your environmant with eb CLI tool:
Should work now!
If sth goes wrong you may debug if SSH files got to its place:
And check logs on AWS console or directly on instance:
Try manually execute commands from project_name/.ebextensions/03-pip-install-from-bitbucket.config as a root user bu in the way they appear in log file, use switches to get more verbose output.
I cannot comment so I'm answering the question. smentek's answer is very detailed and solves the issue. The only missing part is that you need to add the git package to the config:
Git isn't installed on Amazon Linux by default.