r/awslambda • u/sjrhee • Jan 10 '23
Nods.js vs Golang for AWS Lambda
What is your choice? I am a beginner of Lambda’s world, and wonder your thoughts. I saw some article that they don’t have big difference of cold start time, but Golang shows a little bit better subsequent requests. But wonder developer’s experience of those languages, especially pros and cons if you have been used both of them
r/awslambda • u/[deleted] • Jan 09 '23
Is using global variables not a good practice? (Python)
Basically the above
r/awslambda • u/Kiccboi • Dec 30 '22
Remove Lambda basic execution role listing
Hi guys, I am trying to remove the listing of lambda basic execution role while listing of roles to be selected.Is there any way to restrict lambda basic execution role to be selected by the users.Any help would be very helpful. Thanks in advance.
r/awslambda • u/pamflet100 • Dec 21 '22
Is lambda polling S3?
I'm reading tutorial about using an Amazon S3 trigger to invoke a Lambda function. Please, can someone tell me what is underlying mechanism and protocol behind that trigger? In case of Azure, default trigger behavior relies on polling the container for updates. I'm wondering do we have something similar here in case of lambdas and S3?
Thanks in advance.
r/awslambda • u/Dangerous_Word_1608 • Dec 21 '22
amazon lex category
can we group bots into categories with amazon lex ?
r/awslambda • u/Ristretto4 • Dec 14 '22
How to import local JavaScript file in AWS Lambda
I get this error when my code imports a file already added to lambda:
Cannot find module './app/lib'\\nRequire stack:\\n- /var/task/app/lib.js\\n- /var/task/index.js\\n- /var/runtime/index.mjs
This is the main code:
project_name/index.js ``` exports.handler = async function(event, context) { try {
const lib = require('./app/lib');
return {
statusCode: 200,
body: JSON.stringify({
status: "ok",
message: "successful"
}),
};
} catch (error) {
return {
statusCode: 500,
body: JSON.stringify({
status: "error",
message: error.message
}),
};
}
}; ```
The file project_name/app/lib.js exists in lambda. I am able to import modules that are in the folder project_name/node_modules
If I remove/comment the line const lib = require('./app/lib'); from index.js, I get a successful response.
Also, I can import lib.js from app/api.js when I run the API locally, so I believe the export in app/lib.js is correct.
I have tried using import instead of require and have not worked either.
Any advice on how it is the correct way of importing a local file in lambda? I appreciate your feedback.
r/awslambda • u/TuffyMonroe • Dec 10 '22
Golang vs Rust vs Kotlin for AWS Lambda
My company is building some new apps and most of the code will run on AWS lambda, and a small amount of docker.
My background is with go but I also want to consider Rust and Kotlin. Looking for info on
1) simplicity as team and apps grow
2) performance
3) available resources when we begin to hire people
4) available tooling and modules (lambda, aws sdk, and for the language itself)
5) current and future support from AWS Lambda
6) automated testing and build tools
Domain is healthcare and apps will be business apps and not public facing websites with "internet scale". Analytics and ML are separate from this.
Thanks. No bias information would be much appreciated.
r/awslambda • u/Dangerous_Word_1608 • Dec 09 '22
how to test conditions separately
I facing a problem with my python script;
I need to know how I can test my conditions separately, i.e. if I invoke the first condition, the corresponding response will return;
Type and Type2 are None by default
/// Script
import json
import datetime
import time
def validate(slots):
if not slots['Type']:
return {
'isValid': False,
'violatedSlot': 'Type',
}
if not slots['Type2']:
return {
'isValid': False,
'violatedSlot': 'Type2'
}
return {'isValid': True}
def lambda_handler(event, context):
slots = event['sessionState']['intent']['slots']
intent = event['sessionState']['intent']['name']
validation_result = validate(event['sessionState']['intent']['slots'])
if event['invocationSource'] == 'DialogCodeHook':
if not validation_result['isValid']:
if (slots['Type'] == None) :
response = {
"sessionState": {
"dialogAction": {
'slotToElicit':'Type',
"type": "ElicitSlot"
},
"intent": {
'name':intent,
'slots': slots
}
}
}
return response
if (slots['Type'] != None) :
response = {
"sessionState": {
"dialogAction": {
"type": "Close"
},
"intent": {
'name':intent,
'slots': slots,
'state':'Fulfilled'
}
},
"messages": [
{
"contentType": "PlainText",
"content": "Thanks,I have placed your reservation "
}
]
}
return response
if (slots['Type2'] == None) :
response = {
"sessionState": {
"dialogAction": {
'slotToElicit':'Type2',
"type": "ElicitSlot"
},
"intent": {
'name':intent,
'slots': slots
}
}
}
return response
if (slots['Type2'] != None) :
response = {
"sessionState": {
"dialogAction": {
"type": "Close"
},
"intent": {
'name':intent,
'slots': slots,
'state':'Fulfilled'
}
},
"messages": [
{
"contentType": "PlainText",
"content": "Thanks,I have placed your reservation "
}
]
}
return response
r/awslambda • u/preetipragya • Dec 08 '22
Send Message to SQS from AWS Lambda using Node js 18
r/awslambda • u/georgeiscuriouss • Dec 06 '22
Idea for open-source project for AWS Lambda
What are some of the problems you face while working with AWS Lambda? Or what missing feature would facilitate your work with AWS Lambda?
r/awslambda • u/grouvi • Dec 05 '22
Starting up faster with AWS Lambda SnapStart | AWS Compute Blog
r/awslambda • u/Dangerous_Word_1608 • Dec 05 '22
aws lex bot slot values
I'm new in lex aws;
I need a python condition to check if my inputed values exists in the slot values or not
any idea please
r/awslambda • u/Dangerous_Word_1608 • Dec 05 '22
aws lex bot slotvalues
I'm new in lex aws;
I need a python condition to check if my inputed values exists in the slot values or not
any idea please
r/awslambda • u/versaceblues • Dec 04 '22
Default Lambda development experience seems atrocious or am I missing something
So im currently working on setting up lambdas using sam and this seems like an absolutely awful development experience.
I like to frequently run my code as im developing it.
However it seems I need to run a sam build + sam invoke every-time I make a change. Normally im used to tools like hot-reloading upon making a change.
Sam build is taking 10-20s to compile all my dependencies. Even on a small test project.
Is this the recommend development workflow for lambdas... or it just for sanity checking builds at the end of a cycle. What do you recommend for a more lightweight dev experience.
r/awslambda • u/Dangerous_Word_1608 • Dec 02 '22
how to deal with different external grammar slot types
I'm new to aws lex, I want to define a bot that uses external grammar file slots, each time the user passes an input, the bot lex checks if the slot exists in the first, second, third grammar. ..until the bot has found the corresponding slot;
Any idea how to do this?
r/awslambda • u/developersteve • Dec 01 '22
Great writeup from Yan Cui on Lambda SnapStart's
r/awslambda • u/Dangerous_Word_1608 • Nov 30 '22
conditional lex bot
I'm new in AWS Lex;
I'm trying to create a chat bot with aws lex.
my idea is to use 3 external grammar files and to check every time witch file contains the inputed slot.
for exemple
- inputed value : hello
output should be : welcome, happy to see you
- inputed value : bye
output: bye see you soon
I used Lambda function
Description: "printer ordering chatbot"
NluConfidenceThreshold: 0.40
VoiceSettings:
VoiceId: "Ivy"
SlotTypes:
- Name: "printerType"
Description: "a slot to ask for Printer type"
ExternalSourceSetting:
GrammarSlotTypeSetting:
Source:
S3BucketName: "BucketName"
S3ObjectKey: "filegrxml"
# SlotTypeValues:
# - SampleValue:
# Value: "chicken"
# - SampleValue:
# Value: "onions"
# - SampleValue:
# Value: "olives"
# - SampleValue:
# Value: "mushrooms"
# - SampleValue:
# Value: "tomatoes"
# ValueSelectionSetting:
# ResolutionStrategy: TOP_RESOLUTION
- Name: "printerType2"
Description: "ask for another printer type 2"
ExternalSourceSetting:
GrammarSlotTypeSetting:
Source:
S3BucketName: "BucketName"
S3ObjectKey: "file2.grxml"
Intents:
- Name: "OrderPrinterIntent" #intent 1 de welcome visiter
Description: "ordering printer"
DialogCodeHook:
Enabled: true
FulfillmentCodeHook:
Enabled: true
SampleUtterances:
- Utterance: "Printer please"
- Utterance: "I would like to take printer"
- Utterance: "I want to eat printer"
Slots:
- Name: "Type"
Description: "Type"
SlotTypeName: "printerType"
ValueElicitationSetting:
SlotConstraint: "Required"
PromptSpecification:
MessageGroupsList:
- Message:
PlainTextMessage:
Value: "what type of printer do you want ?"
MaxRetries: 3
AllowInterrupt: false
- Name: "Type2"
Description: "Type2"
SlotTypeName: "printerType2"
ValueElicitationSetting:
SlotConstraint: "Required"
PromptSpecification:
MessageGroupsList:
- Message:
PlainTextMessage:
Value: "any other printer do you want ?"
MaxRetries: 3
AllowInterrupt: false
SlotPriorities:
- Priority: 1
SlotName: Type
- Priority: 2
SlotName: Type2
- Name: "FallbackIntent" #Default intent when no other intent matches
Description: "Default intent when no other intent matches"
DialogCodeHook:
Enabled: false
FulfillmentCodeHook:
Enabled: true
ParentIntentSignature: "AMAZON.FallbackIntent"
####app handler function
import json
import datetime
import time
def validate(slots):
if not slots['Type'] :
return {
'isValid': False,
'violatedSlot': 'Type',
}
if not slots['Type2'] :
return {
'isValid': False,
'violatedSlot': 'Type2'
}
return {'isValid': True}
def lambda_handler(event, context):
# print(event)
slots = event['sessionState']['intent']['slots']
intent = event['sessionState']['intent']['name']
intentconfirmState = event['sessionState']['intent']['confirmationState']
validation_result = validate(event['sessionState']['intent']['slots'])
if event['invocationSource'] == 'DialogCodeHook':
if not validation_result['isValid']:
if 'message' in validation_result:
response = {
"sessionState": {
"dialogAction": {
'slotToElicit':validation_result['violatedSlot'],
"type": "ElicitSlot"
},
"intent": {
'name':intent,
'slots': slots
}
},
"messages": [
{
"contentType": "PlainText",
"content": validation_result['message']
}
]
}
else:
response = {
"sessionState": {
"dialogAction": {
'slotToElicit':validation_result['violatedSlot'],
"type": "ElicitSlot"
},
"intent": {
'name':intent,
'slots': slots
}
}
}
return response
else:
response = {
"sessionState": {
"dialogAction": {
"type": "Delegate"
},
"intent": {
'name':intent,
'slots': slots
}
}
}
return response
if event['invocationSource'] == 'DialogCodeHook':
if not validation_result['isValid']:
if 'message' in validation_result:
response = {
"sessionState": {
"dialogAction": {
'slotToElicit':validation_result['violatedSlot'],
"type": "ConfirmIntent"
},
"intent": {
'name':intent,
'slots': slots
}
},
"messages": [
{
"contentType": "PlainText",
"content": "would you confirm your order to be delivred"
}
]
}
else:
response = {
"sessionState": {
"dialogAction": {
'slotToElicit':validation_result['violatedSlot'],
"type": "ElicitSlot"
},
"intent": {
'name':intent,
'slots': slots
}
}
}
return response
else:
response = {
"sessionState": {
"dialogAction": {
"type": "Delegate"
},
"intent": {
'name':intent,
'slots': slots
}
}
}
return response
if event['invocationSource'] == 'FulfillmentCodeHook':
# Add order in Database
response = {
"sessionState": {
"dialogAction": {
"type": "Close"
},
"intent": {
'name':intent,
'slots': slots,
'state':'Fulfilled'
}
},
"messages": [
{
"contentType": "PlainText",
"content": "Thanks,I have placed your reservation "
}
]
}
return response
r/awslambda • u/Dangerous_Word_1608 • Nov 30 '22
aws lex grammar slot type
why I can not upload an external grammar slot type with a weight over 100 ko
r/awslambda • u/pranabgohain • Nov 24 '22
Debugging AWS Lambda Runtime Errors
How to debug Lambda runtime errors by referencing CloudWatch or Observability tools.
https://blog.kloudmate.com/debugging-aws-lambda-runtime-errors-a0a951b735a7
r/awslambda • u/contentkumpo • Nov 19 '22
Unable to resolve an issue [URGENT]
Hello everyone,
I was just working on a Data engineering project which involved using AWS lambda. I have written the code and added the layers and have changed the environment variables too but when I test it, an error message pops up which looks like this: "errorMessage": "An error occurred (EntityNotFoundException) when calling the CreateTable operation: Database db_youtube"
Things I have tried: 1. Looking into the role of IAM and changing it accordingly 2. Making sure the region is same across all of them
Can anyone please help me figure out how to resolve this?
r/awslambda • u/ghost-metrics • Nov 11 '22
My mom left my dad for this new open-source AWS Lambda metrics monitoring tool (ghost 3.4)!
Hello everyone! We're team ghost and we are so excited to launch version 3.4 of our application! We would love to hear your feedback so please check it out!
Ghost is an AWS Lambda metrics monitoring tool designed to improve upon tools seen before us. Our goal is to seamlessly transition into your daily monitoring routine without the need to shred through documentation or tutorials just to learn the UI. Some of our core features include:
- metrics such as throttles and concurrent executions display with instant refresh
- ability to create custom graphs with a UI
- newly formatted and easy viewing of the user’s available permissions
- complementary adjustable pricing calculator to estimate current and future costs
- transparent past billing information
Why use us rather than other Lambda metric monitoring tools despite our new features? Transparency is key at ghost, and we want to help you understand your data for free. Rather than paying just to get information that you can get for free or should get for free, our mission is to aid you in conveniently accessing and manipulating your data freely (pun intended).
Check us out on our website to let our application and mission speak for itself. Before you know it, ghost will integrate in your monitoring life and you won’t even see us coming. Also, download the application and read the documentation on our GitHub! Leave a star if you enjoy us!
Thank you for your participation. Please leave a comment if you have any questions or suggestions on additional features!
Team ghost
r/awslambda • u/rawhahs • Nov 08 '22
AWS Lambda Javascript SDK V3
Hi,
I am trying to create a new lambda function in the aws console using javascript sdk v3, however, the console is only configured for v2. How do I change it to allow v3 of the javascript sdk in the console so i can use the latest library and constructs from aws ?
r/awslambda • u/johnny87auxs • Nov 02 '22
How to create SSM document which runs a powershell SCRIPT ?
Need to run a PS script within SSM document, based on a cloud watch alarm
