Long Running Lambda
Joel@contrastsecurity.com
http://www.joel.codes/longrunninglambda/
AWS Lambda
Limitations:
● 300 seconds run time
● 512MB disk space
● 3008 MB memory
● 1,024 file descriptors
● 1,024 Processes/Threads
● 6MB RequestResponse/synchronous body payload invocation
● 128K Event/asynchronous invocation body payload invocation
Limitless AWS Lambda
● No time limit
● No code run time requirements
Limitless AWS Lambda
Lambda
● A trigger for that Function
● IAM Role
● A place to log output
● Ultimately launches ECS
Two Cycles and their requirements
ECS
● VPC
● Subnet
● Security Group
● IAM Role
● A place to log output
● Ultimately runs your code
ECS Basics
● Repositories
● Clusters
● Task Definition
ECS Task Definition
{
"executionRoleArn": "arn:aws:iam::account_id:role/DockerContainerS3IAMRole",
"containerDefinitions": [
{
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/aws/lambda/DatabaseBackups",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "DatabaseBackups"
}
},
"environment": [
{
"name": "DB_DUMP_DIR",
"value": "/opt/database/backups"
}
"image": "account_id.dkr.ecr.us-east-1.amazonaws.com/DatabaseBackups:latest",
"name": "DatabaseBackups"
}
],
"taskDefinitionArn": "arn:aws:ecs:us-east-1:account_id:task-definition/DatabaseBackups:6",
"family": "DatabaseBackups",
"requiresCompatibilities": [
"FARGATE"
]
}
Fargate in Depth
The Lambda
import boto3
import os
def lambda_handler(event, context):
print('Starting lambda, request-id: ', context.aws_request_id)
print('ECS Cluster: ', os.environ['ecs_cluster'])
print('ECS Task Definition: ', os.environ['ecs_task_definition'])
print('ECS subnets: ', os.environ['ecs_subnet'])
ecs = boto3.client('ecs')
response = ecs.run_task(
cluster=os.environ['ecs_cluster'],
taskDefinition=os.environ['ecs_task_definition'],
launchType='FARGATE',
networkConfiguration={
'awsvpcConfiguration': {
'subnets': [
os.environ['ecs_subnet'],
],
'assignPublicIp': 'ENABLED'
}
},
count=1
)
Backing up a Database

More Related Content

PDF
Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ...
PPTX
Amazon Web Services lection 5
PPTX
Amazon Web Services lection 2
PPTX
Amazon Web Services lection 6
PDF
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
PPTX
Serverless Reality
PPTX
AWS Kinesis
PDF
AWS Lambda - A quick introduction #advancedaws
Server-less solution for moving Millions of Images in Cloud - Brett Sutter, ...
Amazon Web Services lection 5
Amazon Web Services lection 2
Amazon Web Services lection 6
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Reality
AWS Kinesis
AWS Lambda - A quick introduction #advancedaws

What's hot (16)

PDF
Deploying Data Science with Docker and AWS
PDF
AWS Brown Bag
PDF
AWS re:Invent 2016 Recap: What Happened, What It Means
PPTX
AWS for the Data Professional
PDF
AWSome day 2018 - scalability and cost optimization with container services
PDF
AWSome day 2018 - API serverless with aws
PDF
AWS Bulgaria: Re:invent 2017 Recap
PPTX
SQL Server on Google Cloud Platform
PDF
AWSome day 2018 - database in cloud
PPTX
Benchmarking Aerospike on the Google Cloud - NoSQL Speed with Ease
PPTX
Introduction to AWS Kinesis
PPTX
Real time sentiment analysis using twitter stream api & aws kinesis
KEY
Amazon Web Services (cloud: is it good for anything?)
PDF
MongoDB .local Bengaluru 2019: Distributed Transactions: With Great Power Com...
PDF
Docker Container automatisiert nach AWS deployen - Continuous Lifecycle 2016
PDF
[GS네오텍] Google Kubernetes Engine
Deploying Data Science with Docker and AWS
AWS Brown Bag
AWS re:Invent 2016 Recap: What Happened, What It Means
AWS for the Data Professional
AWSome day 2018 - scalability and cost optimization with container services
AWSome day 2018 - API serverless with aws
AWS Bulgaria: Re:invent 2017 Recap
SQL Server on Google Cloud Platform
AWSome day 2018 - database in cloud
Benchmarking Aerospike on the Google Cloud - NoSQL Speed with Ease
Introduction to AWS Kinesis
Real time sentiment analysis using twitter stream api & aws kinesis
Amazon Web Services (cloud: is it good for anything?)
MongoDB .local Bengaluru 2019: Distributed Transactions: With Great Power Com...
Docker Container automatisiert nach AWS deployen - Continuous Lifecycle 2016
[GS네오텍] Google Kubernetes Engine
Ad

Similar to Long running aws lambda - Joel Schuweiler, Minneapolis (20)

PDF
Getting Started with AWS Lambda & Serverless Cloud
PDF
Jak utrzymać stado Lambd w ryzach
PDF
Jak utrzymać stado Lambd w ryzach
PPTX
AWS Serverless Computing Introduction Session 2.pptx
PDF
Getting Started with AWS Lambda and Serverless Computing
PDF
What is AWS lambda?
PPTX
2016 Utah Cloud Summit: AWS Lambda and API Gateway
PPTX
lambda.pptx
PDF
The Best Practices and Hard Lessons Learned of Serverless Applications
PPTX
Primeros pasos en desarrollo serverless
PDF
Overview aws-lambda-security
PDF
Introduction to AWS Lambda with Python
PDF
AWS Lambda 활용의 모든 것! - AWS Summit Seoul 2017
PPTX
Auto Retweets Using AWS Lambda
PPTX
Scheduled Retweets Using AWS Lambda
PPTX
Serverless design considerations for Cloud Native workloads
PDF
Going Serverless on AWS with Golang and SAM
PPTX
Introduction to AWS lambda & Serverless Application1.pptx
PDF
AWS Lambda Functions A Comprehensive Guide
PDF
AWS Lambda Documentation
Getting Started with AWS Lambda & Serverless Cloud
Jak utrzymać stado Lambd w ryzach
Jak utrzymać stado Lambd w ryzach
AWS Serverless Computing Introduction Session 2.pptx
Getting Started with AWS Lambda and Serverless Computing
What is AWS lambda?
2016 Utah Cloud Summit: AWS Lambda and API Gateway
lambda.pptx
The Best Practices and Hard Lessons Learned of Serverless Applications
Primeros pasos en desarrollo serverless
Overview aws-lambda-security
Introduction to AWS Lambda with Python
AWS Lambda 활용의 모든 것! - AWS Summit Seoul 2017
Auto Retweets Using AWS Lambda
Scheduled Retweets Using AWS Lambda
Serverless design considerations for Cloud Native workloads
Going Serverless on AWS with Golang and SAM
Introduction to AWS lambda & Serverless Application1.pptx
AWS Lambda Functions A Comprehensive Guide
AWS Lambda Documentation
Ad

More from AWS Chicago (20)

PPTX
Kathie Kinde Clark - Elevate Your Professional Footprint: LinkedIn Masterclass
PDF
Jason Anderson From Dirt Roads to Highways: Simplifying DevOps and Cloud Inf...
PDF
Aman Sardana and Vijay Kumar Soni - Navigating Hybrid Cloud Challenges for ...
PDF
Ben Blair Operating Safely in a Vibe Coding World
PPTX
Joseph Morotti Enhancing customer experience through Amazon Connect and Gene...
PPTX
Craig Johnson When VPCs Attack: Real-Life Cloud Networking Fails (and Fixes)
PDF
Peter Sankauskas Access Denied: Understanding & Debugging AWS IAM
PDF
Shuen Mei Parth Sharma Boost Productivity, Innovation and Efficiency wit...
PDF
Bob Fornal The Impact of Testing on a DevOps Pipeline
PDF
Jason Butz Chaos Engineering with FIS and Lambda Functions
PPTX
Automated VPC migration into centralized inspection architecture with AWS Gat...
PDF
Julia Furst Morgado The Lazy Guide to Kubernetes with EKS Auto Mode + Karpenter
PDF
Bob Fornal - Active Career Management AWS Community Day Midwest 2025
PDF
Edwin Moedano Monitoring and Observability of Lambdas with Cloudwatch and Po...
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
PPTX
Nathan Hiscock Architecting secure, scalable, cost-efficient computer vision...
PDF
AWS Community Day Midwest 2025 Julia Furst Morgado The Lazy Guide to Kuberne...
PDF
Steven Seaney - Simplifying and Streamlining AWS Control Tower Deployments
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
PPTX
Paul Chin Jr. Data Gone in 60 Seconds: A Serverless ETL Heist
Kathie Kinde Clark - Elevate Your Professional Footprint: LinkedIn Masterclass
Jason Anderson From Dirt Roads to Highways: Simplifying DevOps and Cloud Inf...
Aman Sardana and Vijay Kumar Soni - Navigating Hybrid Cloud Challenges for ...
Ben Blair Operating Safely in a Vibe Coding World
Joseph Morotti Enhancing customer experience through Amazon Connect and Gene...
Craig Johnson When VPCs Attack: Real-Life Cloud Networking Fails (and Fixes)
Peter Sankauskas Access Denied: Understanding & Debugging AWS IAM
Shuen Mei Parth Sharma Boost Productivity, Innovation and Efficiency wit...
Bob Fornal The Impact of Testing on a DevOps Pipeline
Jason Butz Chaos Engineering with FIS and Lambda Functions
Automated VPC migration into centralized inspection architecture with AWS Gat...
Julia Furst Morgado The Lazy Guide to Kubernetes with EKS Auto Mode + Karpenter
Bob Fornal - Active Career Management AWS Community Day Midwest 2025
Edwin Moedano Monitoring and Observability of Lambdas with Cloudwatch and Po...
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
Nathan Hiscock Architecting secure, scalable, cost-efficient computer vision...
AWS Community Day Midwest 2025 Julia Furst Morgado The Lazy Guide to Kuberne...
Steven Seaney - Simplifying and Streamlining AWS Control Tower Deployments
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
Paul Chin Jr. Data Gone in 60 Seconds: A Serverless ETL Heist

Recently uploaded (20)

PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Five Habits of High-Impact Board Members
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Getting started with AI Agents and Multi-Agent Systems
PPTX
Tartificialntelligence_presentation.pptx
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PPTX
The various Industrial Revolutions .pptx
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
August Patch Tuesday
PPT
What is a Computer? Input Devices /output devices
PDF
STKI Israel Market Study 2025 version august
DOCX
search engine optimization ppt fir known well about this
PDF
Zenith AI: Advanced Artificial Intelligence
Univ-Connecticut-ChatGPT-Presentaion.pdf
Five Habits of High-Impact Board Members
A contest of sentiment analysis: k-nearest neighbor versus neural network
O2C Customer Invoices to Receipt V15A.pptx
Developing a website for English-speaking practice to English as a foreign la...
Getting started with AI Agents and Multi-Agent Systems
Tartificialntelligence_presentation.pptx
Taming the Chaos: How to Turn Unstructured Data into Decisions
The various Industrial Revolutions .pptx
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
DP Operators-handbook-extract for the Mautical Institute
1 - Historical Antecedents, Social Consideration.pdf
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
observCloud-Native Containerability and monitoring.pptx
A novel scalable deep ensemble learning framework for big data classification...
August Patch Tuesday
What is a Computer? Input Devices /output devices
STKI Israel Market Study 2025 version august
search engine optimization ppt fir known well about this
Zenith AI: Advanced Artificial Intelligence

Long running aws lambda - Joel Schuweiler, Minneapolis

  • 2. AWS Lambda Limitations: ● 300 seconds run time ● 512MB disk space ● 3008 MB memory ● 1,024 file descriptors ● 1,024 Processes/Threads ● 6MB RequestResponse/synchronous body payload invocation ● 128K Event/asynchronous invocation body payload invocation
  • 3. Limitless AWS Lambda ● No time limit ● No code run time requirements
  • 4. Limitless AWS Lambda Lambda ● A trigger for that Function ● IAM Role ● A place to log output ● Ultimately launches ECS Two Cycles and their requirements ECS ● VPC ● Subnet ● Security Group ● IAM Role ● A place to log output ● Ultimately runs your code
  • 5. ECS Basics ● Repositories ● Clusters ● Task Definition
  • 6. ECS Task Definition { "executionRoleArn": "arn:aws:iam::account_id:role/DockerContainerS3IAMRole", "containerDefinitions": [ { "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/aws/lambda/DatabaseBackups", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "DatabaseBackups" } }, "environment": [ { "name": "DB_DUMP_DIR", "value": "/opt/database/backups" } "image": "account_id.dkr.ecr.us-east-1.amazonaws.com/DatabaseBackups:latest", "name": "DatabaseBackups" } ], "taskDefinitionArn": "arn:aws:ecs:us-east-1:account_id:task-definition/DatabaseBackups:6", "family": "DatabaseBackups", "requiresCompatibilities": [ "FARGATE" ] }
  • 8. The Lambda import boto3 import os def lambda_handler(event, context): print('Starting lambda, request-id: ', context.aws_request_id) print('ECS Cluster: ', os.environ['ecs_cluster']) print('ECS Task Definition: ', os.environ['ecs_task_definition']) print('ECS subnets: ', os.environ['ecs_subnet']) ecs = boto3.client('ecs') response = ecs.run_task( cluster=os.environ['ecs_cluster'], taskDefinition=os.environ['ecs_task_definition'], launchType='FARGATE', networkConfiguration={ 'awsvpcConfiguration': { 'subnets': [ os.environ['ecs_subnet'], ], 'assignPublicIp': 'ENABLED' } }, count=1 )
  • 9. Backing up a Database