Challenge Overview
Project overview
We need to build a small AWS Lambda function that will:
- Accept details of a Topcoder submission (memberID and submissionID)
- Generate an M2M authorization token for accessing Topcoder services
- Download the submission from the submission service (v5)
- Start up a configured EC2 instance
- Validate the submission on the instance by unzipping it and building it
- Make a request back to the reviews API with a response (either it builds successfully or the build fails), to indicate if the submission is valid
Technology
- Node.js
- Python
- EC2 / AWS APIs
- Topcoder APIs
- AWS Lambda
Project goal
The goal is that this Lambda function will be plugged into the submission workflow for specific marathon match challenges on the Topcoder site, allowing the submissions to be validated and eventually scored using the AWS platform, on EC2 instances.Requirements
Serverless
We will target Serverless and Node.js for defining the Lambda function: https://www.serverless.com/Submission API
To access the submission API, you will use a generated M2M token as the authorization header in the request.https://github.com/topcoder-platform/submissions-api
We will target: https://api.topcoder-dev.com/v5/ for this challenge, but please make it easy to configure this via serverless.
M2M details will be available in the forum, along with the key, secret, and sample request to generate the authorization token.
Once you have the authorization token, you can download the submission via the documented {{URL}}/submissions/{{submissionID}}/download endpoint. Note that the submission API contains a Postman collection, for reference, in the `docs` folder.
Sample payload
The payload will look like this, with the memberID and submissionID:
{
"resource": "submission",
"id": "5d1ab793-aebe-43af-9582-cf9e13207303",
"type": "Contest Submission",
"url": "https://s3.amazonaws.com/topcoder-dev-submissions-dmz/26f1f63a-3ccd-446b-a772-323063241d6c-23225544-SUBMISSION_ZIP-1599115849785.zip",
"memberId": 23225544,
"challengeId": 30056682,
"created": "2020-09-03T06:50:55.870Z",
"updated": "2020-09-03T06:50:55.870Z",
"createdBy": "lazybaer",
"updatedBy": "lazybaer",
"submissionPhaseId": 775212,
"fileType": "zip",
"isFileSubmission": false
}
We will use the submission API to download the submission to the spun up EC2 instance. It will be zipped, so we will unzip it and attempt to build it.
EC2 instance
For this particular challenge, we will target a basic CentOS Linux micro instance with Python, which you will launch, configure, run the build, and shut down via EC2 APIs. Note that we *don't* want to do anything like SSH into the instance and run scripts. All running of the build and commands should be done via EC2 APIs, like `SendCommand`. The submission will be in the Ptyhon language, and will be unzipped and built / run according to a specific template. You are free to define the template for what this should look like, but keep in mind we need to validate both success and failure of a run, as part of the review. We won't be validating the output - just that the Python dependencies install and the app itself runs successfully. You should make sure the template includes a requirements.txt, for installing the necessary Python dependencies. Please include something basic, like numpy or pandas, in the requirements.txt.
Response
The response (either success, failure, along with details on failure) will be POST'd back to the reviews API, using the M2M token we retrieved in the first step, from the lambda function.
https://tc-submission-api-prod.herokuapp.com/docs/#/Reviews/createReview
The score should either be 0 or 100, with 100 being a success, and 0 being a failure. Use /v5/reviews as the endpoint for the Topcoder API.
Once the validation is done, the EC2 instance should be shut down and deleted.
Configuration
All configuration should be external and easily addressed via Serverless, making it easy to adjust for different challenges. This includes things like the EC2 AMI to use, the size of the instance to launch, the configuration commands, the build command, along with the Topcoder API endpoint to use (prod or dev).
Scorecard Aid:
Judging Criteria- Major requirements are a working lambda that properly launches an EC2, configures it, and runs a submission
- Minor requirements is that the code is clean and easily deployable, that configuration is available in the serverless YML, and that the EC2 instance is stopped properly
Deployment guide and validation document
- You must provide a README.md that covers:
- How to install and configure the lambda
- A comprehensive Validation.md that covers:
- How to validate the individual requirements. Please ensure that you address each major requirement clearly and directly, including both success *and* failure of a sample build
What to submit
- The source code for the plugin
- A README.md that covers deployment of the code to AWS lambda
- A Validation.md that covers the details above