Skip to content

Instantly share code, notes, and snippets.

@Sonsuz
Created November 14, 2022 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sonsuz/634ba6b1892e00f60f6c20377ac26881 to your computer and use it in GitHub Desktop.
Save Sonsuz/634ba6b1892e00f60f6c20377ac26881 to your computer and use it in GitHub Desktop.
lambda function for web app
import json
import boto3
from time import gmtime, strftime
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('WebApp-Table')
now = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
def lambda_handler(event, context):
name = event['firstname'] +' '+ event['lastname']
response = table.put_item(
Item={
'ID': name,
'LatestGreetingTime':now
})
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda, ' + name)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment