Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ $> stepfunctions-local start --lambda-endpoint http://hostname.com:1337 --lambda
### I want to run a local state machine with local Lambdas
`stepfunctions-local` does not aim to emulate Lambda. To do this you need a local Lambda server that is compliant to AWS API. We recommand to use [localstack](https://github.com/localstack/localstack) for that. See how to [here](#run-lambdas-with-localstack).

### I want to run a local state machine with distant ECS Tasks
Simply configure your ECS endpoint and region when starting the server:
```bash
$> stepfunctions-local start --ecs-endpoint http://hostname.com:1337 --ecs-region my-region
```
`stepfunctions-local` will directly query ECS using this configuration.

### I want to run a local state machine with local ECS Tasks
`stepfunctions-local` does not aim to emulate ECS. To do this you need a local ECS server that is compliant to AWS API. You may have to create a mock server to do this yourself.

## Prerequisites
* [AWS Command Line Interface (CLI)](https://aws.amazon.com/cli/)
* [Node 8 or greater](https://nodejs.org/)
Expand Down Expand Up @@ -75,6 +85,8 @@ Options:
--region <region> the region the server should run on
--lambda-region <lambda-region> the region for lambda
--lambda-endpoint <lambda-endpoint> the endpoint for lambda
--ecs-region <ecs-region> the region for ECS
--ecs-endpoint <ecs-endpoint> the endpoint for ECS
-h, --help output usage information
```

Expand All @@ -93,6 +105,8 @@ stepfunctionsLocal.start({
region: 'local',
lambdaRegion: 'local',
lambdaEndpoint: 'http://localhost:4574',
ecsRegion: 'local',
ecsEndpoint: 'http://localhost:4600',
});
```

Expand All @@ -101,6 +115,8 @@ stepfunctionsLocal.start({
- region: local
- lambda-region: local
- lambda-endpoint: http://localhost:4574
- ecs-region: local
- ecs-endpoint: http://localhost:4600

### Configure logs
The service does not log anything by default. It uses the [debug](https://www.npmjs.com/package/debug) package which is based on the `DEBUG` environment variable. You can log process info by setting it.
Expand Down Expand Up @@ -201,12 +217,24 @@ $> stepfunctions-local start --lambda-endpoint http://localhost:4574 --lambda-re
**Wow, that's great !**
Feedback, bug reports and pull requests are more than welcome !

You can test your code with :
To run the tests, you must first [authenticate to AWS](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html),
including setting a default region. You can do this via the `aws configure` command or by setting environment variables:

```bash
$> export AWS_ACCESS_KEY_ID=(your access key)
$> export AWS_SECRET_ACCESS_KEY=(your secret key)
$> export AWS_DEFAULT_REGION=us-east-1
```

You can then run the tests as follows:

```bash

$> npm run lint
$> npm run test
```


## See also
- [AWS Step Functions Documentation](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html)
- [AWS Step Functions SDK](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/StepFunctions.html)
Expand Down
10 changes: 9 additions & 1 deletion bin/stepfunctions-local-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ program
.option('--region <region>', 'the region the server should run on')
.option('--lambda-endpoint <lambda-endpoint>', 'the endpoint for lambda')
.option('--lambda-region <lambda-region>', 'the region for lambda')
.parse(process.argv)
.option('--ecs-endpoint <ecs-endpoint>', 'the endpoint for ECS')
.option('--ecs-region <ecs-region>', 'the region for ECS')
.parse(process.argv);

const config = {};
if (undefined !== program.port) {
Expand All @@ -25,5 +27,11 @@ if (undefined !== program.lambdaEndpoint) {
if (undefined !== program.lambdaRegion) {
config.lambdaRegion = program.lambdaRegion;
}
if (undefined !== program.ecsEndpoint) {
config.ecsEndpoint = program.ecsEndpoint;
}
if (undefined !== program.ecsRegion) {
config.ecsRegion = program.ecsRegion;
}
console.log('Starting stepfunctions-local server...');
server.start(config);
Loading