Minor fixes / enhancements

This commit is contained in:
Philipp Muens 2019-04-30 13:41:45 +02:00
parent 4c0268eb7e
commit dce099c0bc
3 changed files with 11 additions and 7 deletions

View File

@ -54,7 +54,7 @@ functions:
- kinesis
- Ref: AWS::Region
- Ref: AWS::AccountId
- MyOtherKinesisStream
- stream/MyOtherKinesisStream
```
## Setting the BatchSize and StartingPosition

View File

@ -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];
}());

View File

@ -443,7 +443,7 @@ describe('AwsCompileStreamEvents', () => {
}, {
Ref: 'AWS::AccountId',
},
'MyStream',
'stream/MyStream',
],
],
},
@ -510,7 +510,7 @@ describe('AwsCompileStreamEvents', () => {
}, {
Ref: 'AWS::AccountId',
},
'MyStream',
'stream/MyStream',
],
],
}