Sunday, April 26, 2020

AWS Lambda using Python

AWS HOWTO
https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html


AWS repository
https://github.com/awsdocs/aws-lambda-developer-guide


Check prerequisities

[dave@dave ~]$ aws --version

aws-cli/2.0.1 Python/3.7.3 Linux/5.5.16-200.fc31.x86_64 botocore/2.0.0dev5

[dave@dave ~]$ python --version

Python 3.7.6

 



Python Lambda

import json

 
def lambda_handler(event, context):

    # TODO implement

    return {

        'statusCode': 200,

        'body': json.dumps('Hello from Lambda!')

    }



Get lambda in AWS CLI

[dave@dave aws-lambda-developer-guide]$  aws lambda get-function --function-name dave-test-function

{

    "Configuration": {

        "FunctionName": "dave-test-function",

        "FunctionArn": "arn:aws:lambda:eu-central-1:45454545454:function:dave-test-function",

        "Runtime": "python3.8",

        "Role": "arn:aws:iam::45454545:role/dave-lambda-role-test",

        "Handler": "lambda_function.lambda_handler",

        "CodeSize": 299,

        "Description": "",

        "Timeout": 3,

        "MemorySize": 128,

        "LastModified": "2020-04-26T07:53:06.901+0000",

        "CodeSha256": "45454545454545",

        "Version": "$LATEST",

        "TracingConfig": {

            "Mode": "PassThrough"

        },

        "RevisionId": "454545454545",

        "State": "Active",

        "LastUpdateStatus": "Successful"

    },

    "Code": {

        "RepositoryType": "S3",

        "Location": "https://awslambda-eu-cent-1-tasks.s3.eu-central-1.amazonaws.com/snapshots/454534345656/dave-test-function-456544562342423424"

    }

}

 

2 comments: