Python Lab Challenge Contest
You are a new Python developer at a small SaaS startup built on AWS. During the interview process your coworkers assured you that AWS expertise is not required. Your ability to work with Python and Python libraries is enough to perform in the role.
One of the company's microservices is deployed as a serverless function on AWS Lambda. The function is triggered according to a schedule managed by an Amazon Eventbridge rule. Your colleague has asked you to update the schedule. The new schedule, which is a cron expression, is stored in a file, or object, in an Amazon S3 bucket. And one more thing, your colleague gave you the name of the object encoded as a cipher text.
Company policy requires all changes be performed using Python code. Partial code has been provided to you. To complete this challenge you need to complete three functions that are described later. Each function includes documentation describing the expected behavior of the code.
The following instructions prepare you for working with the embedded IDE that contains the code files that you must complete.
1. The in-browser development environment is accessible by clicking the Validation Steps tab.
It is starting up while you see Setup in progress. It takes approximately 1 minute to start up at which point you can begin writing code in the IDE.
You may detach the IDE to it's own browser tab by clicking the button shown below that is in the upper-right corner of the IDE:
You may also maximize the IDE within the same tab by clicking in the upper-right corner of this lab.
2. You may also, optionally, log in to AWS with an account that has limited read-only access by clicking Open Environment in the upper-right corner at the top of this lab and entering the user name and password provided in the Credentials drop-down menu:
Note: The Open Environment button is not visible if you maximize the IDE.
You do not need to log in to AWS to complete the challenge tasks.
3. Once the IDE setup is complete, click the left PROJECT bar to reveal the provided code files:
A summary of each file is as follows:
- aws_credential_helper.py: Helper function for authenticating AWS Python clients (clients are part of the
- challenge.py: Contains the high-level flow of the challenge. You do not need to edit this file, although you may want to comment out lines of code while developing the functions you need to complete.
- decipher.py: Contains the
decipherfunction you need to implement. The function's doc string explains the desired behavior you must implement to pass the first check.
- eventbridge_rules.py: Contains the
eventbridge_rulesclass, which includes an
update_rule_schedulemember function that you must complete for the third check to pass. You need to use the provided Eventbridge client (
_events_client). The documentation for the client is provided in the References section below.
- s3_objects.py: Contains the
s3_objectsclass, which includes a
get_contentmember function that you must complete for the second check to pass. You need to use the provided S3 client (
_s3_client). The documentation for the client is provided in the References section below.
When you have completed the three functions
challenge.py will be able to run from start to finish without any errors. You can run it by entering
python challenge.py in a terminal (Open a terminal by clicking Terminal > New Terminal in the IDE).
4. Wait until the lab AWS code credentials are available by confirming the line below shows an access key ID beginning with
AKIA (before the credentials are ready it will read
It takes two minutes from the time you start the lab for the key to appear. You can start on the decipher function implementation while waiting. Just be sure to perform instruction 5 before working on the S3 or Eventbridge code.
5. In the IDE, open a new terminal (Terminal > New Terminal) and enter the following commands to substitute placeholders with the AWS credentials in the provided code:
Copy codesed -i 's/AWS_CLIENT_ID//' aws_credential_helper.py
sed -i 's%AWS_CLIENT_SECRET%%' aws_credential_helper.py
The above commands allow the Python AWS clients to authenticate requests you will be sending.
6. Click the Go to Validation Steps button below to perform the tasks and complete the challenge. When you are ready, click to check your solution.
# Codecomment markers highlight where you need to write your code.
- You should not edit code before the
# Do not change the codecomments or change the source file names. Doing so may cause the checks to malfunction.
- The code files include test cases that you can run from the terminal. For example, you can test your decipher code by entering
python decipher.pyin the terminal.
The following documentation pages describe the methods available for each AWS client library you will need to use:
Keep in mind that the provided code already initializes an authenticated client as a class member variable for you to use.
Check the implementation of the
decipher function in
decipher.py is complete
Check the implementation of the
s3_objects.get_content function in
s3_objects.py is complete
Check there is one and only one Eventbridge rule with the correct schedule and the
EventBusName fields must remain the same. Be sure to run challenge.py (enter
python challenge.py in the terminal) to update the rule schedule.