'CodePipeline : What is taskdef.json and appsec.yaml purpose?
The whole point of using CodePipeline for me is to deploy automatically an ECS Service (Blue / Green deployment), with CodeDeploy.
CodePipeline have the following stages :
"Source" containing Bitbucket webhook.
"Build" containing CodeBuild step (that build and push a docker image on ECR).
"Deploy" containing ECS (Blue / Green) that will use CodeDeploy to deploy the designed service.
What i don't understand, is the purpose of taskdef.json and appsec.yaml in my case.
What i only do manually (so without CodePipeline currently) is redeploying ECS service with the same task definition. I don't really have to update my task definition each time, since the docker image that i push always have the same tag (staging or production), all other one are untagged, so there is only one available.
So why is it mandatory to input those files, even if when i do it manually i don't change a thing, and just click on Next continually ?
And also, how can i include it from the CodeBuild step ?
Solution 1:[1]
I finally found how to do it. What i did first was to include a taskdef.json and appspec.yaml files in my Git project. Since i didn't need those file to be "automatically updated" or "generated", i just took my last task definition in JSON, and put it in taskdef.json.
For the appspec.yaml, you can get it in JSON format when doing a manual deployment on an ECS service, on the last page where it is summarizing everyting.
You then need to update CodeBuild project to upload both artifacts on S3 for example, and then in the pipeline, the Deploy task can use those artifacts.
This site helped me setting up everyting well.
Solution 2:[2]
On your pipeline, you can input the taskdef.json file, together with appspec.yml, usin AWS CodeCommit. On every deploy, CodePipeline will fetch the most recent inputs available.
Say, for instance, you have changed an environment variable value. That goes on the taskdef.json file. What you would have to do is to push the commit with the new version of your taskdef.json. This will trigger a new deploy, with the new taskdef.json, as well as using the most recent ECR image with the tag you have specified on CodePipilie/CodeDeploy.
This tutorial explains how to get it all together: https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-ecs-ecr-codedeploy.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Luxior |
Solution 2 | Diogo Melo |