From e5222796490f1c57360061dda1088eddc56d31f6 Mon Sep 17 00:00:00 2001 From: "shimoda.m@nds-tyo.co.jp" Date: Wed, 28 May 2025 19:24:06 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=83=A1=E3=83=AB=E3=82=AF=E6=96=BD?= =?UTF-8?q?=E8=A8=AD=E3=83=9E=E3=82=B9=E3=82=BF=E4=BD=9C=E6=88=90=E3=82=B9?= =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=88=E3=83=9E=E3=82=B7=E3=83=B3=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stepfunctions/TOOLS/convert_config.yaml | 34 +++++ .../r-jskult-batch-mst-inst-all-state.json | 129 ++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 stepfunctions/r-jskult-batch-mst-inst-all-state/r-jskult-batch-mst-inst-all-state.json diff --git a/stepfunctions/TOOLS/convert_config.yaml b/stepfunctions/TOOLS/convert_config.yaml index 98700734..9c893fa5 100644 --- a/stepfunctions/TOOLS/convert_config.yaml +++ b/stepfunctions/TOOLS/convert_config.yaml @@ -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 \ No newline at end of file diff --git a/stepfunctions/r-jskult-batch-mst-inst-all-state/r-jskult-batch-mst-inst-all-state.json b/stepfunctions/r-jskult-batch-mst-inst-all-state/r-jskult-batch-mst-inst-all-state.json new file mode 100644 index 00000000..54086560 --- /dev/null +++ b/stepfunctions/r-jskult-batch-mst-inst-all-state/r-jskult-batch-mst-inst-all-state.json @@ -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" + } + } +} \ No newline at end of file