https://github.com/coinbase/step-hello-world
example coinbase/step framework application
https://github.com/coinbase/step-hello-world
Last synced: about 1 year ago
JSON representation
example coinbase/step framework application
- Host: GitHub
- URL: https://github.com/coinbase/step-hello-world
- Owner: coinbase
- License: apache-2.0
- Created: 2018-03-03T07:33:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-10-06T00:17:26.000Z (over 3 years ago)
- Last Synced: 2025-03-24T10:38:42.864Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 34.2 KB
- Stars: 5
- Watchers: 24
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# step-hello-world
`step-hello-world` is an example application for the [Step](https://github.com/coinbase/step) library. It is a AWS Step Function and Lambda that takes an input, and returns a greeting.
### Getting started
Building with `go build .`, which will create the binary `step-hello-world`.
You can test its execution with:
```bash
./step-hello-world exec
{
"Greeting": "Hello World"
}
./step-hello-world exec '{"Greeting": "Hi"}'
{
"Greeting": "Hi"
}
```
Looking at the State Machine output:
```bash
./step-hello-world json
{
"Comment": "Hello World",
"StartAt": "Hello",
"States": {
"Hello": {
"Type": "TaskFn",
"Comment": "Deploy Step Function",
"Resource": "coinbase-step-hello-world",
"End": true
}
}
}
```
### Deploying
To create the AWS resources we use [GeoEngineer](https://github.com/coinbase/geoengineer). This requires `ruby`, `bundler` and `terraform`.
Create the resources with:
```
bundle
./geo apply resources/step-hello-world.rb
```
Once the resources are created you can bootstrap or deploy `step-hello-world` with the `step` binary from [github.com/coinbase/step](https://github.com/coinbase/step).
Bootstrap (directly upload to the Step Function and Lambda):
```bash
# Use AWS credentials or assume-role into AWS
# Build linux zip for lambda
GOOS=linux go build -o lambda
zip lambda.zip lambda
# Tell step to bootstrap this lambda
step bootstrap \
-lambda "coinbase-step-hello-world" \
-step "coinbase-step-hello-world" \
-states "$(./step-hello-world json)"
```
Deploy (via the step-deployer step function in github.com/coinbase/step):
```bash
GOOS=linux go build -o lambda
zip lambda.zip lambda
# Tell step-deployer to deploy this lambda
step deploy \
-lambda "coinbase-step-hello-world" \
-step "coinbase-step-hello-world" \
-project "coinbase/step-hello-world"\
-config "development" \
-states "$(./step-hello-world json)"
```
To invoke the deployed step-hello-world in AWS requires the `aws-cli`:
```bash
ARN="arn:aws:states:${AWS_REGION}:${AWS_ACCOUNT_ID}:stateMachine:coinbase-step-hello-world"
EXECUTION_ARN=$(aws stepfunctions start-execution \
--state-machine-arn $ARN \
--input '{"Greeting": "Hi"}' | jq -r ".executionArn" )
sleep 1
aws stepfunctions describe-execution --execution-arn $EXECUTION_ARN
{
"executionArn": "...coinbase-step-hello-world:execution",
"stateMachineArn": "...stateMachine:coinbase-step-hello-world",
"name": "...",
"status": "SUCCEEDED",
"startDate": 1520050165.321,
"stopDate": 1520050165.597,
"input": "{\"Greeting\": \"Hi\"}",
"output": "{\"Greeting\":\"Hi\"}"
}
aws stepfunctions get-execution-history --execution-arn $EXECUTION_ARN
{
"events": [
{
"timestamp": 1520050165.321,
"type": "ExecutionStarted",
"id": 1,
"previousEventId": 0,
"executionStartedEventDetails": {
"input": "{\"Greeting\": \"Hi\"}",
"roleArn": "...role/coinbase-step-hello-world-step-function-role"
}
},
...
}
```