Lambda in AWS
Lambda is a serverless compute service that allows you to run code without provisioning or managing servers. Here is an example of how to create a Lambda function using the AWS SDK for Python (boto3):
python
import boto3
lambda_client = boto3.client('lambda')
response = lambda_client.create_function(
FunctionName='my-function',
Runtime='python3.6',
Role='arn:aws:iam::123456789012:role/lambda-role',
Handler='handler.lambda_handler',
Code={
'ZipFile': open('lambda_function.zip', 'rb').read()
},
Description='My first Lambda function'
)
This code creates a Lambda function named "my-function" that runs on Python 3.6, uses a specified role, and executes a function called "handler.lambda_handler". It also specifies the code for the function, which is packaged as a ZIP file.
No comments:
Post a Comment