Skip to content

Commit f7667fd

Browse files
committed
feat: check that regions are macthing between AWS and activity ARN
BREAKING CHANGE: activityArn must be explictly defined
1 parent dd7f58d commit f7667fd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/worker.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const EventEmitter = require('events').EventEmitter;
22
const util = require('util');
33
const AWS = require('aws-sdk');
4+
var parser = require('aws-arn-parser');
45

56
const Pooler = require('./pooler.js');
67
const replaceError = require('./replace-error.js');
@@ -28,7 +29,14 @@ function Worker(options) {
2829
this.autoStart = typeof (options.autoStart) === 'boolean' ? options.autoStart : true;
2930

3031
if (!options.activityArn) {
31-
this.emit('error', new Error('activityArn is mandatory inside Worker'));
32+
throw(new Error('activityArn is mandatory inside Worker'));
33+
return;
34+
}
35+
36+
const {region} = parser(options.activityArn);
37+
38+
if(this.stepfunction.config.region !== region){
39+
throw(new Error(`activity ARN region (${region}) should match with AWS Region (${this.stepfunction.config.region})`));
3240
return;
3341
}
3442

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"xo": "^0.18.2"
3838
},
3939
"dependencies": {
40+
"aws-arn-parser": "^1.0.0",
4041
"aws-sdk": "^2.82.0"
4142
}
4243
}

0 commit comments

Comments
 (0)