diff --git a/docs/providers/aws/events/streams.md b/docs/providers/aws/events/streams.md index d4bee8e4c..2fc9e0b4c 100644 --- a/docs/providers/aws/events/streams.md +++ b/docs/providers/aws/events/streams.md @@ -54,7 +54,7 @@ functions: - kinesis - Ref: AWS::Region - Ref: AWS::AccountId - - MyOtherKinesisStream + - stream/MyOtherKinesisStream ``` ## Setting the BatchSize and StartingPosition diff --git a/lib/plugins/aws/package/compile/events/stream/index.js b/lib/plugins/aws/package/compile/events/stream/index.js index 9fe115404..bf550a7ed 100644 --- a/lib/plugins/aws/package/compile/events/stream/index.js +++ b/lib/plugins/aws/package/compile/events/stream/index.js @@ -75,9 +75,9 @@ class AwsCompileStreamEvents { || _.has(event.stream.arn, 'Fn::Join'))) { const errorMessage = [ `Bad dynamic ARN property on stream event in function "${functionName}"`, - ' If you use a dynamic "arn" (such as with Fn::GetAtt or Fn::ImportValue)', - ' there must only be one key (either Fn::GetAtt or Fn::ImportValue) in the arn', - ' object. Please check the docs for more info.', + ' If you use a dynamic "arn" (such as with Fn::GetAtt, Fn::Join', + ' or Fn::ImportValue) there must only be one key (either Fn::GetAtt, Fn::Join', + ' or Fn::ImportValue) in the arn object. Please check the docs for more info.', ].join(''); throw new this.serverless.classes .Error(errorMessage); @@ -112,7 +112,11 @@ class AwsCompileStreamEvents { return EventSourceArn['Fn::ImportValue']; } else if (EventSourceArn['Fn::Join']) { // [0] is the used delimiter, [1] is the array with values - return EventSourceArn['Fn::Join'][1].slice(-1).pop(); + const name = EventSourceArn['Fn::Join'][1].slice(-1).pop(); + if (name.split('/').length) { + return name.split('/').pop(); + } + return name; } return EventSourceArn.split('/')[1]; }()); diff --git a/lib/plugins/aws/package/compile/events/stream/index.test.js b/lib/plugins/aws/package/compile/events/stream/index.test.js index 9f0badceb..cd15293da 100644 --- a/lib/plugins/aws/package/compile/events/stream/index.test.js +++ b/lib/plugins/aws/package/compile/events/stream/index.test.js @@ -443,7 +443,7 @@ describe('AwsCompileStreamEvents', () => { }, { Ref: 'AWS::AccountId', }, - 'MyStream', + 'stream/MyStream', ], ], }, @@ -510,7 +510,7 @@ describe('AwsCompileStreamEvents', () => { }, { Ref: 'AWS::AccountId', }, - 'MyStream', + 'stream/MyStream', ], ], }