Search code examples
amazon-web-servicesamazon-elastic-beanstalkaws-codepipelineaws-ecr

CodePipeline: How to integrate ECR with Elastic Beanstalk?


I'm trying to combine ECR and Elastic Beanstalk with the following CodePipeline setup:

  1. Source : CodeCommit
  2. Build : buildspec.yml which Builds a docker image and pushes it to ECR repository
  3. Deploy: Elastic Beanstalk

Note that Step 2 doesn't contain any artifacts, it merely builds the new image from the source code by using docker build -t <my-image> . and pushes it to ECR with the latest tag.

My Questions are:

  1. How do you trigger beanstalk from step 3 to use the latest ECR image?
    1. Which artifacts should be included (if any) from step 1/2?
    2. Is the artifact is just the same Dockerrun.aws.json which point to the ECR image file every time?
  2. Alternative way: Should I just deploy the entire source code to beanstalk and let it use the Dockerfile in the package instead so it will build it?
    1. if so - Where can I see the build process of the image?
    2. Is there a way to select a different Dockerfile from the source code?

Solution

  • For anyone looking for the answer: include only the Dockerrun.aws.json file in artifacts of buildspec.yml and point it's image field to the ECR image.