1. Inline Code
Cloudformation:
AWSTemplateFormatVersion: "2010-09-09" Description: Lambda inline code Resources: MyInlineLambda: Type: AWS::Lambda::Function Properties: Runtime: python3.x Role: arn:aws:iam::123456789012:role/lambda-role Handler: index.handler Code: ZipFile: | import os DB_URL = os.getenv("DB_URL") db_client = db.connect(DB_URL) def handler(event, context): user = db_client.get(user_id = event["user_id"]) return user
2. Through Zip File on S3
Cloudformation:
AWSTemplateFormatVersion: "2010-09-09" Description: Lambda from S3 Resources: MyLambdaFromS3: Type: AWS::Lambda::Function Properties: Runtime: nodejs18.x Role: arn:aws:iam::123456789012:role/lambda-role Handler: index.handler Code: S3Bucket: some-bucket S3Key: function.zip S3ObjectVersion: String
Serverless Framework:
service: my-service package: individually: true functions: hello: handler: com.serverless.Handler package: artifact: s3://some-bucket/path/to/function.zip
Top comments (0)