Search code examples
amazon-web-servicesamazon-elastic-beanstalkamazon-ecsaws-codepipeline

AWSEBDockerrunVersion is in Dockerrun.aws.json and Build artifact but Deploy says it is missing


I am trying to deploy an web app to ElasticBeanstalk and am usind CodePipeline to source, build, and deploy. Source and Build are completing and working fine. When it gets to Deploy, I get the following error:

Deployment completed, but with errors: Failed to deploy application. ECS Application sourcebundle validation error: AWSEBDockerrunVersion is missing.

For reference, here is my buildspec.yml:

version: 0.2
phases:
  pre_build:
    commands:
      - echo Logging in to Docker
      - docker login --username $DOCKERHUB_USERNAME --password $DOCKERHUB_PASS
      - echo Logging in to Amazon ECR...
      - aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com
  build:
    commands:
      - echo Build started on `date`
      - echo Building the Docker image...
      - docker-compose --file=docker-compose.aws.production.yml build
  post_build:
    commands:
      - echo Build complete on `date`
      - echo Pushing the Docker image
      - docker-compose --file=docker-compose.aws.production.yml push
artifacts:
  files:
    - 'Dockerrun.aws.json'

and my Dockerrun.aws.json:

{
    "AWSEBDockerrunversion": 2,
    "containerDefinitions": [
        {
            "name": "client",
            "image": "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/orcinus-client-prod",
            "hostname": "client",
            "essential": true,
            "memory": 1024,
            "portMappings": [
                {
                    "hostPort": 80,
                    "containerPort": 80
                }
            ]
        },
        {
            "name": "server",
            "image": "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/orcinus-server-prod",
            "hostname": "server",
            "essential": true,
            "memory": 512,
            "portMappings":[
                {
                    "hostPort": 4000,
                    "containerPort": 4000
                }
            ]
        }
    ]
}

The Deploy stage is using the BuildArtifact exported from the Build stage as an Input Artifact as well.

My EB Environment is using the ECS running on 64bit Amazon Linux 2/3.2.9 platform. I've tried using the Docker platform but it recommends otherwise in the docs. I have been trying to find a solution to this for a while but haven't been able to. I am pretty new to AWS and deploying apps so any help would be greatly appreciated.

The Deploy stage is using the BuildArtifact exported from the Build stage as an Input Artifact as well.

My EB Environment is using the docker platform with ECS running on 64bit Amazon Linux 2/3.2.9 platform branch. I've tried using the Docker platform branch but it recommends otherwise in the docs. I have been trying to find a solution to this for a while but haven't been able to. I've tried using the input artifacts from SourceArtifact instead and that didn't work. I've updated my the value of AWSEBDockerrunversion to use double quotes or version 1 or 3 and got similar. I've tried to look at the ECS instance associated with the environment but I couldn't find anything related and nothing related to my Dockerrun.aws.json in the task definitions. I am pretty new to AWS and deploying apps so any help would be greatly appreciated.


Solution

  • I found the issue. It was the key needing to be AWSEBDockerrunVersion not AWSEBDockerrunversion.