-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (42 loc) · 1.19 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"encoding/json"
"fmt"
"reflect"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sfn"
"github.com/google/uuid"
)
// Event defines your lambda input/output data structure,
type Event struct {
Payload string `json:"payload"`
Status int `json:"status"`
}
var (
stateMachineArn = "your-state-machine-arn"
defaultRegion = "ap-southeast-1"
)
func main() {
sfnSvc := sfn.New(session.New(&aws.Config{Region: aws.String(defaultRegion)}))
inputStruct := Event{
Payload: fmt.Sprintf("Start at: %v", time.Now()),
Status: 123,
}
input, _ := json.Marshal(inputStruct)
result, err := sfnSvc.StartExecution(&sfn.StartExecutionInput{
Input: aws.String(string(input)),
StateMachineArn: aws.String(stateMachineArn),
Name: aws.String(fmt.Sprintf("%s-vuduongtp", uuid.New().String())),
TraceHeader: aws.String(fmt.Sprintf("StartExecution:%s", stateMachineArn)),
})
prettyPrint(result)
prettyPrint(err)
}
func prettyPrint(i interface{}) {
fmt.Printf("Type: %s\n", reflect.TypeOf(i))
s, _ := json.MarshalIndent(i, "", "\t")
fmt.Println(string(s))
fmt.Println("==============")
}