您现在的位置是:首页 >学无止境 >aws CloudFormation deploy lamdba function网站首页学无止境

aws CloudFormation deploy lamdba function

彻骨寒风 2024-07-01 11:59:07
简介aws CloudFormation deploy lamdba function

1.python code  lamdba_function.py

def lambda_handler(event, context):
    message = 'Hello {} {}!'.format(event['first_name'], event['last_name'])
    return {
        'message' : message
    }

 2.zip code

zip lamdba_function.zip lamdba_function.py

 3. upload zip to s3

4. creat role

 5.creat lamdba_function.yaml

AWSTemplateFormatVersion: '2010-09-09'
Description: Lambda function.
Resources:
  Function:
    Type: AWS::Lambda::Function
    Properties:
      Handler: lamdba_function.lambda_handler  #文件名+handler名称
      Role: arn:aws:iam::856290849487:role/lamdba_role
      Code:
        S3Bucket: kaijia-test
        S3Key: lamdba_function.zip
      Runtime: python3.10
      Timeout: 5
      TracingConfig:
        Mode: Active

6. deploy

 

 

7. see function

 

风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。