@@ -9,67 +9,67 @@ Serverless Framework v2.32.0 or later is required.
9
9
10
10
## TOC
11
11
12
- - [ Install] ( #install )
13
- - [ Setup] ( #Setup )
14
- - [ Adding a custom name for a state machine] ( #adding-a-custom-name-for-a-statemachine )
15
- - [ Adding a custom logical id for a stateMachine] ( #adding-a-custom-logical-id-for-a-statemachine )
16
- - [ Depending on another logical id] ( #depending-on-another-logical-id )
17
- - [ Adding retain property for a state machine] ( #adding-retain-property-for-a-statemachine )
18
- - [ CloudWatch Alarms] ( #cloudwatch-alarms )
19
- - [ CloudWatch Notifications] ( #cloudwatch-notifications )
20
- - [ Blue-Green deployments] ( #blue-green-deployment )
21
- - [ Pre-deployment validation] ( #pre-deployment-validation )
22
- - [ Express Workflow] ( #express-workflow )
23
- - [ CloudWatch Logs] ( #cloudwatch-logs )
24
- - [ X-Ray] ( #x-ray )
25
- - [ Current Gotcha] ( #current-gotcha )
26
- - [ Events] ( #events )
27
- - [ API Gateway] ( #api-gateway )
28
- - [ Simple HTTP endpoint] ( #simple-http-endpoint )
29
- - [ Custom Step Functions Action] ( #custom-step-functions-action )
30
- - [ HTTP Endpoint with custom IAM Role] ( #http-endpoint-with-custom-iam-role )
31
- - [ Share API Gateway and API Resources] ( #share-api-gateway-and-api-resources )
32
- - [ Enabling CORS] ( #enabling-cors )
33
- - [ HTTP Endpoints with AWS_IAM Authorizers] ( #http-endpoints-with-aws_iam-authorizers )
34
- - [ HTTP Endpoints with Custom Authorizers] ( #http-endpoints-with-custom-authorizers )
35
- - [ Shared Authorizer] ( #shared-authorizer )
36
- - [ LAMBDA_PROXY request template] ( #lambda_proxy-request-template )
37
- - [ Customizing request body mapping templates] ( #customizing-request-body-mapping-templates )
38
- - [ Customizing response headers and templates] ( #customizing-response-headers-and-templates )
39
- - [ Send request to an API] ( #send-request-to-an-api )
40
- - [ Setting API keys for your Rest API] ( #setting-api-keys-for-your-rest-api )
41
- - [ Request Schema Validators] ( #request-schema-validators )
42
- - [ Schedule] ( #schedule )
43
- - [ Enabling / Disabling] ( #enabling--disabling )
44
- - [ Specify Name and Description] ( #specify-name-and-description )
45
- - [ Scheduled Events IAM Role] ( #scheduled-events-iam-role )
46
- - [ Specify InputTransformer] ( #specify-inputtransformer )
47
- - [ Use EventBridge Scheduler instead of EventBridge rules] ( #use-eventbridge-scheduler-instead-of-eventbridge-rules )
48
- - [ CloudWatch Event] ( #cloudwatch-event )
49
- - [ Simple event definition] ( #simple-event-definition )
50
- - [ Enabling / Disabling] ( #enabling--disabling-1 )
51
- - [ Specify Input or Inputpath or InputTransformer] ( #specify-input-or-inputpath-or-inputtransformer )
52
- - [ Specifying a Description] ( #specifying-a-description )
53
- - [ Specifying a Name] ( #specifying-a-name )
54
- - [ Specifying a RoleArn] ( #specifying-a-rolearn )
55
- - [ Specifying a custom CloudWatch EventBus] ( #specifying-a-custom-cloudwatch-eventbus )
56
- - [ Specifying a custom EventBridge EventBus] ( #specifying-a-custom-eventbridge-eventbus )
57
- - [ Specifying a DeadLetterQueue] ( #specifying-a-deadletterqueue )
58
- - [ Tags] ( #tags )
59
- - [ Commands] ( #commands )
60
- - [ deploy] ( #deploy )
61
- - [ invoke] ( #invoke )
62
- - [ IAM Role] ( #iam-role )
63
- - [ Tips] ( #tips )
64
- - [ How to specify the stateMachine ARN to environment variables] ( #how-to-specify-the-statemachine-arn-to-environment-variables )
65
- - [ How to split up state machines into files] ( #how-to-split-up-state-machines-into-files )
66
- - [ Sample statemachines setting in serverless.yml] ( #sample-statemachines-setting-in-serverlessyml )
67
- - [ Wait State] ( #wait-state )
68
- - [ Retry Failure] ( #retry-failure )
69
- - [ Parallel] ( #parallel )
70
- - [ Catch Failure] ( #catch-failure )
71
- - [ Choice] ( #choice )
72
- - [ Map] ( #map )
12
+ - [ Install] ( #install )
13
+ - [ Setup] ( #Setup )
14
+ - [ Adding a custom name for a state machine] ( #adding-a-custom-name-for-a-statemachine )
15
+ - [ Adding a custom logical id for a stateMachine] ( #adding-a-custom-logical-id-for-a-statemachine )
16
+ - [ Depending on another logical id] ( #depending-on-another-logical-id )
17
+ - [ Adding retain property for a state machine] ( #adding-retain-property-for-a-statemachine )
18
+ - [ CloudWatch Alarms] ( #cloudwatch-alarms )
19
+ - [ CloudWatch Notifications] ( #cloudwatch-notifications )
20
+ - [ Blue-Green deployments] ( #blue-green-deployment )
21
+ - [ Pre-deployment validation] ( #pre-deployment-validation )
22
+ - [ Express Workflow] ( #express-workflow )
23
+ - [ CloudWatch Logs] ( #cloudwatch-logs )
24
+ - [ X-Ray] ( #x-ray )
25
+ - [ Current Gotcha] ( #current-gotcha )
26
+ - [ Events] ( #events )
27
+ - [ API Gateway] ( #api-gateway )
28
+ - [ Simple HTTP endpoint] ( #simple-http-endpoint )
29
+ - [ Custom Step Functions Action] ( #custom-step-functions-action )
30
+ - [ HTTP Endpoint with custom IAM Role] ( #http-endpoint-with-custom-iam-role )
31
+ - [ Share API Gateway and API Resources] ( #share-api-gateway-and-api-resources )
32
+ - [ Enabling CORS] ( #enabling-cors )
33
+ - [ HTTP Endpoints with AWS_IAM Authorizers] ( #http-endpoints-with-aws_iam-authorizers )
34
+ - [ HTTP Endpoints with Custom Authorizers] ( #http-endpoints-with-custom-authorizers )
35
+ - [ Shared Authorizer] ( #shared-authorizer )
36
+ - [ LAMBDA_PROXY request template] ( #lambda_proxy-request-template )
37
+ - [ Customizing request body mapping templates] ( #customizing-request-body-mapping-templates )
38
+ - [ Customizing response headers and templates] ( #customizing-response-headers-and-templates )
39
+ - [ Send request to an API] ( #send-request-to-an-api )
40
+ - [ Setting API keys for your Rest API] ( #setting-api-keys-for-your-rest-api )
41
+ - [ Request Schema Validators] ( #request-schema-validators )
42
+ - [ Schedule] ( #schedule )
43
+ - [ Enabling / Disabling] ( #enabling--disabling )
44
+ - [ Specify Name and Description] ( #specify-name-and-description )
45
+ - [ Scheduled Events IAM Role] ( #scheduled-events-iam-role )
46
+ - [ Specify InputTransformer] ( #specify-inputtransformer )
47
+ - [ Use EventBridge Scheduler instead of EventBridge rules] ( #use-eventbridge-scheduler-instead-of-eventbridge-rules )
48
+ - [ CloudWatch Event] ( #cloudwatch-event )
49
+ - [ Simple event definition] ( #simple-event-definition )
50
+ - [ Enabling / Disabling] ( #enabling--disabling-1 )
51
+ - [ Specify Input or Inputpath or InputTransformer] ( #specify-input-or-inputpath-or-inputtransformer )
52
+ - [ Specifying a Description] ( #specifying-a-description )
53
+ - [ Specifying a Name] ( #specifying-a-name )
54
+ - [ Specifying a RoleArn] ( #specifying-a-rolearn )
55
+ - [ Specifying a custom CloudWatch EventBus] ( #specifying-a-custom-cloudwatch-eventbus )
56
+ - [ Specifying a custom EventBridge EventBus] ( #specifying-a-custom-eventbridge-eventbus )
57
+ - [ Specifying a DeadLetterQueue] ( #specifying-a-deadletterqueue )
58
+ - [ Tags] ( #tags )
59
+ - [ Commands] ( #commands )
60
+ - [ deploy] ( #deploy )
61
+ - [ invoke] ( #invoke )
62
+ - [ IAM Role] ( #iam-role )
63
+ - [ Tips] ( #tips )
64
+ - [ How to specify the stateMachine ARN to environment variables] ( #how-to-specify-the-statemachine-arn-to-environment-variables )
65
+ - [ How to split up state machines into files] ( #how-to-split-up-state-machines-into-files )
66
+ - [ Sample statemachines setting in serverless.yml] ( #sample-statemachines-setting-in-serverlessyml )
67
+ - [ Wait State] ( #wait-state )
68
+ - [ Retry Failure] ( #retry-failure )
69
+ - [ Parallel] ( #parallel )
70
+ - [ Catch Failure] ( #catch-failure )
71
+ - [ Choice] ( #choice )
72
+ - [ Map] ( #map )
73
73
74
74
## Install
75
75
@@ -425,8 +425,8 @@ stepFunctions:
425
425
- lambda: LAMBDA_FUNCTION_ARN
426
426
- kinesis: KINESIS_STREAM_ARN
427
427
- kinesis:
428
- arn: KINESIS_STREAM_ARN
429
- partitionKeyPath: $.id # used to choose the parition key from payload
428
+ arn: KINESIS_STREAM_ARN
429
+ partitionKeyPath: $.id # used to choose the parition key from payload
430
430
- firehose: FIREHOSE_STREAM_ARN
431
431
- stepFunctions: STATE_MACHINE_ARN
432
432
FAILED:
@@ -790,7 +790,7 @@ stepFunctions:
790
790
createUser:
791
791
...
792
792
events:
793
- - http:
793
+ - http:
794
794
path: /users
795
795
...
796
796
authorizer:
@@ -873,6 +873,43 @@ stepFunctions:
873
873
definition:
874
874
` ` `
875
875
876
+ If you want to add multiple custom templates for different status codes, headers and content types, you can do so by including them in the `responses` object like so :
877
+
878
+ ` ` ` yml
879
+
880
+ stepFunctions:
881
+ stateMachines:
882
+ hello:
883
+ events:
884
+ - http:
885
+ path: posts/create
886
+ method: POST
887
+ responses:
888
+ 200:
889
+ statusCode: 200
890
+ responseParameters:
891
+ method.response.header.Content-Type: "'application/json'"
892
+ method.response.header.X-Application-Id: "'my-app'"
893
+ responseTemplates:
894
+ application/json: |
895
+ {
896
+ "status": 200,
897
+ "info": "OK"
898
+ }
899
+ 400:
900
+ statusCode: 400
901
+ responseParameters:
902
+ method.response.header.Content-Type: "'application/json'"
903
+ method.response.header.X-Application-Id: "'my-app'"
904
+ responseTemplates:
905
+ application/json: |
906
+ {
907
+ "status": 400,
908
+ "info": "Bad Request"
909
+ }
910
+ definition:
911
+ ` ` `
912
+
876
913
# ### Send request to an API
877
914
878
915
You can input an value as json in request body, the value is passed as the input value of your statemachine
@@ -982,7 +1019,7 @@ provider:
982
1019
name: PostCreateModel
983
1020
schema: ${file(api_schema/post_add_schema.json)}
984
1021
description: "A Model validation for adding posts"
985
-
1022
+
986
1023
stepFunctions:
987
1024
stateMachines:
988
1025
create:
@@ -1089,10 +1126,10 @@ stepFunctions:
1089
1126
stateMachines:
1090
1127
stateMachineScheduled:
1091
1128
events:
1092
- - schedule:
1129
+ - schedule:
1093
1130
rate: cron(30 12 ? * 1-5 *)
1094
1131
inputTransformer:
1095
- inputPathsMap:
1132
+ inputPathsMap:
1096
1133
time: '$.time'
1097
1134
stage: '$.stageVariables'
1098
1135
inputTemplate: '{"time": <time>, "stage" : <stage> }'
@@ -1424,8 +1461,8 @@ Then
1424
1461
# to get the Arn of the 1st EventBridge rule
1425
1462
!GetAtt Hellostepfunc1EventsRuleCloudWatchEvent1.Arn
1426
1463
1427
- # to get the Arn of the 2nd EventBridge rule
1428
- !GetAtt Hellostepfunc1EventsRuleCloudWatchEvent2.Arn
1464
+ # to get the Arn of the 2nd EventBridge rule
1465
+ !GetAtt Hellostepfunc1EventsRuleCloudWatchEvent2.Arn
1429
1466
```
1430
1467
1431
1468
## Tags
@@ -1505,12 +1542,12 @@ resources:
1505
1542
Path: /path_of_state_machine_roles/
1506
1543
AssumeRolePolicyDocument:
1507
1544
Statement:
1508
- - Effect: Allow
1509
- Principal:
1510
- Service:
1511
- - states.amazonaws.com
1512
- Action:
1513
- - sts:AssumeRole
1545
+ - Effect: Allow
1546
+ Principal:
1547
+ Service:
1548
+ - states.amazonaws.com
1549
+ Action:
1550
+ - sts:AssumeRole
1514
1551
Policies:
1515
1552
- PolicyName: statePolicy
1516
1553
PolicyDocument:
@@ -1740,21 +1777,21 @@ stepFunctions:
1740
1777
Type: Parallel
1741
1778
Next: Final State
1742
1779
Branches:
1743
- - StartAt: Wait 20s
1744
- States:
1745
- Wait 20s:
1746
- Type: Wait
1747
- Seconds: 20
1748
- End: true
1749
- - StartAt: Pass
1750
- States:
1751
- Pass:
1752
- Type: Pass
1753
- Next: Wait 10s
1754
- Wait 10s:
1755
- Type: Wait
1756
- Seconds: 10
1757
- End: true
1780
+ - StartAt: Wait 20s
1781
+ States:
1782
+ Wait 20s:
1783
+ Type: Wait
1784
+ Seconds: 20
1785
+ End: true
1786
+ - StartAt: Pass
1787
+ States:
1788
+ Pass:
1789
+ Type: Pass
1790
+ Next: Wait 10s
1791
+ Wait 10s:
1792
+ Type: Wait
1793
+ Seconds: 10
1794
+ End: true
1758
1795
Final State:
1759
1796
Type: Pass
1760
1797
End: true
@@ -1782,12 +1819,12 @@ stepFunctions:
1782
1819
Resource:
1783
1820
Fn::GetAtt: [hello, Arn]
1784
1821
Catch:
1785
- - ErrorEquals: ["HandledError"]
1786
- Next: CustomErrorFallback
1787
- - ErrorEquals: ["States.TaskFailed"]
1788
- Next: ReservedTypeFallback
1789
- - ErrorEquals: ["States.ALL"]
1790
- Next: CatchAllFallback
1822
+ - ErrorEquals: ["HandledError"]
1823
+ Next: CustomErrorFallback
1824
+ - ErrorEquals: ["States.TaskFailed"]
1825
+ Next: ReservedTypeFallback
1826
+ - ErrorEquals: ["States.ALL"]
1827
+ Next: CatchAllFallback
1791
1828
End: true
1792
1829
CustomErrorFallback:
1793
1830
Type: Pass
@@ -1834,12 +1871,12 @@ stepFunctions:
1834
1871
ChoiceState:
1835
1872
Type: Choice
1836
1873
Choices:
1837
- - Variable: "$.foo"
1838
- NumericEquals: 1
1839
- Next: FirstMatchState
1840
- - Variable: "$.foo"
1841
- NumericEquals: 2
1842
- Next: SecondMatchState
1874
+ - Variable: "$.foo"
1875
+ NumericEquals: 1
1876
+ Next: FirstMatchState
1877
+ - Variable: "$.foo"
1878
+ NumericEquals: 2
1879
+ Next: SecondMatchState
1843
1880
Default: DefaultState
1844
1881
FirstMatchState:
1845
1882
Type: Task
0 commit comments