diff --git a/lib/plugins/aws/deploy/compile/functions/tests/index.js b/lib/plugins/aws/deploy/compile/functions/tests/index.js index 4162e5145..c85f1decd 100644 --- a/lib/plugins/aws/deploy/compile/functions/tests/index.js +++ b/lib/plugins/aws/deploy/compile/functions/tests/index.js @@ -129,6 +129,7 @@ describe('AwsCompileFunctions', () => { }); it('should update IamPolicyLambdaExecution with a logging resource for the function', () => { + const normalizedName = `${functionName[0].toUpperCase()}${functionName.substr(1)}LogGroup`; awsCompileFunctions.compileFunctions(); expect(awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate @@ -140,17 +141,7 @@ describe('AwsCompileFunctions', () => { .Resource ).to.deep.equal( [ - { - 'Fn:Join': [ - ':', - [ - 'arn:aws:logs', - { Ref: 'AWS::Region' }, - { Ref: 'AWS::AccountId' }, - `log-group:/aws/lambda/${functionName}*:*:*`, - ], - ], - }, + { 'Fn:Join': [':', [{ 'Fn::GetAtt': [normalizedName, 'Arn'] }, '*', '*']] }, ] ); }); @@ -167,6 +158,11 @@ describe('AwsCompileFunctions', () => { name: 'func1', }, }; + const f = service.functions; + const normalizedNames = [ + `${f.func0.name[0].toUpperCase()}${f.func0.name.substr(1)}LogGroup`, + `${f.func1.name[0].toUpperCase()}${f.func1.name.substr(1)}LogGroup`, + ]; awsCompileFunctions.compileFunctions(); expect(awsCompileFunctions.serverless.service.provider.compiledCloudFormationTemplate @@ -178,28 +174,8 @@ describe('AwsCompileFunctions', () => { .Resource ).to.deep.equal( [ - { - 'Fn:Join': [ - ':', - [ - 'arn:aws:logs', - { Ref: 'AWS::Region' }, - { Ref: 'AWS::AccountId' }, - `log-group:/aws/lambda/${service.functions.func0.name}*:*:*`, - ], - ], - }, - { - 'Fn:Join': [ - ':', - [ - 'arn:aws:logs', - { Ref: 'AWS::Region' }, - { Ref: 'AWS::AccountId' }, - `log-group:/aws/lambda/${service.functions.func1.name}*:*:*`, - ], - ], - }, + { 'Fn:Join': [':', [{ 'Fn::GetAtt': [normalizedNames[0], 'Arn'] }, '*', '*']] }, + { 'Fn:Join': [':', [{ 'Fn::GetAtt': [normalizedNames[1], 'Arn'] }, '*', '*']] }, ] ); });