Skip to content

Instantly share code, notes, and snippets.

@maatthc
Created March 20, 2019 08:32
Show Gist options
  • Save maatthc/867c646314fa567cbc0cad9886783545 to your computer and use it in GitHub Desktop.
Save maatthc/867c646314fa567cbc0cad9886783545 to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: "2010-09-09"
Description: "An example lambda template to demonstrate persistent state between executions"
Resources:
LambdaExecutionRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: "sts:AssumeRole"
countExecutionLambda:
Type: "AWS::Lambda::Function"
Properties:
Handler: "index.handler"
Role: !GetAtt [ LambdaExecutionRole, Arn ]
Code:
ZipFile: |
let executionCounter = 0
exports.handler = function(event, context) {
executionCounter++
console.log(`Number of execution: ${executionCounter}`)
return 'okay'
}
Runtime: "nodejs8.10"
Timeout: "25"
MemorySize: 128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment