Amazon Q Feature Development (preview)
Build smarter: let Amazon Q Developer help with feature development
app.py
) implements the Lambda function itself, taking care of the parameters encoding and decoding, and the error handling. The second file (api.py
) contains the calls to DynamoDB to store and retrieve the data. This is a SAM application. The DynamoDB table and the two Lambda functions are declared in a template.yaml
file, alongside with the IAM role and environment variables passed to the Lambda functions to access the database.GET /case/{case_id}
retrieves a support case by passing its case_id
. POST /case
creates a new support case. It expects a JSON body that contains the case title
and description
.
As a developer, I want to add a new API to allow me to retrieve all support cases.
"add an API to list all support cases. Expose this API as a new Lambda function."
api,py
, app.py
and template.yaml
)
- add a
list_cases()
function to theapi.py
file ; - add a new test case for that
list_cases()
function ; - add a Lambda function handler in
app.py
that calls the newapi.list_cases()
and manages errors ; - add a new Lambda function in
template.yaml
. It proposes to name itListFunction
and proposes to expose it asGET /cases
; - and finally, it proposes to deploy and test the updated project.
api.py
. It correctly identified the need to call DynamoDB's scan()
API and it generated code to manage the result's pagination.
app.py
and wrote code to encode the HTTP API Gateway return value. It even generated code in the case an exception occurs and mimicked my print(event)
statement I always use at the start of Lambda handlers to verify the exact event passed to the function. This means it detected, understood, and replicated some of my personal coding patterns. How cool!
test_api.py
did not make use of any test framework, I added pytest
manually. Amazon Q Developer also did not generate correctly the content of template.yaml
. I expect this to change as we're always learning Amazon Q new things. It will continue to learn, evolve, and improve over time.Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.