topics/aws/exercises/url_function/solution.md
Create a basic AWS Lambda function that will be triggered when you enter a URL in the browser
Go to Lambda console panel and click on Create function
Give the function a name like urlFunction
Select Python3 runtime
Now to handle function's permissions, we can attach IAM role to our function either by setting a role or creating a new role. I selected "Create a new role from AWS policy templates"
In "Policy Templates" select "Simple Microservice Permissions"
Next, you should see a text editor where you will insert a code similar to the following
import json
def lambda_handler(event, context):
firstName = event['name']
return 'Hello ' + firstName
{
"name": 'Spyro'
}
TestEvent)Test buttonExecution result: succeededWe'll define a trigger in order to trigger the function when inserting the URL in the browser
{ "name": "$input.params('name')" }
.../hello?name=marioHello Mario