LoginSignup
3
1

More than 1 year has passed since last update.

ECSのデプロイ時エラーによるタスク無限再起動を防ぐ

Last updated at Posted at 2022-06-09

概要

ECSにデプロイ時、

  • ALBのヘルスチェックが通らない
  • タスク自身のヘルスチェックが通らない
  • コンテナ内部のエラーによってコンテナが止まってしまう

などの理由でECSがサービス内のタスクを無限に再起動し続けます。
放っておくとNATの通信料などがかかり痛手です。
これはECSサービスのDeploymentCircuitBreaker設定をオンにすると防げます。

実装

CFn.yml
  YourService:
    Type: AWS::ECS::Service
    Properties:
      ServiceName: !Ref YourServiceName
      Cluster: !Ref YourClusterArn
      LaunchType: FARGATE
      DeploymentConfiguration:
        DeploymentCircuitBreaker: #ここを設定!
          Enable: true
          Rollback: true
        MaximumPercent: 200
        MinimumHealthyPercent: 75
      DesiredCount: !Ref DesiredCount
      NetworkConfiguration:
        AwsvpcConfiguration:
          AssignPublicIp: DISABLED
          SecurityGroups:
            - !Ref YourSecurityGroupId
          Subnets:
            - !Ref YourPrivateSubnet
      TaskDefinition: !Ref YourTaskDefinition

コンソール

スクリーンショット 2022-06-09 11.59.13.png

参考

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1