🦉
AWS ECS CICD ハンズオンを CDK で書いてみた(ローリングアップデート)
AWS ECS Blue/Green デプロイハンズオンを CDK で書いてみた を少し変更して、 CodePipeline の部分をローリングアップデートに変えてみたのでそのメモ。
修正量は少なくて CodeDeployEcsDeployAction
を EcsDeployAction
に変えただけ。
-const deployAction = new codepipeline_actions.CodeDeployEcsDeployAction({
- actionName: `${Context.ID_PREFIX}-frontend-deploy`,
- deploymentGroup: props.ecsDeploymentGroup,
-
- // the properties below are optional
- taskDefinitionTemplateInput: sourceOutput, // タスク定義
- appSpecTemplateInput: sourceOutput, // AppSpecファイル
- containerImageInputs: [{
- input: buildOutput,
-
- // the properties below are optional
- taskDefinitionPlaceholder: 'IMAGE1_NAME',
- }],
- variablesNamespace: 'DeployVariables'
+const deployAction = new codepipeline_actions.EcsDeployAction({
+ actionName: `${Context.ID_PREFIX}-frontend-deploy-rolling-update`,
+ input: buildOutput,
+ service: props.frontendService,
+ deploymentTimeout: cdk.Duration.minutes(10)
buildspec.yml も少し変更が必要でした。
post_build:
commands:
- docker push ${REPOSITORY_URI}/${IMAGE_NAME}:${IMAGE_TAG}
- - printf '{"Version":"1.0","ImageURI":"%s"}' ${REPOSITORY_URI}/${IMAGE_NAME}:${IMAGE_TAG} > imageDetail.json
+ - printf '[{"name":"%s","imageUri":"%s"}]' "${CONTAINER_NAME}" "${REPOSITORY_URI}/${IMAGE_NAME}:${IMAGE_TAG}" > imagedefinitions.json
artifacts:
- files: imageDetail.json
+ files: imagedefinitions.json
コードはこちらです。
- CDK
- CodePipeline のパートで使われる Rails アプリケーション
Discussion