Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Did not find the image definition file imagedefinitions.json

"Invalid action configuration Did not find the image definition file imagedefinitions.json in the input artifacts ZIP file. Verify the file is stored in your pipeline's Amazon S3 artifact bucket"

getting this error, i did not user codebuild in AWS and image is directil pushed to ECR , we build that image with maven, i have uploaded imagedefinitions.json to the artifi bucket , i also zipped that file ,but nothing worked,

can any one suggest anything

like image 502
Akshay Avatar asked Nov 14 '19 05:11

Akshay


1 Answers

When you are using ECR as a source, ECR generates an artifact file called 'imageDetail.json' which is of the format [1]. But the ECS Deploy stage requires a file called 'imagedefinitions.json' which is formatted differently [2].

To provide the required file, please add a CodeBuild step betweenn source and deploy with the following buildspec: (Basically converting the file)

version: 0.2
phases:
    install:
        runtime-versions:
            docker: 18
    build:
        commands:
            - apt-get install jq -y
            - ContainerName="todo"
            - ImageURI=$(cat imageDetail.json | jq -r '.ImageURI')
            - printf '[{"name":"CONTAINER_NAME","imageUri":"IMAGE_URI"}]' > imagedefinitions.json
            - sed -i -e "s|CONTAINER_NAME|$ContainerName|g" imagedefinitions.json
            - sed -i -e "s|IMAGE_URI|$ImageURI|g" imagedefinitions.json
            - cat imagedefinitions.json

artifacts:
    files:
        - imagedefinitions.json

Important1: Update 'ContainerName' as it exists in your task definition

Important2: Make sure input artifact of deploy action is BuildArtifact.

  1. https://docs.aws.amazon.com/codepipeline/latest/userguide/file-reference.html#file-reference-ecs-bluegreen
  2. https://docs.aws.amazon.com/codepipeline/latest/userguide/file-reference.html#pipelines-create-image-definitions
like image 174
shariqmaws Avatar answered Nov 02 '22 18:11

shariqmaws