Skip to content

Commit

Permalink
Add MemorySize setting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinverdonk committed Dec 21, 2019
1 parent 7af1204 commit 493d7cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
29 changes: 17 additions & 12 deletions dist/lib/generate-cloudformation-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,54 @@ 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',
'logs:CreateLogStream',
'logs:PutLogEvents'
],
resource: ['*']
}]).map((_) => Object.keys(_)
.reduce((acc, key) => {
}
])
.map((_) => Object.keys(_).reduce((acc, key) => {
acc[key.replace(/^\w/, _ => _.toUpperCase())] = _[key];
return acc;
}, {}))));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/generate-cloudformation-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 493d7cb

Please sign in to comment.