由CDK定义时,是否可以在本地运行AWS Step Functions? [英] Is there a way of running AWS Step Functions locally when defined by CDK?

查看:48
本文介绍了由CDK定义时,是否可以在本地运行AWS Step Functions?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AWS Step Functions可以使用步骤功能本地Docker" .但是,需要使用基于JSON的亚马逊州语言.如果使用AWS CDK/CloudFormation定义了AWS基础结构(Step Functions加上lambda),这根本就不方便.

AWS Step Functions may be run in a local Docker environment using Step Functions Local Docker. However, the step functions need to be defined using the JSON-based Amazon States Language. This is not at all convenient if your AWS infrastructure (Step Functions plus lambdas) is defined using AWS CDK/CloudFormation.

是否可以通过CDK或CloudFormation输出为状态机创建Amazon States Language定义,从而可以在本地运行step函数?

Is there a way to create the Amazon States Language definition of a state machine from the CDK or CloudFormation output, such that it’s possible to run the step functions locally?

我的开发周期目前需要30分钟才能在AWS中构建/部署/运行基于Lambda的步骤功能,以便对其进行测试,并且肯定有比这更好/更快的测试方法.

My development cycle is currently taking me 30 minutes to build/deploy/run my Lambda-based step functions in AWS in order to test them and there must surely be a better/faster way of testing them than this.

推荐答案

我们已经可以通过以下方式实现这一目标:

We have been able to achieve this by the following:

下载:

https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local.html

要在本地运行步骤功能,请在提取本地步骤功能文件的目录中运行:

To run step functions local, in the directory where you extracted the local Step Function files run:

java -jar StepFunctionsLocal.jar --lambda-endpoint http://localhost:3003

java -jar StepFunctionsLocal.jar --lambda-endpoint http://localhost:3003

要创建状态机,您需要一个json定义(可以从生成的模板中提取它,也可以获取工具包插件,键入步进函数,从模板中选择,并且可以作为入门者.也可以获取它从AWS控制台的step函数上的定义选项卡中.

To create a state machine, you need a json definition (It can be pulled from the generated template or can get the toolkit plug in for Vs code, type step functions, select from a template and that can be your starter. Can also get it from the AWS console in the definition tab on the step function.

在与定义json相同的目录中运行此命令:

Run this command in the same directory as the definition json:

aws stepfunctions --endpoint http://localhost:8083 create-state-machine --definition" cat step-function.json "-名称"local-state-machine";--role-arn" arn:aws:iam :: 012345678901:role/DummyRole"

aws stepfunctions --endpoint http://localhost:8083 create-state-machine --definition "cat step-function.json" --name "local-state-machine" --role-arn "arn:aws:iam::012345678901:role/DummyRole"

您现在应该可以(希望如此)击中SF了:)

You should be able to hit the SF now (hopefully) :)

这篇关于由CDK定义时,是否可以在本地运行AWS Step Functions?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆