• This repository has been archived on 23/Sep/2020
  • Stars
    star
    208
  • Rank 189,015 (Top 4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

step is a framework for building, testing and deploying AWS Step Functions and Lambda

Step (Beta)

One Small Step for Go

Step is a opinionated implementation of the AWS State Machine language in Go used to build and test AWS Step Functions and Lambdas. Step combines the Structure of a state machine with the Code of a lambda so that the two can be developed, tested and maintained together.

The three core components of Step are:

  1. Library: tools for building and deploying Step Functions in Go.
  2. Implementation: of the AWS State Machine specification to test with the code together (README).
  3. Deployer: to deploy Lambda's and Step Functions securely (README)

Getting Started

A Step function has two parts:

  1. A State Machine description in JSON, which outlines the flow of execution.
  2. The Lambda Function which executes the TaskFn states of the step function.

Create a State Machine like this:

func StateMachine(lambdaArn string) (machine.StateMachine, error) {
  state_machine, err := machine.FromJSON([]byte(`{
    "Comment": "Hello World",
    "StartAt": "HelloFn",
    "States": {
      "Hello": {
        "Type": "TaskFn",
        "Comment": "Deploy Step Function",
        "End": true
      }
    }
  }`))

  if err != nil {
      return nil, err
  }

  // Set the Handlers
  state_machine.SetTaskFnHandlers(CreateTaskHandlers())

  // Set Lambda Arn to call with Task States
  state_machine.SetResource(&lambdaArn)

  return state_machine, nil
}

TaskFn is a custom state type that injects Parameters to execute the correct handler.

Each TaskFn must have a handler that implements func(context.Context, <input_type>) (interface{}, error). These are defined like:

func CreateTaskFunctions() *handler.TaskHandlers {
  tm := handler.TaskHandlers{}
  // Assign Hello state the HelloHandler
	tm["Hello"] = HelloHandler
	return &tm
}

type Hello struct {
  Greeting *string
}

// HelloHandler takes a Hello struct alters its greeting and returns it
func HelloHandler(_ context.Context, hello *Hello) (*Hello, error) {
  if hello.Greeting == "" {
    hello.Greeting = "Hello World"
  }
  return hello, nil
}

To build a Step Function we then need an executable that can:

  1. Be executed in a Lambda
  2. Build the State Machine
func main() {
  var arg, command string
  switch len(os.Args) {
  case 1:
    fmt.Println("Starting Lambda")
    run.LambdaTasks(StateMachine("lambda"))
  case 2:
    command = os.Args[1]
    arg = ""
  case 3:
    command = os.Args[1]
    arg = os.Args[2]
  default:
    printUsage() // Print how to use and exit
  }

  switch command {
  case "json":
    run.JSON(StateMachine(arg))
  case "exec":
    run.Exec(StateMachine(""))(&arg)
  default:
    printUsage() // Print how to use and exit
  }

}
  1. ./step-hello-world will run as a Lambda Function
  2. ./step-hello-world json will print out the state machine

Testing

A core benefit when using Step and joining the State Machine and Lambda together is that it makes it possible to test your Step Functions execution.

For example, a basic test that ensures the correct output and execution path through the Hello World step function looks like:

func Test_HelloWorld_StateMachine(t *testing.T) {
  state_machine, err := StateMachine("")
  assert.NoError(t, err)

  exec, err := state_machine.Execute(&Hello{})
  assert.NoError(t, err)
  assert.Equal(t, "Hello World", exec.Output["Greeting"])

  assert.Equal(t, state_machine.Path(), []string{
    "Hello",
  })
}

Deploying

There are two ways to get a State Machine into the cloud:

  1. Bootstrap: Directly upload the Lambda and Step Function to AWS
  2. Deploy: Using the Step Deployer which is a Step Function included in this library.

The Step executable can perform both of these functions.

Step does not create the Lambda or Step Function in AWS, it only modifies them. So before either bootstrapping or deploying the resources must already be created.

First build and install step with:

go build && go install

Bootstrap (directly upload to the Step Function and Lambda):

# 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):

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"   \
  -states "$(./step-hello-world json)"

Development State

Step is still Beta and its API might change quickly.

More Links

  1. AWS Step Functions, State Machines, Bifrost, and Building Deployers
  2. Open Sourcing Coinbase’s Secure Deployment Pipeline
  3. https://docs.aws.amazon.com/step-functions/latest/dg/step-functions-dg.pdf
  4. https://github.com/vkkis93/serverless-step-functions-offline
  5. https://github.com/totherik/step

CC Renee French for the logo, borrowed from GopherCon 2017

More Repositories

1

terraform-landscape

Improve Terraform's plan output to be easier to read and understand
Ruby
1,570
star
2

coinbase-wallet-sdk

An open protocol that lets users connect their mobile wallets to your DApp
TypeScript
1,423
star
3

coinbase-pro-trading-toolkit

DEPRECATED — The Coinbase Pro trading toolkit
TypeScript
864
star
4

kryptology

Go
846
star
5

coinbase-pro-node

DEPRECATED — The official Node.js library for Coinbase Pro
JavaScript
839
star
6

build-onchain-apps

Accelerate your onchain creativity with the Build Onchain Apps Template. ⛵️
Solidity
701
star
7

odin

Archived: Odin deployer to AWS for 12 Factor applications.
Go
543
star
8

coinbase-python

DEPRECATED — Coinbase Python API
Python
521
star
9

onchainkit

React components and TypeScript utilities to help you build top-tier onchain apps.
TypeScript
481
star
10

solidity-style-guide

471
star
11

assume-role

DEPRECATED — assume-role: a CLI tool making it easy to assume IAM roles through an AWS Bastion account
Shell
423
star
12

geoengineer

DEPRECATED — Infrastructure As Code
Ruby
401
star
13

coinbase-node

DEPRECATED — The official Node.js library for the Coinbase API.
JavaScript
363
star
14

mesh-specifications

Specification files for the Mesh Blockchain Standard
Shell
320
star
15

cbpay-js

Coinbase Pay SDK
TypeScript
317
star
16

coinbase-php

DEPRECATED — PHP wrapper for the Coinbase API
PHP
297
star
17

smart-wallet

Solidity
287
star
18

coinbase-ruby

DEPRECATED — Ruby wrapper for the Coinbase API
Ruby
241
star
19

waas-sdk-react-native

Coinbase Wallet as a Service (WaaS) SDK for React Native. Enables MPC Operations for iOS and Android Devices.
TypeScript
234
star
20

temporal-ruby

Ruby SDK for Temporal
Ruby
218
star
21

wallet-mobile-sdk

An open protocol for mobile web3 apps to interact with wallets
Kotlin
203
star
22

mesh-sdk-go

Mesh Client Go SDK
Go
192
star
23

coinbase-ios-sdk

Integrate bitcoin into your iOS application with Coinbase
Swift
171
star
24

nft-dapp-starter-kit

Starter kit for developers who want to build an NFT minting site
TypeScript
159
star
25

mesh-cli

CLI for the Mesh API
Go
154
star
26

coinbase-java

Coinbase API v1 library for Java
Java
147
star
27

coinbase-commerce-node

Coinbase Commerce Node
JavaScript
142
star
28

waas-client-library-go

Coinbase Wallet as a Service (WaaS) Client Library in Go.
Go
140
star
29

coinbase-commerce-php

Coinbase Commerce PHP
PHP
136
star
30

traffic_jam

DEPRECATED — Ruby library for time-based rate limiting
Ruby
129
star
31

dexter

Forensics acquisition framework designed to be extensible and secure
Go
122
star
32

coinbase-exchange-ruby

DEPRECATED — Official Ruby library for the GDAX API
Ruby
122
star
33

mongobetween

Go
110
star
34

multisig-tool

DEPRECATED — Multisig Vault recovery tool
JavaScript
110
star
35

mesh-bitcoin

Bitcoin Mesh API Implementation
Go
108
star
36

mesh-ethereum

Ethereum Mesh API Implementation
Go
100
star
37

coinbase-advanced-py

The Advanced API Python SDK is a Python package that makes it easy to interact with the Coinbase Advanced API. The SDK handles authentication, HTTP connections, and provides helpful methods for interacting with the API.
Python
98
star
38

coinbase-android-sdk

DEPRECATED — Android SDK for Coinbase
Java
96
star
39

react-coinbase-commerce

Coinbase Commerce React
JavaScript
92
star
40

fenrir

Archived: AWS SAM deployer to manage serverless projects.
Go
91
star
41

pwnbot

You call PwnBot in Slack on someone else's unlocked computer
JavaScript
90
star
42

commerce-onchain-payment-protocol

Solidity
90
star
43

digital-asset-policy-proposal

Digital Asset Policy Proposal: Safeguarding America’s Financial Leadership
84
star
44

coinbase-commerce-python

Coinbase Commerce Python
Python
79
star
45

magic-spend

Solidity
78
star
46

verifications

📜 "Coinbase Verifications" is a set of Coinbase-verified onchain attestations that enable access to apps and other onchain benefits.
Solidity
75
star
47

CBTabViewExample

TypeScript
72
star
48

chainstorage

The File System For a Multi-Blockchain World
Go
71
star
49

coinbase-bitmonet-sdk

DEPRECATED — Library to accept bitcoin payments in your Android App
Java
63
star
50

self-service-iam

DEPRECATED — Self Service AWS IAM Policies for dev at scale
JavaScript
58
star
51

coinbase-wordpress

DEPRECATED — Coinbase plugin/widget for Wordpress
57
star
52

coinbase-commerce-woocommerce

Accept Bitcoin on your WooCommerce-powered website.
PHP
57
star
53

paymaster-bundler-examples

JavaScript
55
star
54

barbar

DEPRECATED — OSX crypto-currency price ticker
Swift
53
star
55

demeter

DEPRECATED — Security Group Management For AWS
Ruby
52
star
56

coinbase-exchange-node

DEPRECATED — Use gdax-node
JavaScript
47
star
57

cadence-ruby

Ruby SDK for Cadence
Ruby
43
star
58

coinbase-woocommerce

DEPRECATED — Accept Bitcoin on your WooCommerce-powered website.
38
star
59

protoc-gen-rbi

Protobuf compiler plugin that generates Sorbet .rbi "Ruby Interface" files.
Go
38
star
60

mesh-ecosystem

Repository of all open source Mesh implementations and SDKs
33
star
61

master_lock

Inter-process locking library using Redis.
Ruby
32
star
62

coinbase-commerce-ruby

Coinbase Commerce Ruby Gem
Ruby
30
star
63

watchdog

DEPRECATED -- Github Bot for Datadog codification
Go
28
star
64

bittip

DEPRECATED — Reddit tip bot
JavaScript
27
star
65

cash-addr

Utility to convert between base58 and CashAddr BCH addresses.
Ruby
26
star
66

maxfuzz

DEPRECATED — Containerized Cloud Fuzzing
C
26
star
67

rules_ruby

Bazel Ruby Rules
Starlark
24
star
68

mesh-geth-sdk

go-ethereum based sdk for Mesh API
Go
24
star
69

onchain-app-template

TypeScript
24
star
70

redisbetween

Go
23
star
71

gtt-ui

DEPRECATED
JavaScript
22
star
72

btcexport

Export process for Bitcoin blockchain data to CSV
Go
22
star
73

bchd-explorer

Vue
21
star
74

baseca

Go
21
star
75

coinbase-sdk-nodejs

TypeScript
21
star
76

coinbase-commerce-whmcs

Coinbase Commerce module for WHMCS
PHP
18
star
77

coinbase-nft-floor-price

Coinbase NFT floor price estimate model
Python
17
star
78

coinbase-magento

DEPRECATED — Accept Bitcoin on your Magento-powered website.
17
star
79

salus

We would like to request that all contributors please clone a *fresh copy* of this repository since the September 21st maintenance.
HTML
17
star
80

coinbase-android-sdk-example

DEPRECATED — Example android app leveraging the coinbase android sdk
Java
15
star
81

staking-client-library-go

Programmatic access to Coinbase's best-in-class staking infrastructure and services. 🔵
Go
15
star
82

coinbase-spree

DEPRECATED — Accept bitcoin payments on your Spree store with Coinbase.
15
star
83

coinbase-cloud-sdk-js

TypeScript
14
star
84

staking-client-library-ts

Programmatic access to Coinbase's best-in-class staking infrastructure and services. 🔵
TypeScript
14
star
85

service_variables

Service level variables backed by Redis - useful for service wide configuration.
Ruby
12
star
86

solidity-workshop

JavaScript
12
star
87

chainsformer

Go
12
star
88

omniauth-coinbase

DEPRECATED — Coinbase OAuth 2 Strategy for Omniauth
Ruby
12
star
89

coinbase-javascript-sdk

DEPRECATED
JavaScript
11
star
90

coinbase-commerce-prestashop

DEPRECATED — Official Coinbase Commerce Prestashop Payment Module
PHP
11
star
91

mkr-vote-proxy

Cold storage-friendly voting for MKR tokens
Solidity
11
star
92

chainnode

Go
10
star
93

step-asg-deployer

Deprecated, renamed and maintained at https://github.com/coinbase/odin
Go
10
star
94

wrapped-tokens-os

TypeScript
10
star
95

eip-token-upgrade

Solidity
10
star
96

client-analytics

TypeScript
9
star
97

code-of-conduct

Code of conduct for open source projects managed by Coinbase
9
star
98

coinbase-magento2

DEPRECATED: Accept Bitcoin on your Magento2-powered website.
8
star
99

coinbase-commerce-opencart

DEPRECATED — Coinbase Commerce Integration For Opencart
PHP
8
star
100

waas-proxy-server

Go
7
star