Using environment variables
Environment variables are useful for storing variables that you may want to change without modifying code.
Cody is going on vacation. While she would normally be the main person to receive messages, for a week it will be have to go to Jeff.
Let's tweak the Lambda function a bit to send a personalized SMS to Jeff!

I have assigned Jeff's phone number and name to the relevant environment variables.
Deze oefening maakt deel uit van de cursus
Streaming Data with AWS Kinesis and Lambda
Oefeninstructies
- Import the
osmodule. - Get the environment variables for PHONE_NUMBER and RECEIVER.
- Get the environment variable for DEPARTMENT, and if it's not set, fall back to
'Fleet Department'.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
import ____
# Get Environment variables, specify defaults
PHONE_NUMBER = os.____.get("ALERT_PHONE_NUMBER", None)
RECEIVER = os.environ.____("RECEIVER_NAME", "Random Person")
DEPARTMENT = ____("DEPARTMENT", "____")
# Construct message
message = """Hello {} from {}!
Here are the speeders:
{}
""".format(RECEIVER, DEPARTMENT, speeders.to_string())
# Send message
sns.publish(PhoneNumber = PHONE_NUMBER, Message = message)