More information on the services introduced in this section:

Run the following commands in the Cloud9 terminal to set environment variables used in this workshop:
AWS_REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/\(.*\)[a-z]/\1/')
accountId=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .accountId)
s3_deploy_bucket="theme-park-sam-deploys-${accountId}"
Environment variables are not stored in the terminal. Any time you close Cloud9 or open a new terminal, you will need to rerun these commands to set environment variables. This section is provided in each module.
Go to the Lambda console - from the AWS Management Console, select Services then select Lambda under Compute. Make sure your region is correct. You will see some Lambda functions that SAM has already deployed.
Select Create function:
theme-park-ridetimes for Function name.Node.js 14.x is selected under Runtime.arm64.Lambda functions that use arm64 architecture (AWS Graviton2 processor) can achieve significantly better better price and performance than the equivalent function running on x86_64 architecture. For more information, read this documentation page.


theme-park-ride-times:
Choose Add.
Back in the function view, select the Code tab. This opens the code source panel below.

**Now it’s your time to finish the codes. **
This Lambda function code should read the latest message from the SNS topic, writes it to the DynamoDB table, and then pushes the message to the frontend application via an IoT topic.
You could change the code runtime from NodeJS to python or other code language you are familiar with, by changing Runtime settings under the Code Tab.
The environment variables could be found below.
This function uses three environment variables:
IOT_DATA_ENDPOINT: the IoT endpoint hostname.IOT_TOPIC: The name of the IoT topic to publish messages to, which is theme-park-rides.DDB_TABLE_NAME: The name of the application’s DynamoDB table.In this section, you will retrieve and configure these Environment Variables for the function.
Go back to your browser tab with Cloud9 running. If you need to re-launch Cloud9, from the AWS Management Console, select Services then select Cloud9 under Developer Tools. Make sure your region is correct.
In the terminal enter the following command to retrieve the value for IOT_DATA_ENDPOINT:
aws iot describe-endpoint --endpoint-type iot:Data-ATS
aws dynamodb list-tables | grep backend

theme-park-ridetimes Lambda function open. Choose the Configuration tab, then select the Environment variables menu option on the left.
In the Environment variables card, choose Edit.
Choose Add environment variable three times to enter the three environment variables, as follows:
theme-park-rides
Ensure you have entered the environment variables into the Environment variables card, not the Tags card.