feat: メルク施設マスタ作成ステートマシンを追加

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2025-05-28 19:24:06 +09:00
parent 75072eb024
commit e522279649
2 changed files with 163 additions and 0 deletions

View File

@ -34,6 +34,8 @@ resource:
- &STG_SG_JSKULT_ULTMARC_IO "sg-014caf29e738d106a"
# セキュリティグループ(ecs-jskult-batch-ultmarc-io)
- &STG_SG_DCF_INST_MERGE_IO "sg-0b5d1639a83d28f66"
# セキュリティグループ(ecs-jskult-batch-mst-inst-all)
- &STG_SG_MST_INST_ALL "sg-0483fd75c76fa5808"
# 本番環境
product:
# サブネット(PrivateSubnet1)
@ -61,6 +63,9 @@ resource:
# セキュリティグループ(ecs-jskult-batch-ultmarc-io)
# TODO: 本番リリース時にIDを正式版にする
- &PRD_SG_DCF_INST_MERGE_IO "sg-xxxxxxxxxxxxx"
# セキュリティグループ(ecs-jskult-batch-mst-inst-all)
# TODO: 本番リリース時にIDを正式版にする
- &PRD_SG_MST_INST_ALL "sg-xxxxxxxxxxxxx"
config:
# CRMデータ取得
r-crm-datafetch-state:
@ -315,3 +320,32 @@ config:
SG_ECS_ALL: *PRD_SG_ECS_ALL
# セキュリティグループ(ecs-jskult-batch-ultmarc-io)
SG_DCF_INST_MERGE_IO: *PRD_SG_DCF_INST_MERGE_IO
r-jskult-batch-mst-inst-all-state:
# ステージング環境
staging:
# AWSアカウントID
AWS_ACCOUNT_ID: *AWS_ACCOUNT_ID
# 東京リージョン
REGION_AP_NORTHEAST_1: *REGION_AP_NORTHEAST_1
# サブネット(PrivateSubnet1)
SUBNET_PRI_1A: *STG_SUBNET_PRI_1A
# サブネット(PrivateSubnet2)
SUBNET_PRI_1D: *STG_SUBNET_PRI_1D
# セキュリティグループ(ecs-all)
SG_ECS_ALL: *STG_SG_ECS_ALL
# セキュリティグループ(ecs-jskult-batch-ultmarc-io)
SG_MST_INST_ALL: *STG_SG_MST_INST_ALL
# 本番環境
product:
# AWSアカウントID
AWS_ACCOUNT_ID: *AWS_ACCOUNT_ID
# 東京リージョン
REGION_AP_NORTHEAST_1: *REGION_AP_NORTHEAST_1
# サブネット(PrivateSubnet1)
SUBNET_PRI_1A: *PRD_SUBNET_PRI_1A
# サブネット(PrivateSubnet2)
SUBNET_PRI_1D: *PRD_SUBNET_PRI_1D
# セキュリティグループ(ecs-all)
SG_ECS_ALL: *PRD_SG_ECS_ALL
# セキュリティグループ(ecs-jskult-batch-ultmarc-io)
SG_MST_INST_ALL: *PRD_SG_MST_INST_ALL

View File

@ -0,0 +1,129 @@
{
"Comment": "実消化&アルトマーク メルク施設マスタステートマシン",
"StartAt": "params",
"States": {
"params": {
"Comment": "パラメータ設定",
"Type": "Pass",
"Parameters": {
"ecs": {
"LaunchType": "FARGATE",
"Cluster": "arn:aws:ecs:#{REGION_AP_NORTHEAST_1}:#{AWS_ACCOUNT_ID}:cluster/mbj-newdwh2021-#{ENV_NAME}-jskult-batch-mst-inst-all-ecs",
"TaskDefinition": "arn:aws:ecs:#{REGION_AP_NORTHEAST_1}:#{AWS_ACCOUNT_ID}:task-definition/mbj-newdwh2021-#{ENV_NAME}-task-jskult-batch-mst-inst-all",
"NetworkConfiguration": {
"AwsvpcConfiguration": {
"Subnets": [
"#{SUBNET_PRI_1A}",
"#{SUBNET_PRI_1D}"
],
"SecurityGroups": [
"#{SG_ECS_ALL}",
"#{SG_MST_INST_ALL}"
],
"AssignPublicIp": "DISABLED"
}
},
"Overrides": {
"ContainerOverrides": [
{
"Name": "mbj-newdwh2021-#{ENV_NAME}-container-jskult-batch-mst-inst-all",
"Environment": [
{
"Name": "BATCH_EXECUTION_ID",
"Value.$": "$$.Execution.Id"
},
{
"Name": "MAX_RUN_COUNT",
"Value.$": "$.maxRunCount"
}
]
}
]
}
}
},
"ResultPath": "$.params",
"Next": "exec-ecs-task"
},
"exec-ecs-task": {
"Type": "Task",
"Resource": "arn:aws:states:::ecs:runTask.sync",
"Parameters": {
"LaunchType.$": "$.params.ecs.LaunchType",
"Cluster.$": "$.params.ecs.Cluster",
"TaskDefinition.$": "$.params.ecs.TaskDefinition",
"NetworkConfiguration.$": "$.params.ecs.NetworkConfiguration",
"Overrides.$": "$.params.ecs.Overrides"
},
"ResultPath": "$.result",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"BackoffRate": 2,
"IntervalSeconds": 3,
"MaxAttempts": 3
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "ErrorEnd",
"ResultPath": "$.result"
}
],
"Next": "scan-jskult-batch-run-manage",
"Comment": "ECSタスク起動"
},
"scan-jskult-batch-run-manage": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:getItem",
"Parameters": {
"TableName": "mbj-newdwh2021-#{ENV_NAME}-jskult-batch-run-manage",
"Key": {
"execution_id": {
"S.$": "$$.Execution.Id"
}
}
},
"Next": "Choice",
"ResultPath": "$.scan"
},
"Choice": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.scan.Item",
"IsPresent": false,
"Next": "ErrorEnd",
"Comment": "バッチ実行管理テーブルにデータが存在しない場合"
},
{
"Variable": "$.scan.Item.batch_run_status.S",
"StringEquals": "retry",
"Next": "wait-for-retry",
"Comment": "バッチ実行管理テーブルのスターテスがリトライの場合"
}
],
"Default": "NormalEnd"
},
"wait-for-retry": {
"Type": "Wait",
"SecondsPath": "$.retryIntervalSecond",
"Next": "exec-ecs-task"
},
"NormalEnd": {
"Comment": "正常終了",
"Type": "Succeed"
},
"ErrorEnd": {
"Comment": "異常終了",
"Type": "Fail",
"Error": "StatesError",
"Cause": "StepFunctions ErrorEnd"
}
}
}