AWS Lambda python function output remains "Hello from Lambda" even after changing the code

Viewed 1931

So I just started learning AWS Lambda today and tried to create a simple Hello World function in Python. The sample code which AWS generates looks like this:

import json

def lambda_handler(event, context):
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

Running this code gives the following output:

Response
{
  "statusCode": 200,
  "body": "\"Hello from Lambda!\""
}

But now when I try to modify this code and run it I get the exact same output as the sample code. I modified it to this:

import json

def lambda_handler(event, context):
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello!')
    }

But I still get this as output:

Response
{
  "statusCode": 200,
  "body": "\"Hello from Lambda!\""
}

Things I've tried:

  1. Deleting the function and creating a new one.
  2. Using a different test event.

Neither worked. I also watched videos on YouTube where people are doing exactly what I was and their code change seemed to work. Can someone please help me with what I am missing?

1 Answers

Clicking on "Deploy" first and then "Test" worked for me.

Related