I'm currently trying to automate my build and deployment process through CodePipeline. After my code finishes building in codebuild, I want to update my task definition and update my service through the aws cli via CodeBuild.
I'm having a problem with updating the service because there's no way for me to keep track of the revision number. Is there a way to let the updated service know to use the latest revision? I know that you can specify a json, but how can I manipulate the revision number so that the service points to the right image in my registry?
Reading a little the documentation of the api of Amazon, does not tell you which is the last image that was uploaded. I recommend that in the process of upload captures the version to be able to set it in the service.
I leave you the response of the api when you list the images.
Response syntax:
{
"imageIds": [
{
"imageDigest": "string",
"imageTag": "string"
}
],
"nextToken": "string"
}
A possible process can be:
TAG=$(git describe --always)
docker build . -t [acount].dkr.ecr.[zone].amazonaws.com/[app]:TAG
docker push [acount].dkr.ecr.[zone].amazonaws.com/[app]:TAG
Update the task with the image:
Update the service with the task
Hope this can help you