newdwh2021/stepfunctions/r-data-import-state/r-data-import-state.json

123 lines
4.2 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"Comment": "MeDaCa データ取込ECSタスク起動 ステートマシン",
"StartAt": "params",
"States": {
"params": {
"Type": "Pass",
"Parameters": {
"sns": {
"TopicArn": "arn:aws:sns:#{REGION_AP_NORTHEAST_1}:#{AWS_ACCOUNT_ID}:nds-notice-#{ENV_NAME}"
},
"ecs": {
"LaunchType": "FARGATE",
"Cluster.$": "$.InputParams.ClusterName",
"TaskDefinition.$": "$.InputParams.TaskName",
"NetworkConfiguration": {
"AwsvpcConfiguration": {
"Subnets.$": "States.Array($.InputParams.SubNetIdApNorthEast1A, $.InputParams.SubNetIdApNorthEast1D)",
"SecurityGroups.$": "States.Array($.InputParams.SecurityGroupIdECSAll, $.InputParams.SecurityGroupIdECSDataImport)",
"AssignPublicIp": "DISABLED"
}
},
"Overrides": {
"ContainerOverrides": [
{
"Name.$": "$.InputParams.ContainerName",
"Environment": [
{
"Name": "BUCKET_NAME",
"Value.$": "$.InputParams.BucketName"
},
{
"Name": "TARGET_KEY",
"Value.$": "$.InputParams.TargetKey"
},
{
"Name": "DATA_SOURCE_NAME",
"Value.$": "$.InputParams.DataSourceName"
},
{
"Name": "FILE_NAME",
"Value.$": "$.InputParams.FileName"
},
{
"Name": "MODE",
"Value.$": "$.InputParams.Mode"
}
]
}
]
}
}
},
"Comment": "パラメータ設定",
"ResultPath": "$.params",
"Next": "data-import"
},
"data-import": {
"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": "CreateImportPendingFile",
"ResultPath": "$.result"
}
],
"Next": "Success",
"Comment": "データ登録処理"
},
"CreateImportPendingFile": {
"Type": "Task",
"Parameters": {
"Body": "",
"Bucket.$": "$.InputParams.BucketName",
"Key.$": "States.Format('{}.pending-import', $.InputParams.TargetKey)"
},
"Resource": "arn:aws:states:::aws-sdk:s3:putObject",
"Next": "FailedNotice",
"Comment": "データ登録保留ファイル作成",
"ResultPath": "$.result"
},
"FailedNotice": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"Parameters": {
"TopicArn.$": "$.params.sns.TopicArn",
"Subject": "データ登録ECSタスク異常通知",
"Message.$": "States.Format('({}){}のデータ登録が失敗したため、登録中断ファイルを作成しました。\n\n バケット名:{}\n取込ファイルパス{}\n\n', $.InputParams.DataSourceName, $.InputParams.FileName, $.InputParams.BucketName, $.InputParams.TargetKey)"
},
"Next": "Fail"
},
"Success": {
"Type": "Succeed",
"Comment": "正常終了"
},
"Fail": {
"Type": "Fail",
"Comment": "異常終了",
"Error": "StatusError",
"Cause": "StepFunctions ErrorEnd"
}
}
}