{
  "Comment": "MeDaCA 実消化&アルトマーク 日次バッチ起動ステートマシン",
  "StartAt": "params",
  "States": {
    "params": {
      "Comment": "パラメータ設定",
      "Type": "Pass",
      "Parameters": {
        "sns": {
          "TopicArn": "arn:aws:sns:#{REGION_AP_NORTHEAST_1}:#{AWS_ACCOUNT_ID}:nds-notice-#{ENV_NAME}"
        },
        "ecs": {
          "Cluster": "arn:aws:ecs:#{REGION_AP_NORTHEAST_1}:#{AWS_ACCOUNT_ID}:cluster/mbj-newdwh2021-#{ENV_NAME}-jskult-batch-daily-ecs",
          "LaunchType": "FARGATE",
          "NetworkConfiguration": {
            "AwsvpcConfiguration": {
              "Subnets": [
                "#{SUBNET_PRI_1A}",
                "#{SUBNET_PRI_1D}"
              ],
              "SecurityGroups": [
                "#{SG_ECS_ALL}",
                "#{SG_JSKULT_BATCH_DAILY}"
              ],
              "AssignPublicIp": "DISABLED"
            }
          }
        }
      },
      "ResultPath": "$.params",
      "Next": "exec-batch-daily"
    },
    "exec-batch-daily": {
      "Comment": "実消化&アルトマーク 日次バッチ起動",
      "Type": "Task",
      "Resource": "arn:aws:states:::ecs:runTask.sync",
      "Parameters": {
        "Cluster.$": "$.params.ecs.Cluster",
        "LaunchType.$": "$.params.ecs.LaunchType",
        "TaskDefinition": "arn:aws:ecs:#{REGION_AP_NORTHEAST_1}:#{AWS_ACCOUNT_ID}:task-definition/mbj-newdwh2021-#{ENV_NAME}-task-jskult-batch-daily",
        "NetworkConfiguration.$": "$.params.ecs.NetworkConfiguration"
      },
      "Retry": [
        {
          "ErrorEquals": ["States.ALL"],
          "BackoffRate": 2,
          "IntervalSeconds": 5,
          "MaxAttempts": 3
        }
      ],
      "Catch": [
        {
          "ErrorEquals": ["States.ALL"],
          "ResultPath": "$.result",
          "Next": "ErrorEnd"
        }
      ],
      "ResultPath": "$.result",
      "Next": "NormalEnd"
    },
    "NormalEnd": {
      "Comment": "正常終了",
      "Type": "Succeed"
    },
    "ErrorEnd": {
      "Comment": "異常終了",
      "Type": "Fail",
      "Error": "StatesError",
      "Cause": "StepFunctions ErrorEnd"
    }
  }
}
