Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A -- Copy this lambda policy
- {
- "Version": "2012-10-17",
- "Statement": [
- {
- "Action": [
- "logs:CreateLogGroup",
- "logs:CreateLogStream",
- "logs:PutLogEvents"
- ],
- "Resource": "arn:aws:logs:*:*:*",
- "Effect": "Allow"
- },
- {
- "Action": [
- "dynamodb:PutItem",
- "dynamodb:UpdateItem",
- "dynamodb:DeleteItem"
- ],
- "Resource": "arn:aws:dynamodb:*:*:*",
- "Effect": "Allow"
- }
- ]
- }
- B __ FIRST LAMBDA CODE
- console.log('Loading Lambda function');
- exports.handler = async (event, context, callback) => {
- let resultNum = Math.ceil(999.99);
- callback(null, 'this is the original function (Math.ceil) = ' + resultNum);
- };
- C __ SECOND LAMBDA CODE
- console.log('Loading Lambda function');
- exports.handler = async (event, context, callback) => {
- let resultNum = Math.floor(999.99);
- callback(null, 'this is the canary function (Math.floor) = ' + resultNum);
- };
- ------------------
- import json
- print('Loading your function')
- def lambda_handler(event, context):
- #print("Received event: " + json.dumps(event, indent=2))
- # print statements actually get printed to the logs.
- print("message --> " + event['message'])
- # Actually returning the value of the 'message' key.
- return event['message']
- # Raising an exception if something goes wrong...
- raise Exception('Something went wrong!')
- --------------------
- import json
- print("STARTING NEW INVOCATION!!!")
- def lambda_handler(event, context):
- # Setting variables to equal values from the event object passed in.
- bucket = event['Records'][0]['s3']['bucket']['name']
- region = event['Records'][0]['awsRegion']
- object = event['Records'][0]['s3']['object']['key']
- user = event['Records'][0]['userIdentity']['principalId']
- print("Bucket: " + bucket)
- print("Region: " + region)
- print("User is " + user)
- return(object)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement