0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

StepFunctionsでAWS SDK統合が使えるようになった

Last updated at Posted at 2021-10-01

やれること

今まではDynamoDBでqueryするときなどで, Lambdaを呼んでaws-sdkを利用して色々叩いていました.
これがなんと, StepFunctionsのStateから直接叩けるようになりました🎉

スクリーンショット 2021-10-01 115349.jpgスクリーンショット 2021-10-01 125948.jpg

DynamoDBにQueryを発行してみます. SDKを利用するときに入れる値と同じ値を入れるだけです.

{
  // ...
  "States": {
    "ExecuteQuery": {
      "Type": "Task",
      "Resource": "arn:aws:states:::aws-sdk:dynamodb:query",
      "Parameters": {
        "TableName": "MyTable",
        "KeyConditionExpression": "#pk = :pk AND begins_with(#sk, :sk)",
        "ExpressionAttributeNames": {
          "#pk": "Key",
          "#sk": "Value"
        },
        "ExpressionAttributeValues": {
          ":pk": {
            "S.$": "$.input.hoge"
          },
          ":sk": {
            "S": "fuga_"
          }
        }
      },
      "Retry": [
        // ...
      ],
      "Catch": [
        // ...
      ],
      "InputPath": "$",
      "ResultPath": "$.ExecuteQuery",
      "OutputPath": "$",
      "Next": "aaa"
    }
}

出力はこんな感じ

{
  "name": "ExecuteQuery",
  "output": {
    // ...
    "ExecuteQuery": {
      "Count": 1,
      "Items": [
        {
          "Value": {
            "S": "fuga_12345"
          },
          "Key": {
            "S": "hogehoge"
          }
        }
      ],
      "ScannedCount": 1
    }
  },
  "outputDetails": {
    "truncated": false
  }
}

あとはStateMachine内で適当に使いましょう

使えるAWS SDKの中身

多分ほぼ全部使えます 👏👏👏

ただ, StepFunctionsの仕様上大きなデータは引き回せないため, S3周りなどで小さいデータ以外を扱う場合は, 普通にLambdaでするほうが安定すると思います.

さいごに

ようやくStepFunctionsでノーコードがまともにできるようになるのでしょうか, 期待しています.

0
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?