LoginSignup
7
5

More than 5 years have passed since last update.

Serverless Step Functions v1.0をリリースしました

Last updated at Posted at 2017-04-17

https://github.com/horike37/serverless-step-functions
Serverless FrameworkでAWS Step Functionsが使えるプラグインをβ版にて公開していましたが、この度、βを脱却して1.0をリリースしました。

v1.0の機能

serverless.ymlの設定

以下が serverless.ymlの記述例です。
stateMachines内で、definitionにyamlにてState Languageを記述を行います。

serverless.yml

custom:
  accountId: xxxxxxxx

functions:
  hellofunc:
    handler: handler.hello

stepFunctions:
  stateMachines:
    hellostepfunc1:
      events:
        - http:
          path: gofunction
          method: GET
      definition:
        Comment: "A Hello World example of the Amazon States Language using an AWS Lambda Function"
        StartAt: HelloWorld1
        States:
          HelloWorld1:
            Type: Task
            Resource: arn:aws:lambda:${opt:region}:${self:custom.accountId}:function:${self:service}-${opt:stage}-hello
            End: true

トリガーイベントの対応

StateMachineをトリガーするイベントの設定はevents内で行います。
現在はAPI Gatewayのイベントのみに対応しています。v1.0の段階では、Cors、Custom Authorizer, API Keyには対応できていないのですが、これらも順次対応予定です。

API Gatewayのイベントの記法は以下の通りです。これで、GETで/gofunctionにアクセスすることで、hellostepfunc1のStateMachineが起動するようになります。

serverless.yml
stepFunctions:
  stateMachines:
    hellostepfunc1:
      events:
        - http:
          path: gofunction
          method: GET
      definition:

デプロイ

今回で、serverless deploy stepfのコマンドは廃止され、デプロイはすべてserverless deployを通して行う用になっています。

serverless deploy実行時に、serverless.ymlにStepFunctionsの記述が存在していれば、CloudFormationを通してデプロイが実行されます。

コマンドラインからの実行

serverless invoke stepf --name <your-statemachine> で実行可能です。

まとめ

というわけで、かなりシンプルな仕様になったと思います。以降はセマンティックバージョニングにも基いて互換性を保ちながらアップデートしていくことになります。

また、この機能はServerlessのコアに取り込むことも議論していましたが、結果、延期となってしまいました。
https://github.com/serverless/serverless/issues/3024

理由としては、ServerlessはAWSを含むマルチクラウドプロバイダーサポートを特徴としています。
Step FunctionsはAWS固有の機能です。こういったプロバイダー特有の機能は、イベントとFunctionからは切り分けてどのように管理していくのかを決めていく必要があるためです。(x-aws-といったベンダープレフィックスを付けるとか)

ただし、今回のリリースで決まった仕様は、ちゃんとした議論の結果でもあるので、コアに取り込まれることも大きく変わらないと思います。
それでは、良いStep Functionsライフを!

7
5
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
7
5