How to deploy through AWS codeploy using composer when a dependency is in a private repository

So I’m new to AWS Codedeploy, I have it successfully deploying with one little issue, every time I add to my deploy script composer update I get this lovely little message “Permission denied (publickey)”.

Now when I run composer update as ubuntu user it runs fine, my key is setup in the private repository fine, I have made sure that the bash file is run as ubuntu.

  • aws beanstalk 403 error while deploying
  • How to deploy and update app on multiply ec2 instances in Amazon Auto-scaling group?
  • AWS Elastic Beanstalk (hook declined)
  • Git push pushes nothing
  • aws codecommit cannot push
  • AWS CodeDeploy Github File Already Exist
  • So how do other people setup their code deployments to work with private composer repositories? Sorry if there is something obvious but I am very baffled.

    If someone can answer you would make one developer very happy.

  • catching a git post-receive error in a script
  • Using a Git hook to create a commit log and add to the current commit
  • Trying to get the list of ec2 instances under a deployment group using aws command
  • Script for root to git pull as another user
  • git-p4 message and author encoding
  • Why can I view some Unix executable files in Mac OS X and not others?
  • 2 Solutions collect form web for “How to deploy through AWS codeploy using composer when a dependency is in a private repository”

    Use a Deployment Key on the root user.

    The way I had it set up for my application that has multiple private composer packages is to create an artifact of my application then deploy that via CodeDeploy.

    A summary of what I do

    • On my CI machine (Jenkins or my local), run composer. This machine will already have the appropriate access to the repos.
    • Tar Ball/Zip up my application together with the corresponding vendor folder created by composer – this is my deploy artifact
    • Save that artifact to S3
    • Have CodeDeploy begin a deploy with that artifact in S3 as my source

    This method is more scalable especially when you are deploying to >1 server

    • avoids adding private keys on your server(s)
    • avoids your servers from running composer individually
    Git Baby is a git and github fan, let's start git clone.