mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Remove non-alphanumeric characters in resource logical ids
This commit is contained in:
parent
d8859bf157
commit
aaa1ef6fdc
@ -82,9 +82,10 @@ class AwsCompileStreamEvents {
|
||||
const streamType = EventSourceArn.split(':')[2];
|
||||
const normalizedStreamType = streamType[0].toUpperCase() + streamType.substr(1);
|
||||
|
||||
// get the name of the stream
|
||||
// get the name of the stream (and remove any non-alphanumerics in it)
|
||||
const streamName = EventSourceArn.split('/')[1];
|
||||
const normalizedStreamName = streamName[0].toUpperCase() + streamName.substr(1);
|
||||
const normalizedStreamName = streamName[0].toUpperCase()
|
||||
+ streamName.substr(1).replace(/\W/g, '');
|
||||
|
||||
// create type specific PolicyDocument statements
|
||||
let streamStatement = {};
|
||||
|
||||
@ -403,5 +403,23 @@ describe('AwsCompileStreamEvents', () => {
|
||||
.PolicyDocument.Statement.length
|
||||
).to.equal(0);
|
||||
});
|
||||
|
||||
it('should remove all non-alphanumerics from stream names for the resource logical ids', () => {
|
||||
awsCompileStreamEvents.serverless.service.functions = {
|
||||
first: {
|
||||
events: [
|
||||
{
|
||||
stream: 'arn:aws:kinesis:region:account:stream/some-long-name',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
awsCompileStreamEvents.compileStreamEvents();
|
||||
|
||||
expect(awsCompileStreamEvents.serverless.service
|
||||
.provider.compiledCloudFormationTemplate.Resources
|
||||
).to.have.any.keys('FirstEventSourceMappingKinesisSomelongname');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user