-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
33 lines (28 loc) · 839 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
const policyStatements = [{
Effect: 'Allow',
Action: ['logs:CreateLogStream', 'logs:CreateLogGroup', 'logs:PutLogEvents'],
Resource: [
{
'Fn::Sub': 'arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:*'
}
]
}];
class SimplifyDefaultExecRole {
constructor(serverless) {
this.hooks = {
'before:package:finalize': function() {
simplifyBaseIAMLogGroups(serverless);
}
};
}
}
function simplifyBaseIAMLogGroups(serverless) {
const resourceSection = serverless.service.provider.compiledCloudFormationTemplate.Resources;
for (const key in resourceSection) {
if (key === 'IamRoleLambdaExecution') {
resourceSection[key].Properties.Policies[0].PolicyDocument.Statement = policyStatements;
}
}
}
module.exports = SimplifyDefaultExecRole;