simplerubysteps 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d5cf7a99237d4043c3f2b547815ccf5b82ed750f2e194da5db111265481a1b6b
4
+ data.tar.gz: 9f335626271e6262e02f1b9fd20c3a294bc4cb46a8d5df287b57746a07607165
5
+ SHA512:
6
+ metadata.gz: 6b312d30dd07e329d1d2ca8d11303c382afabe670a59d99a680eb923771e6251e43144585a70ae6a7fa2ac8b3590ccf1ebc25b7d5f30ac7a1b35156633feb662
7
+ data.tar.gz: c3c272f1f2a36827517890203c9b4f18cb3697bccc28538f080c4e8bb65b22ef303f53c3b8431e31d12c47fe36559ac0270a125da02122b2267fcba71cb84008
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Christian Tschenett
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # Simplerubysteps
2
+
3
+ Simplerubysteps simplifies the administration of AWS Step Functions with ruby (eventually - this is an early alpha version)
4
+
5
+ This is software in the experimental stage and should not really be used by anyone. Be warned.
6
+
7
+ ## Installation
8
+
9
+ Prerequisites (for alpha version):
10
+ * Linux-like environment (the deployment tools are currently implemented with shell scripts)
11
+ * AWS CLI installed
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ require "simplerubysteps"
17
+ ```
18
+
19
+ And install the gem:
20
+
21
+ $ gem install simplerubysteps
22
+
23
+ ## Usage
24
+
25
+ ### Create AWS Step Functions State Machine with ruby DSL
26
+
27
+ ```
28
+ cd samples/sample1
29
+ vi workflow.rb
30
+ ```
31
+
32
+ ### Create CloudFormation stack with Step Functions State Machine and supporting Lambda functions
33
+
34
+ ```
35
+ export AWS_PROFILE=...
36
+ cd samples/sample1
37
+ simplerubysteps-deploy
38
+ ```
39
+
40
+ ### Trigger State Machine Execution and wait for completion
41
+
42
+ ```
43
+ export AWS_PROFILE=...
44
+ cd samples/sample1
45
+ echo '{"foo": "John Wick"}' | simplerubysteps-workflow-run
46
+ ```
47
+
48
+ ### Delete CloudFormation stack
49
+
50
+ ```
51
+ export AWS_PROFILE=...
52
+ cd samples/sample1
53
+ simplerubysteps-destroy
54
+ ```
55
+
56
+ ## Development
57
+
58
+ After checking out the repo, run `bin/setup` to install dependencies.
59
+
60
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
61
+
62
+ ## Contributing
63
+
64
+ Bug reports and pull requests are (soon - after alpha phase) welcome on GitHub at https://github.com/chtz/simplerubysteps
65
+
66
+ ## License
67
+
68
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "simplerubysteps"
5
+
6
+ require "irb"
7
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ bin_dir = File.expand_path(File.dirname(__FILE__))
4
+ shell_script_path = File.join(bin_dir, '../lib/deploy.sh')
5
+
6
+ Kernel.exec(shell_script_path)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ bin_dir = File.expand_path(File.dirname(__FILE__))
4
+ shell_script_path = File.join(bin_dir, '../lib/destroy.sh')
5
+
6
+ Kernel.exec(shell_script_path)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ bin_dir = File.expand_path(File.dirname(__FILE__))
4
+ shell_script_path = File.join(bin_dir, '../lib/workflow-run.sh')
5
+
6
+ Kernel.exec(shell_script_path)
data/lib/deploy.sh ADDED
@@ -0,0 +1,91 @@
1
+ #!/bin/bash
2
+
3
+ SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
4
+
5
+ export STACK_NAME=$(basename "$PWD")
6
+
7
+ echo "CF Stack: $STACK_NAME"
8
+
9
+ export CF_TEMPLATE=$SCRIPT_DIR/../lib/statemachine.yaml
10
+
11
+ export DEPLOY_BUCKET=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --output text --query "Stacks[].Outputs[]"|grep DeployBucket|awk '{print $2}')
12
+
13
+ if [[ -n "$DEPLOY_BUCKET" ]]; then
14
+ echo "Deployment bucket found: $DEPLOY_BUCKET"
15
+ else
16
+ echo "Creating deloyment bucket"
17
+
18
+ echo '[{"ParameterKey":"DeployLambda","ParameterValue":"no"},{"ParameterKey":"DeployStepfunctions","ParameterValue":"no"}]' > /tmp/params.json
19
+
20
+ aws cloudformation deploy \
21
+ --template-file $CF_TEMPLATE \
22
+ --stack-name $STACK_NAME \
23
+ --capabilities '["CAPABILITY_IAM","CAPABILITY_NAMED_IAM"]' \
24
+ --parameter-overrides file:///tmp/params.json
25
+
26
+ aws cloudformation wait stack-create-complete \
27
+ --stack-name $STACK_NAME || \
28
+ { echo "Stack creation/update failed." >&2; exit 1; }
29
+
30
+ export DEPLOY_BUCKET=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --output text --query "Stacks[].Outputs[]"|grep DeployBucket|awk '{print $2}')
31
+ fi
32
+
33
+ echo "Uploading lambda ZIP"
34
+
35
+ rm -f /tmp/function.zip
36
+ zip /tmp/function.zip *.rb
37
+ (cd $SCRIPT_DIR/../lib; zip -r /tmp/function.zip *.rb)
38
+ (cd $SCRIPT_DIR/../lib; zip -r /tmp/function.zip simplerubysteps/*.rb)
39
+
40
+ export LAMBDA_SHA=$(shasum /tmp/function.zip | awk '{print $1}')
41
+ export UPLOADED_LAMBDA_ZIP=function-$LAMBDA_SHA.zip
42
+ aws s3 cp /tmp/function.zip s3://$DEPLOY_BUCKET/$UPLOADED_LAMBDA_ZIP
43
+
44
+ export LAMBDA_FUNCTION_ARN=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --output text --query "Stacks[].Outputs[]"|grep LambdaFunctionARN|awk '{print $2}')
45
+
46
+ if [[ -n "$LAMBDA_FUNCTION_ARN" ]]; then
47
+ echo "Lambda ARN found: $LAMBDA_FUNCTION_ARN"
48
+ else
49
+ echo "Creating lambda"
50
+
51
+ echo '[{"ParameterKey":"DeployLambda","ParameterValue":"yes"},{"ParameterKey":"DeployStepfunctions","ParameterValue":"no"},{"ParameterKey":"LambdaS3","ParameterValue":"'$UPLOADED_LAMBDA_ZIP'"}]' > /tmp/params.json
52
+
53
+ aws cloudformation deploy \
54
+ --template-file $CF_TEMPLATE \
55
+ --stack-name $STACK_NAME \
56
+ --capabilities '["CAPABILITY_IAM","CAPABILITY_NAMED_IAM"]' \
57
+ --parameter-overrides file:///tmp/params.json
58
+
59
+ aws cloudformation wait stack-update-complete \
60
+ --stack-name $STACK_NAME || \
61
+ { echo "Stack update failed." >&2; exit 1; }
62
+
63
+ export LAMBDA_FUNCTION_ARN=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --output text --query "Stacks[].Outputs[]"|grep LambdaFunctionARN|awk '{print $2}')
64
+ fi
65
+
66
+ echo "Uploading state machine JSON"
67
+
68
+ ruby -e 'require "./workflow.rb";puts $sm.render.to_json' > /tmp/my-state-machine-definition.json
69
+ export STATE_MACHINE_JSON_SHA=$(shasum /tmp/my-state-machine-definition.json | awk '{print $1}')
70
+ export UPLOADED_STATE_MACHINE_JSON=statemachine-$STATE_MACHINE_JSON_SHA.zip
71
+ aws s3 cp /tmp/my-state-machine-definition.json s3://$DEPLOY_BUCKET/$UPLOADED_STATE_MACHINE_JSON
72
+
73
+ echo "Updating CloudFormation Stack"
74
+
75
+ echo '[{"ParameterKey":"DeployLambda","ParameterValue":"yes"},{"ParameterKey":"DeployStepfunctions","ParameterValue":"yes"},{"ParameterKey":"LambdaS3","ParameterValue":"'$UPLOADED_LAMBDA_ZIP'"},{"ParameterKey":"StepFunctionsS3","ParameterValue":"'$UPLOADED_STATE_MACHINE_JSON'"}]' > /tmp/params.json
76
+
77
+ aws cloudformation deploy \
78
+ --template-file $CF_TEMPLATE \
79
+ --stack-name $STACK_NAME \
80
+ --capabilities '["CAPABILITY_IAM","CAPABILITY_NAMED_IAM"]' \
81
+ --parameter-overrides file:///tmp/params.json
82
+
83
+ aws cloudformation wait stack-update-complete \
84
+ --stack-name $STACK_NAME || \
85
+ { echo "Stack update failed." >&2; exit 1; }
86
+
87
+ export STEP_FUNCTIONS_ARN=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --output text --query "Stacks[].Outputs[]"|grep StepFunctionsStateMachineARN|awk '{print $2}')
88
+
89
+ echo "StepFunctions ARN found: $STEP_FUNCTIONS_ARN"
90
+
91
+ echo "Done"
data/lib/destroy.sh ADDED
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ export STACK_NAME=$(basename "$PWD")
4
+
5
+ export DEPLOY_BUCKET=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --output text --query "Stacks[].Outputs[]"|grep DeployBucket|awk '{print $2}')
6
+
7
+ aws s3 rm s3://$DEPLOY_BUCKET --recursive
8
+
9
+ aws cloudformation delete-stack \
10
+ --stack-name $STACK_NAME
data/lib/function.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'json'
2
+ require './workflow.rb'
3
+
4
+ def handler(event:, context:)
5
+ puts ENV.inspect
6
+ puts event
7
+ puts context.inspect
8
+ $sm.states[event["Task"].to_sym].perform_action event["Input"]
9
+ end
@@ -0,0 +1,3 @@
1
+ module Simplerubysteps
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,178 @@
1
+ require "simplerubysteps/version"
2
+ require "json"
3
+
4
+ module Simplerubysteps
5
+ $FUNCTION_ARN=ENV["LAMBDA_FUNCTION_ARN"] ? ENV["LAMBDA_FUNCTION_ARN"] : "unknown"
6
+
7
+ class StateMachine
8
+ attr_reader :states
9
+ attr_reader :start_at
10
+
11
+ def initialize()
12
+ @states = {}
13
+ end
14
+
15
+ def add(state)
16
+ @start_at = state.name unless @start_at
17
+
18
+ @states[state.name] = state
19
+ state.state_machine = self
20
+
21
+ state
22
+ end
23
+
24
+ def render
25
+ {
26
+ :StartAt => @start_at,
27
+ :States => @states.map { |name,state| [name, state.render] }.to_h
28
+ }
29
+ end
30
+ end
31
+
32
+ class State
33
+ attr_reader :name
34
+ attr_accessor :state_machine
35
+
36
+ def initialize(name)
37
+ @name = name
38
+ @dict = {}
39
+ end
40
+
41
+ def []=(key,value)
42
+ @dict[key] = value
43
+ end
44
+
45
+ def next=(state)
46
+ @dict[:Next] = (state.is_a? Symbol) ? state : state.name
47
+ end
48
+
49
+ def render
50
+ dict = @dict
51
+ dict[:End] = true unless dict[:Next]
52
+ dict
53
+ end
54
+ end
55
+
56
+ class Task < State
57
+ def initialize(name)
58
+ super
59
+ @dict[:Type] = "Task"
60
+ @dict[:Resource] = $FUNCTION_ARN
61
+ @dict[:"Parameters"] = {
62
+ :Task => name,
63
+ "Input.$" => "$"
64
+ }
65
+ end
66
+
67
+ def action(&action_block)
68
+ @action_block = action_block
69
+ end
70
+
71
+ def perform_action(input)
72
+ @action_block.call(input) if @action_block
73
+ end
74
+ end
75
+
76
+ class ChoiceItem
77
+ def initialize(dict = {}, state = nil)
78
+ @dict = dict
79
+ self.next = state if state
80
+ end
81
+
82
+ def next=(state)
83
+ @dict[:Next] = (state.is_a? Symbol) ? state : state.name
84
+ end
85
+
86
+ def render
87
+ @dict
88
+ end
89
+ end
90
+
91
+ class Choice < State
92
+ attr_reader :choices
93
+
94
+ def initialize(name)
95
+ super
96
+ @choices = []
97
+ @dict[:Type] = "Choice"
98
+ end
99
+
100
+ def add(item)
101
+ @choices.push item
102
+ end
103
+
104
+ def add_string_matches(var, match, state)
105
+ add ChoiceItem.new({
106
+ :Variable => var,
107
+ :StringMatches => match
108
+ }, state)
109
+ end
110
+
111
+ def default=(state)
112
+ @dict[:Default] = (state.is_a? Symbol) ? state : state.name
113
+ end
114
+
115
+ def next=(state)
116
+ self.default = state
117
+ end
118
+
119
+ def render
120
+ dict = @dict.clone
121
+ dict[:Choices] = @choices.map { |item| item.render }
122
+ dict
123
+ end
124
+ end
125
+
126
+ ################################################################################
127
+
128
+ $sm = StateMachine.new
129
+ $tasks = []
130
+
131
+ def task(name)
132
+ t = $sm.add Task.new(name)
133
+
134
+ $tasks.last.next = t if $tasks.last
135
+
136
+ $tasks.push t
137
+ yield if block_given?
138
+ $tasks.pop
139
+ end
140
+
141
+
142
+ def action(&action_block)
143
+ $tasks.last.action &action_block
144
+ end
145
+
146
+ def transition(state)
147
+ $tasks.last.next = state
148
+ end
149
+
150
+ def choice(name)
151
+ t = $sm.add Choice.new(name)
152
+
153
+ $tasks.last.next = t if $tasks.last
154
+
155
+ $tasks.push t
156
+ yield if block_given?
157
+ $tasks.pop
158
+ end
159
+
160
+ def string_matches(var, match)
161
+ c = ChoiceItem.new({
162
+ :Variable => var,
163
+ :StringMatches => match
164
+ })
165
+
166
+ $tasks.last.add c
167
+
168
+ $tasks.push c
169
+ yield if block_given?
170
+ $tasks.pop
171
+ end
172
+
173
+ def default
174
+ $tasks.push $tasks.last
175
+ yield if block_given?
176
+ $tasks.pop
177
+ end
178
+ end
@@ -0,0 +1,122 @@
1
+ ---
2
+ AWSTemplateFormatVersion: "2010-09-09"
3
+ Parameters:
4
+ LambdaS3:
5
+ Description: LambdaS3.
6
+ Default: function.zip
7
+ Type: String
8
+ StepFunctionsS3:
9
+ Description: StepFunctionsS3.
10
+ Default: my-state-machine-definition.json
11
+ Type: String
12
+ DeployLambda:
13
+ Description: DeployLambda.
14
+ Default: "yes"
15
+ Type: String
16
+ AllowedValues:
17
+ - "yes"
18
+ - "no"
19
+ ConstraintDescription: must specify yes or no.
20
+ DeployStepfunctions:
21
+ Description: DeployStepfunctions.
22
+ Default: "yes"
23
+ Type: String
24
+ AllowedValues:
25
+ - "yes"
26
+ - "no"
27
+ ConstraintDescription: must specify yes or no.
28
+ Conditions:
29
+ CreateLambda: !Equals
30
+ - !Ref DeployLambda
31
+ - "yes"
32
+ CreateStepfunctions: !Equals
33
+ - !Ref DeployStepfunctions
34
+ - "yes"
35
+ Resources:
36
+ DeployBucket:
37
+ Type: AWS::S3::Bucket
38
+ LambdaFunction:
39
+ Type: 'AWS::Lambda::Function'
40
+ Condition: CreateLambda
41
+ Properties:
42
+ Code:
43
+ S3Bucket: !Ref DeployBucket
44
+ S3Key: !Ref LambdaS3
45
+ Handler: function.handler
46
+ Role: !GetAtt MyLambdaRole.Arn
47
+ Runtime: ruby2.7
48
+ StepFunctionsStateMachine:
49
+ Type: 'AWS::StepFunctions::StateMachine'
50
+ Condition: CreateStepfunctions
51
+ Properties:
52
+ DefinitionS3Location:
53
+ Bucket: !Ref DeployBucket
54
+ Key: !Ref StepFunctionsS3
55
+ RoleArn: !GetAtt StepFunctionsRole.Arn
56
+ MyLambdaRole:
57
+ Type: AWS::IAM::Role
58
+ Condition: CreateLambda
59
+ Properties:
60
+ AssumeRolePolicyDocument:
61
+ Version: "2012-10-17"
62
+ Statement:
63
+ - Effect: Allow
64
+ Principal:
65
+ Service: lambda.amazonaws.com
66
+ Action:
67
+ - sts:AssumeRole
68
+ Policies:
69
+ - PolicyName: lambda-policy
70
+ PolicyDocument:
71
+ Version: "2012-10-17"
72
+ Statement:
73
+ - Effect: Allow
74
+ Action:
75
+ - logs:CreateLogGroup
76
+ - logs:CreateLogStream
77
+ - logs:PutLogEvents
78
+ Resource: arn:aws:logs:*:*:*
79
+ StepFunctionsRole:
80
+ Type: AWS::IAM::Role
81
+ Condition: CreateStepfunctions
82
+ Properties:
83
+ AssumeRolePolicyDocument:
84
+ Version: "2012-10-17"
85
+ Statement:
86
+ - Effect: Allow
87
+ Principal:
88
+ Service: states.amazonaws.com
89
+ Action: sts:AssumeRole
90
+ Policies:
91
+ - PolicyName: StepFunctionsPolicy
92
+ PolicyDocument:
93
+ Version: "2012-10-17"
94
+ Statement:
95
+ - Effect: Allow
96
+ Action:
97
+ - logs:CreateLogGroup
98
+ - logs:CreateLogStream
99
+ - logs:PutLogEvents
100
+ Resource: arn:aws:logs:*:*:*
101
+ - Effect: Allow
102
+ Action:
103
+ - lambda:InvokeFunction
104
+ Resource: !GetAtt LambdaFunction.Arn
105
+ Outputs:
106
+ DeployBucket:
107
+ Value: !Ref DeployBucket
108
+ LambdaRoleARN:
109
+ Value: !GetAtt MyLambdaRole.Arn
110
+ Condition: CreateLambda
111
+ LambdaFunctionARN:
112
+ Value: !GetAtt LambdaFunction.Arn
113
+ Condition: CreateLambda
114
+ LambdaFunctionName:
115
+ Value: !Ref LambdaFunction
116
+ Condition: CreateLambda
117
+ StepFunctionsRoleARN:
118
+ Value: !GetAtt StepFunctionsRole.Arn
119
+ Condition: CreateStepfunctions
120
+ StepFunctionsStateMachineARN:
121
+ Value: !GetAtt StepFunctionsStateMachine.Arn
122
+ Condition: CreateStepfunctions
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+
3
+ export STACK_NAME=$(basename "$PWD")
4
+
5
+ export STEP_FUNCTIONS_ARN=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --output text --query "Stacks[].Outputs[]"|grep StepFunctionsStateMachineARN|awk '{print $2}')
6
+
7
+ tee /tmp/statemachineinput.json > /dev/null
8
+ STATE_MACHINE_INPUT="$(cat /tmp/statemachineinput.json)"
9
+
10
+ EXECUTION_ARN=$(aws stepfunctions start-execution \
11
+ --state-machine-arn $STEP_FUNCTIONS_ARN \
12
+ --input "$STATE_MACHINE_INPUT" \
13
+ --query "executionArn" \
14
+ --output text)
15
+
16
+ echo "Started execution: $EXECUTION_ARN"
17
+
18
+ while true; do
19
+ STATUS=$(aws stepfunctions describe-execution \
20
+ --execution-arn $EXECUTION_ARN \
21
+ --query "status" \
22
+ --output text)
23
+
24
+ if [[ "$STATUS" == "SUCCEEDED" ]]; then
25
+ break
26
+ elif [[ "$STATUS" == "FAILED" || "$STATUS" == "TIMED_OUT" || "$STATUS" == "ABORTED" ]]; then
27
+ echo "Execution failed with status: $STATUS"
28
+ exit 1
29
+ else
30
+ sleep 5
31
+ fi
32
+ done
33
+
34
+ OUTPUT=$(aws stepfunctions describe-execution \
35
+ --execution-arn $EXECUTION_ARN \
36
+ --query "output" \
37
+ --output text)
38
+
39
+ echo "Execution output: $OUTPUT"
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require "simplerubysteps"
4
+ include Simplerubysteps
5
+
6
+ task :t1 do
7
+ action do |input|
8
+ puts "Task t1: #{input}"
9
+ input.merge({ "Foo1" => (input["foo"] == "John Wick" ? "ja" : "nein") })
10
+ end
11
+
12
+ choice :t2 do
13
+ string_matches "$.Foo1", "ja" do
14
+ task :t3 do
15
+ action do |input|
16
+ puts "Task t3: #{input}"
17
+ input.merge({ "Foo3": "Bar3x" })
18
+ end
19
+
20
+ transition :t5
21
+ end
22
+ end
23
+
24
+ default do
25
+ task :t4 do
26
+ action do |input|
27
+ puts "Task t4: #{input}"
28
+ input.merge({ "Foo4": "Bar4xy" })
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ task :t5 do
36
+ action do |input|
37
+ puts "Task t5: #{input}"
38
+ input.merge({ "Foo5" => "Bar5" })
39
+ end
40
+ end
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "simplerubysteps/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "simplerubysteps"
7
+ spec.version = Simplerubysteps::VERSION
8
+ spec.authors = ["Christian Tschenett"]
9
+ spec.email = ["simplerubysteps@furthermore.ch"]
10
+
11
+ spec.summary = %q{simplerubysteps makes it easy to manage AWS Step Functions with ruby.}
12
+
13
+ spec.homepage = "https://github.com/chtz/simplerubysteps"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+ spec.files << "lib/deploy.sh"
20
+ spec.files << "lib/destroy.sh"
21
+ spec.files << "lib/workflow-run.sh"
22
+ spec.files << "lib/statemachine.yaml"
23
+ spec.files << "lib/function.rb"
24
+
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.executables << "simplerubysteps-deploy"
28
+ spec.executables << "simplerubysteps-destroy"
29
+ spec.executables << "simplerubysteps-workflow-run"
30
+
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.17"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplerubysteps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Christian Tschenett
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-04-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - simplerubysteps@furthermore.ch
44
+ executables:
45
+ - simplerubysteps-deploy
46
+ - simplerubysteps-destroy
47
+ - simplerubysteps-workflow-run
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - exe/simplerubysteps-deploy
59
+ - exe/simplerubysteps-destroy
60
+ - exe/simplerubysteps-workflow-run
61
+ - lib/deploy.sh
62
+ - lib/destroy.sh
63
+ - lib/function.rb
64
+ - lib/simplerubysteps.rb
65
+ - lib/simplerubysteps/version.rb
66
+ - lib/statemachine.yaml
67
+ - lib/workflow-run.sh
68
+ - samples/sample1/workflow.rb
69
+ - simplerubysteps.gemspec
70
+ homepage: https://github.com/chtz/simplerubysteps
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubygems_version: 3.0.3.1
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: simplerubysteps makes it easy to manage AWS Step Functions with ruby.
93
+ test_files: []