Skip to content

Commit 69dea38

Browse files
authored
Merge branch 'master' into inputTransformer
2 parents 4b68246 + a4531c1 commit 69dea38

35 files changed

+336
-332
lines changed

.github/workflows/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI
22

3-
on: push
3+
on: [push, pull_request]
44

55
jobs:
66
test:

CHANGELOG.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
This is the Serverless Framework plugin for AWS Step Functions.
66

7+
## Requirement
8+
Serverless Framework v2.32.0 or later is required.
9+
710
## TOC
811

912
- [Install](#install)
@@ -48,6 +51,7 @@ This is the Serverless Framework plugin for AWS Step Functions.
4851
- [Specifying a RoleArn](#specifying-a-rolearn)
4952
- [Specifying a custom CloudWatch EventBus](#specifying-a-custom-cloudwatch-eventbus)
5053
- [Specifying a custom EventBridge EventBus](#specifying-a-custom-eventbridge-eventbus)
54+
- [Specifying a DeadLetterQueue](#specifying-a-deadletterqueue)
5155
- [Tags](#tags)
5256
- [Commands](#commands)
5357
- [deploy](#deploy)
@@ -164,7 +168,7 @@ stepFunctions:
164168
dependsOn:
165169
- DynamoDBTable
166170
- KinesisStream
167-
- CUstomIamRole
171+
- CustomIamRole
168172
tags:
169173
Team: Atlantis
170174
activities:
@@ -1166,6 +1170,73 @@ stepFunctions:
11661170
...
11671171
```
11681172

1173+
#### Specifying a DeadLetterQueue
1174+
1175+
You can configure a target queue to send dead-letter queue events to:
1176+
1177+
```yml
1178+
stepFunctions:
1179+
stateMachines:
1180+
exampleEventBridgeEventStartsMachine:
1181+
events:
1182+
- eventBridge:
1183+
eventBusName: 'my-custom-event-bus'
1184+
event:
1185+
source:
1186+
- "my.custom.source"
1187+
detail-type:
1188+
- "My Event Type"
1189+
detail:
1190+
state:
1191+
- pending
1192+
deadLetterConfig: 'arn:aws:sqs:us-east-1:012345678910:my-dlq' # SQS Arn
1193+
definition:
1194+
...
1195+
```
1196+
##### Important point
1197+
Don't forget to [Grant permissions to the dead-letter queue](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-rule-dlq.html#eb-dlq-perms), to do that you may need to have the `ARN` of the generated `EventBridge Rule`.
1198+
1199+
In order to get the `ARN` you can use [intrinsic functions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html) against the `logicalId`, this plugin generates `logicalIds` following this format:
1200+
```ts
1201+
`${StateMachineName}EventsRuleCloudWatchEvent${index}`
1202+
```
1203+
Given this example 👇
1204+
```yml
1205+
stepFunctions:
1206+
stateMachines:
1207+
hellostepfunc1: # <---- StateMachineName
1208+
events:
1209+
- eventBridge:
1210+
eventBusName: 'my-custom-event-bus'
1211+
event:
1212+
source:
1213+
- "my.custom.source"
1214+
- eventBridge:
1215+
eventBusName: 'my-custom-event-bus'
1216+
event:
1217+
source:
1218+
- "my.custom.source"
1219+
deadLetterConfig: 'arn:aws:sqs:us-east-1:012345678910:my-dlq'
1220+
name: myStateMachine
1221+
definition:
1222+
Comment: "A Hello World example of the Amazon States Language using an AWS Lambda Function"
1223+
StartAt: HelloWorld1
1224+
States:
1225+
HelloWorld1:
1226+
Type: Task
1227+
Resource:
1228+
Fn::GetAtt: [hello, Arn]
1229+
End: true
1230+
```
1231+
Then
1232+
```yaml
1233+
# to get the Arn of the 1st EventBridge rule
1234+
!GetAtt Hellostepfunc1EventsRuleCloudWatchEvent1.Arn
1235+
1236+
# to get the Arn of the 2nd EventBridge rule
1237+
!GetAtt Hellostepfunc1EventsRuleCloudWatchEvent2.Arn
1238+
```
1239+
11691240
## Tags
11701241

11711242
You can specify tags on each state machine. Additionally any global tags (specified under `provider` section in your `serverless.yml`) would be merged in as well.

lib/deploy/events/apiGateway/apiKeys.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ const BbPromise = require('bluebird');
55

66
module.exports = {
77
compileApiKeys() {
8-
if (this.serverless.service.provider.apiKeys) {
9-
if (!Array.isArray(this.serverless.service.provider.apiKeys)) {
8+
const apiKeys = _.get(this.serverless.service.provider.apiGateway, 'apiKeys')
9+
|| this.serverless.service.provider.apiKeys;
10+
if (apiKeys) {
11+
if (!Array.isArray(apiKeys)) {
1012
throw new this.serverless.classes.Error('apiKeys property must be an array');
1113
}
1214

13-
_.forEach(this.serverless.service.provider.apiKeys, (apiKey, i) => {
15+
_.forEach(apiKeys, (apiKey, i) => {
1416
const apiKeyNumber = i + 1;
1517

1618
if (typeof apiKey !== 'string') {

lib/deploy/events/apiGateway/apiKeys.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const expect = require('chai').expect;
44
const Serverless = require('serverless/lib/Serverless');
5-
const AwsProvider = require('serverless/lib/plugins/aws/provider/awsProvider');
5+
const AwsProvider = require('serverless/lib/plugins/aws/provider');
66
const ServerlessStepFunctions = require('./../../../index');
77

88
describe('#methods()', () => {
@@ -16,7 +16,8 @@ describe('#methods()', () => {
1616
region: 'us-east-1',
1717
};
1818
serverless.setProvider('aws', new AwsProvider(serverless));
19-
serverless.service.provider.apiKeys = ['1234567890'];
19+
if (!serverless.service.provider.apiGateway) serverless.service.provider.apiGateway = {};
20+
serverless.service.provider.apiGateway.apiKeys = ['1234567890'];
2021
serverless.service.provider.compiledCloudFormationTemplate = {
2122
Resources: {},
2223
};
@@ -79,12 +80,12 @@ describe('#methods()', () => {
7980
}));
8081

8182
it('throw error if apiKey property is not an array', () => {
82-
serverlessStepFunctions.serverless.service.provider.apiKeys = 2;
83+
serverlessStepFunctions.serverless.service.provider.apiGateway.apiKeys = 2;
8384
expect(() => serverlessStepFunctions.compileApiKeys()).to.throw(Error);
8485
});
8586

8687
it('throw error if an apiKey is not a string', () => {
87-
serverlessStepFunctions.serverless.service.provider.apiKeys = [2];
88+
serverlessStepFunctions.serverless.service.provider.apiGateway.apiKeys = [2];
8889
expect(() => serverlessStepFunctions.compileApiKeys()).to.throw(Error);
8990
});
9091
});

lib/deploy/events/apiGateway/authorizers.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const expect = require('chai').expect;
44
const Serverless = require('serverless/lib/Serverless');
5-
const AwsProvider = require('serverless/lib/plugins/aws/provider/awsProvider');
5+
const AwsProvider = require('serverless/lib/plugins/aws/provider');
66
const ServerlessStepFunctions = require('./../../../index');
77

88
describe('#compileAuthorizers()', () => {

lib/deploy/events/apiGateway/cors.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const expect = require('chai').expect;
44
const Serverless = require('serverless/lib/Serverless');
5-
const AwsProvider = require('serverless/lib/plugins/aws/provider/awsProvider');
5+
const AwsProvider = require('serverless/lib/plugins/aws/provider');
66
const ServerlessStepFunctions = require('./../../../index');
77

88
describe('#compileCors()', () => {

lib/deploy/events/apiGateway/deployment.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const expect = require('chai').expect;
44
const Serverless = require('serverless/lib/Serverless');
5-
const AwsProvider = require('serverless/lib/plugins/aws/provider/awsProvider');
5+
const AwsProvider = require('serverless/lib/plugins/aws/provider');
66
const ServerlessStepFunctions = require('./../../../index');
77

88
describe('#compileDeployment()', () => {

lib/deploy/events/apiGateway/endpointInfo.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const expect = require('chai').expect;
44
const sinon = require('sinon');
55
const BbPromise = require('bluebird');
66
const Serverless = require('serverless/lib/Serverless');
7-
const AwsProvider = require('serverless/lib/plugins/aws/provider/awsProvider');
7+
const AwsProvider = require('serverless/lib/plugins/aws/provider');
88
const ServerlessStepFunctions = require('./../../../index');
99

1010

lib/deploy/events/apiGateway/iamRole.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const expect = require('chai').expect;
44
const Serverless = require('serverless/lib/Serverless');
5-
const AwsProvider = require('serverless/lib/plugins/aws/provider/awsProvider');
5+
const AwsProvider = require('serverless/lib/plugins/aws/provider');
66
const ServerlessStepFunctions = require('./../../../index');
77

88
describe('#compileHttpIamRole()', () => {

0 commit comments

Comments
 (0)