diff --git a/dist/lib/generate-cloudformation-template.js b/dist/lib/generate-cloudformation-template.js index c4bb5c5..d496834 100644 --- a/dist/lib/generate-cloudformation-template.js +++ b/dist/lib/generate-cloudformation-template.js @@ -9,40 +9,44 @@ exports.generateCloudFormationTemplate = (options, lambdaExists) => { .replace(/@{FunctionName}/g, options.functionName) .replace(/@{HandlerName}/g, options.handlerName) .replace(/@{Runtime}/g, options.settings.runtime) + .replace(/@{MemorySize}/g, options.settings.memory.toString()) .replace(/@{ReservedConcurrentExecutions}/g, (!Number.isNaN(Number.parseInt(options.settings.reservedConcurrentExecutions)) ? options.settings.reservedConcurrentExecutions : '!Ref AWS::NoValue').toString()) .replace(/@{Timeout}/g, options.settings.timeout.toString()) .replace(/@{VpcConfig}/g, options.settings.vpcConfig - ? JSON.stringify(Object.keys(options.settings.vpcConfig) - .reduce((acc, key) => { - acc[key.replace(/^\w/, _ => _.toUpperCase())] = (options.settings.vpcConfig[key]); + ? JSON.stringify(Object.keys(options.settings.vpcConfig).reduce((acc, key) => { + acc[key.replace(/^\w/, _ => _.toUpperCase())] = options + .settings.vpcConfig[key]; return acc; }, {})) : '!Ref AWS::NoValue') .replace(/@{Environment}/g, JSON.stringify(options.settings.environment)) .replace(/@{Version}/g, options.version) .replace(/@{TracingMode}/g, options.settings.tracingConfig.mode) - .replace(/@{RoleStatement}/g, JSON.stringify([{ + .replace(/@{RoleStatement}/g, JSON.stringify([ + { Effect: 'Allow', Principal: { Service: options.settings.servicesAllowed }, Action: ['sts:AssumeRole'] - }])) + } + ])) .replace(/@{ManagedPolicies}/g, options.settings.managedPolicies ? `ManagedPolicyArns: ${JSON.stringify(options.settings.managedPolicies)}` : '') - .replace(/@{PolicyStatement}/g, JSON.stringify(options.settings.permissions.concat([{ + .replace(/@{PolicyStatement}/g, JSON.stringify(options.settings.permissions + .concat([ + { effect: 'Allow', - action: [ - 'lambda:InvokeFunction' - ], + action: ['lambda:InvokeFunction'], resource: [ `arn:aws:lambda:*:*:function:${options.functionName}`, `arn:aws:lambda:*:*:function:${options.functionName}:*` ] - }, { + }, + { effect: 'Allow', action: [ 'logs:CreateLogGroup', @@ -50,8 +54,9 @@ exports.generateCloudFormationTemplate = (options, lambdaExists) => { 'logs:PutLogEvents' ], resource: ['*'] - }]).map((_) => Object.keys(_) - .reduce((acc, key) => { + } + ]) + .map((_) => Object.keys(_).reduce((acc, key) => { acc[key.replace(/^\w/, _ => _.toUpperCase())] = _[key]; return acc; }, {})))); diff --git a/package.json b/package.json index 6ab9d58..4f0de41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@erwinverdonk/aws-lambda-upload-deploy", - "version": "1.1.10", + "version": "1.1.11", "description": "Easier way to upload and deploy Lambda functions in Node.js", "main": "./dist/index.js", "scripts": { diff --git a/src/lib/generate-cloudformation-template.ts b/src/lib/generate-cloudformation-template.ts index 9231463..bd8ddb9 100644 --- a/src/lib/generate-cloudformation-template.ts +++ b/src/lib/generate-cloudformation-template.ts @@ -18,7 +18,7 @@ export const generateCloudFormationTemplate = ( .replace(/@{FunctionName}/g, options.functionName) .replace(/@{HandlerName}/g, options.handlerName) .replace(/@{Runtime}/g, options.settings.runtime) - .replace(/@{MemorySize}/g, options.settings.memory) + .replace(/@{MemorySize}/g, options.settings.memory.toString()) .replace( /@{ReservedConcurrentExecutions}/g, (!Number.isNaN(