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.

  • Deploy AWS Elastic beanstalk to an environment in different region
  • How to config AWS CodeCommit config file for an specific repo
  • Installing git through .ebextensions on Elastic Beanstalk
  • Can't push to repository on EC2 - Could not resolve hostname
  • git aws.push returns “error: RPC failed; result=22, HTTP code = 400”
  • AWS S3 Gitpull from Bitbucket and CodePipeline
  • 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.

  • Understanding basic git hooks
  • How to retrieve JSON value in BASH (automatic version in git commit)?
  • git: 'aws.push' is not a git command when trying to push a repository to Amazon Elastic Beanstalk on Mac
  • Include .pem for git pull / push
  • git fetch - bash.exe: warning: could not find /tmp, please create
  • Git (on Windows using msysgit) - “compound” command
  • 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.