🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › lambda sample applications
Lambda sample applications - AWS Lambda
– An example that shows how to use Quarkus in a managed Java runtime with and without SnapStart, or as a GraalVM native image with a custom runtime. Learn more in the Quarkus/Lambda guide ... – A hello world function that returns the public IP address. This app uses the provided.al2 custom runtime. ... – A Go function that shows the use of Lambda's Go libraries, logging, environment variables, and the AWS SDK.
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › create your first lambda function
Create your first Lambda function - AWS Lambda
INIT_START Runtime Version: python:3.13.v16 Runtime Version ARN: arn:aws:lambda:us-west-2::runtime:ca202755c87b9ec2b58856efb7374b4f7b655a0ea3deb1d5acc9aee9e297b072 START RequestId: 9d4096ee-acb3-4c25-be10-8a210f0a9d8e Version: $LATEST The area is 42 [INFO] 2024-09-01T00:05:22.464Z 9315ab6b-354a-486e-884a-2fb2972b7d84 CloudWatch logs group: /aws/lambda/myLambdaFunction END RequestId: 9d4096ee-acb3-4c25-be10-8a210f0a9d8e REPORT RequestId: 9d4096ee-acb3-4c25-be10-8a210f0a9d8e Duration: 1.15 ms Billed Duration: 2 ms Memory Size: 128 MB Max Memory Used: 40 MB · When you're finished working with the example function, delete it.
Discussions

Why or why not use AWS Lambda instead of a web framework for your REST APIs? (Business projects)
To clarify a couple of things: AWS Lambda is one of many ways to deploy code on AWS. AWS Lambda ECS EC2 EKS etc... You can deploy almost any type of code on all of these including a python API. What makes AWS Lambda special is: You can deploy docker containers, or .zip files. LINK It is 100% "serverless", AKA AWS manages the server for you, and you just tell AWS how many instances you want to run. This is done with Firecracker LINK It can scale from 0-10,000+ instances really quickly It can be very cheap vs a EC2 instance if you have a bursty load You can string together multiple Lambda functions using AWS Step Functions LINK You can trigger the lambda functions with a wide range of things. LINK You can run numerous functions in parallel. Stateless (ish, you can have state, but don't do that) This is both positive and negative. Most modern code should be stateless. IE, you should be able to kill it at any point, and run it again. The state should be stored in a database, not locally with the code. AWS Lambda has some downsides: It can be expensive if you have a constant load Data processing, 5+ minute loads, etc. Most light/fast APIs will be much cheaper on Lambda than a tradition ECS + EC2 setup. Testing locally is annoying LINK Lambda does some weird things with requests. You need to add some middleware to handle it. LINK Cold starts! If you haven't called your Lambda in ~15 minutes, the next call can take much longer to start. LINK You don't have control, so if something goes wrong with AWS Lambda, you can't do anything about it. 15 minute max You can only keep a lambda up for a max of 15 minutes. For an API this is more than enough, but for a larger job you should look somewhere else (ECS Fargate, AWS Batch) Other limits (CPU, Time, RAM, etc.) LINK Other, more “traditional” ways to deploy a web API would be AWS ECS or AWS EC2. ECS offers something called Fargate. It is built on the same serverless framework (Firecracker) and will let you deploy code without dealing with the underlying hardware. This has a lot of the same advantages as AWS Lambda without most of the disadvantages. Now to the question I suspect you are really asking. "When should I use a Web API vs another processing method like a queue consumer, map reduce job, ETL pipeline, batch job, etc?" That is a very hard question to answer, and it depends on exactly what you are trying to do. Based on your post history, I assume you are trying to move a monolithic ERP system to microservices? EDIT: Sorry about the spam edits, I decided to move to my computer and give a better answer. More on reddit.com
🌐 r/Python
29
83
January 11, 2023
Can somebody ELI5 what it means to put a Lambda function in a VPC? Using CDK, if you don't specify a VPC when creating a Lambda function, what does that effectively do?
If you don't specify a VPC then the Lambda runs in an VPC internal to AWS managed by them. It runs in a public subnet with internet access and access to all AWS services. It's basically the best option unless your Lambda needs to talk to other resources within your own networks. More on reddit.com
🌐 r/aws
14
22
July 28, 2023
So what does a well-made AWS Lambda in Python actually look like?
I've written probably 50 lambdas in Python at this point and to be honest keeping it simple is the best way. Follow PIP standards to keep your code readability high, use the paginator objects boto3 provides where possible and try to keep the execution time down.15 minutes is pretty high for something serverless so I tend to design my lambdas to perform a single task and then use something like AWS Step Functions to orchestrate several in a flow or in Map states (loops). I also make use of environment variables where possible and template a lot of functions for common things like assuming roles. I also make use of comprehension but don't go too overboard with that because it can reduce readability if you've got a fat one defined haha. No need to add comments every other line, just a single line docstring at the top of the function should be enough to describe it. There's also some neat docker commands out there to build all your packages into a single lambda layer using a requirements.txt, using the lambda image, and this should be possible to do with Terraform, or if you've only got one or two packages just prepare it in a CI/CD and use terraform to build and apply the layer. More on reddit.com
🌐 r/aws
18
24
September 22, 2023
How on earth do you deploy AWS Lambdas?
CDK is another great option that hasn't been brought up in this thread More on reddit.com
🌐 r/aws
91
19
July 2, 2023
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › invoking lambda with events from other aws services › invoking a lambda function using an amazon api gateway endpoint › tutorial: using lambda with api gateway
Tutorial: Using Lambda with API Gateway - AWS Lambda
Choose Use an existing role, and then select the lambda-apigateway-role role that you created earlier. Choose Create function. In the Code source pane, replace the default code with the following Node.js or Python code. ... The region setting must match the AWS Region where you deploy the function and create the DynamoDB table.
🌐
Medium
gartsolutions.medium.com › an-overview-of-aws-lambda-cd53d074cf3f
An Overview of AWS Lambda. AWS Lambda is a compute service that… | by Roman Burdiuzha | Medium
September 16, 2023 - SQS (Simple Queue Service): For instance, if your Lambda function processes messages from SQS, there’s no need to return a result anywhere, and it can be executed asynchronously. When executed asynchronously, several new possibilities arise. For example, you can configure retries in case of errors or forward such requests to a “dead letter” SQS queue. These are the AWS ...
🌐
Modal
modal.com
Modal: High-performance AI infrastructure
If you're running model-based evals, why not just call a serverless Modal function and have it evaluate your model on a separate worker GPU? This makes evaluation during training really easy. ... Late to the party, but finally playing with @modal to run some backend jobs. DX is sooo nice (compared to Docker, Cloud Run, Lambda, etc).
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › code examples for lambda using aws sdks
Code examples for Lambda using AWS SDKs - AWS Lambda
The following code examples show how to use Lambda with an AWS software development kit (SDK). Basics are code examples that show you how to perform the essential operations within a service. Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions...
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with python › define lambda function handler in python
Define Lambda function handler in Python - AWS Lambda
January 31, 2026 - You can use the context object to output information about your function's invocation for monitoring purposes. The context object is a Python class that's defined in the Lambda runtime interface client · . To return the value of any of the context object properties, use the corresponding method on the context object. For example, the following code snippet assigns the value of the aws_request_id property (the identifier for the invocation request) to a variable named request.
Find elsewhere
🌐
Stackify
stackify.com › aws-lambda-with-python-a-complete-getting-started-guide
AWS Lambda with Python: A Complete Getting Started Guide - Stackify
May 16, 2024 - As an example, in the following screenshot, I’ve added triggers for the API Gateway and Alexa Skills Kit. If you’re curious about what a layer is, here’s what you need to know: a layer essentially allows you to add additional dependencies or frameworks for your function to use. We won’t be using any layers, but for more information, refer to the AWS Lambda ...
🌐
GitHub
github.com › awsdocs › aws-doc-sdk-examples › blob › main › python › example_code › lambda › lambda_basics.py
aws-doc-sdk-examples/python/example_code/lambda/lambda_basics.py at main · awsdocs/aws-doc-sdk-examples
FunctionName=function_name, Description="AWS Lambda doc example", Runtime="python3.9", Role=iam_role.arn, Handler=handler_name, Code={"ZipFile": deployment_package}, Publish=True, ) function_arn = response["FunctionArn"] waiter = self.lambda_client.get_waiter("function_active_v2") waiter.wait(FunctionName=function_name) logger.info( "Created function '%s' with ARN: '%s'.", function_name, response["FunctionArn"], ) except ClientError: logger.error("Couldn't create function %s.", function_name) raise ·
Author   awsdocs
🌐
Medium
iamkanikamodi.medium.com › write-a-sample-aws-lambda-function-c616f1e18975
Write a sample AWS Lambda Function | by Kanika Modi | Medium
March 23, 2019 - You can specify a handler (a method/function in your code) where AWS Lambda can begin executing your code. There is already a sample code present.
🌐
W3Schools
w3schools.com › python › python_lambda.asp
Python Lambda
The power of lambda is better shown when you use them as an anonymous function inside another function. Say you have a function definition that takes one argument, and that argument will be multiplied with an unknown number:
🌐
SentinelOne
sentinelone.com › blog › aws-lambda-tutorial
SentinelOne | AWS Lambda Tutorial: A Guide to Creating Your First Function
April 3, 2024 - As you progress throughout the tutorial, you’ll also learn why Lambda and Function-as-a-Service have enjoyed widespread adoption over the past few years. AWS Lambda is a way to run code without creating, managing, or paying for servers.
🌐
Terraform Registry
registry.terraform.io › providers › hashicorp › aws › latest › docs
Docs overview | hashicorp/aws | Terraform | Terraform Registry
When using the user_agent provider argument, the items will be appended to the User-Agent header in order. The user_agent provider-defined function can be used to format the name, version, and comment components. provider "aws" { user_agent = [ provider::aws::user_agent("example-demo", "0.0.1", "a comment"), "other-demo/0.0.2 (other comment)", ] }Copy
🌐
X
x.com › nicbstme › status › 2015174818497437834
Nicolas Bustamante en X: "Lessons from Building AI Agents for Financial Services" / X
The pattern: S3 is the source of truth, a Lambda function syncs changes to PostgreSQL for fast queries, and the agent gets exactly what it needs when it needs it.
🌐
Medium
medium.com › @stephinmon.antony › aws-lambda-with-python-examples-2eb227f5fafe
AWS Lambda with python examples. AWS Lambda is a server less computing… | by stephinmon antony | Medium
November 7, 2018 - So if we upload any .txt files to the configured S3 bucket, it will trigger the Lambda function and copy the uploaded file to the target S3 bucket. ... Python code for copying file from one s3 bucket to another s3 bucket(hard coded the target s3 bucket here, you may change the name as you want) Handler : Handler is a function which calls to start your AWS Lambda function.
🌐
AWS Builder Center
builder.aws.com › build › tools
AWS Builder Center
Connect with builders who understand your journey. Share solutions, influence AWS product development, and access useful content that accelerates your growth. Your community starts here.
🌐
Stripe
docs.stripe.com › webhooks
Receive Stripe events in your webhook endpoint | Stripe Documentation
This code snippet is a webhook function configured to check for received events, detect the originating account if applicable, handle the event, and return a 200 response.
🌐
AWS
docs.aws.amazon.com › aws sdk code examples › code library › code examples by service using aws sdks › code examples for lambda using aws sdks
Code examples for Lambda using AWS SDKs - AWS SDK Code Examples
The following code examples show you how to use AWS Lambda with an AWS software development kit (SDK). Basics are code examples that show you how to perform the essential operations within a service. Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions...
🌐
AWS
docs.aws.amazon.com › amazon bedrock › user guide › additional capabilities › automate tasks in your application using ai agents › tutorial: building a simple amazon bedrock agent › step 1: create a lambda function
Step 1: Create a Lambda function - Amazon Bedrock
For Statement ID, enter a unique identifier (for example, AllowBedrockInvocation). For Principal, enter bedrock.amazonaws.com. For Source ARN, enter arn:aws:bedrock:region:AWS account ID:agent/* Replace region with AWS Region that you are using, such as us-east-1. Replace AWS account ID your AWS account Id. For Action, select lambda:InvokeFunction.
🌐
GitHub
github.com › shreyasgaonkar › aws-lambda-code-samples
GitHub - shreyasgaonkar/aws-lambda-code-samples: Lambda sample codes for EC2, Lambda, API Gateway and SNS in python runtime.
A few of the sample AWS Lambda function codes for common use-cases with Amazon EC2, AWS Lambda, API Gateway & Amazon SNS using Python runtime.
Starred by 29 users
Forked by 18 users
Languages   Python 100.0% | Python 100.0%