Amazon Q Feature Development (preview)

Amazon Q Feature Development (preview)

Build smarter: let Amazon Q Developer help with feature development

Sebastien Stormacq
Amazon Employee
Published Apr 22, 2024
In this post, I show how Feature Development, a new capability of Amazon Q Developer (in preview), helps you be more productive when evolving your application code base.
Amazon Q Developer is a generative AI assistant that helps eliminate time-consuming, busy work across the entire software development lifecycle. It is available in the AWS console, your IDE, the command line, and more.
Amazon Q Developer can help you for various development tasks. It can help transforming old Java code base to a modern version of the language, it can help refactoring your code, generate unit tests, documentation headers, understand and explain a code base that you're discovering, and much more. But let's look at feature development.
As developers, we know that adding new features to our applications can be a time-consuming and challenging process. We often find ourselves spending countless hours researching APIs, understanding code dependencies, and implementing boilerplate code before we can even start working on the core business logic.
To help you be more productive and to focus on what matters most – the core functionality and business value of your new features – AWS launched Feature Development, a new capability of Amazon Q Developer in your IDE.
You just describe in natural language what feature you want to add or modify, and Amazon Q Developer suggests how to do it. With your approval, it even generates the code for you.

Here's how it works

First, I install the Amazon Q Developer extension in my IDE and authenticate with my free AWS Builder ID (enterprise users can also configure single sign-on with AWS Identity Center). The extension is available for Visual Studio Code (VSCode) and JetBrains' IDEs.
AWS Builder ID is a personal profile that provides access to select tools and services including Amazon CodeCatalyst, AWS Training and Certification, and here to authenticate on community.aws . AWS Builder ID represents you as an individual. It is independent from any credentials and data you may have in existing AWS accounts. You don't need to have an AWS Account to create a Builder ID.
Now I'm ready to use Amazon Q Developer.
It's a Python project with two AWS Lambda functions. The project has two files. The first file (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.
There are two APIs defined. 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.
Python project starting point
My Python Lambda project in VSCode

As a developer, I want to add a new API to allow me to retrieve all support cases.
To do so, there are only four steps required.
First, I describe the feature I want to add or modify. I simply provide a text describing the new feature I want to add. In this example, I wrote:
"add an API to list all support cases. Expose this API as a new Lambda function."
If you have something specific in mind, tell it. The more precise you prompt is, the closer the results will be to your expectations. In this specific case, (let's pretend) I don't know how to deal with DynamoDB API. I just expect Amazon Q to update all my files (api,py, app.py and template.yaml)
Second, I collaborate with Q Developer: Q Developer analyzes my code, understands the context, and proposes a plan for implementing the feature. I can collaborate with Q Developer, iterating on the plan until I'm satisfied.
Here is the proposed plan:
The proposed plan to add the feature I asked
Amazon Q proposed plan of implementation
I have to admit, I am always impressed by the level of details in the plan. Here Amazon Q generated a plan in five distinct and easy to understand steps:
  1. add a list_cases() function to the api.py file ;
  2. add a new test case for that list_cases() function ;
  3. add a Lambda function handler in app.py that calls the new api.list_cases() and manages errors ;
  4. add a new Lambda function in template.yaml . It proposes to name it ListFunction and proposes to expose it as GET /cases ;
  5. and finally, it proposes to deploy and test the updated project.
All of that makes a lot of sense. Depending how much I know about programming in this language and with this API, it might be all I need. Even without going all the way to code generation, simply reading the proposed plan can save me time researching how to tackle a specific problem, the type of changes I have to make, and so on.
When I want to refine the plan, I can engage with Amazon Q and ask it to modify a part. It will generate a new plan and I can iterate on it until I'm happy with the proposed solution.
Third, I let Q Developer handle the heavy lifting. Once the plan is finalized, Q Developer generates the code, UI elements, API integrations, and tests across my project. It handles the boilerplate work, allowing me to focus on the business logic.
Before changing any file in my project, it proposes a list of changes across multiple files. It might create new files from scratch or update existing ones. I can review the proposed diffs one by one.
Let's look at the proposed changes for api.py. It correctly identified the need to call DynamoDB's scan() API and it generated code to manage the result's pagination.
Diff review for api.py
A new function to scan the entire DynamoDB table. It correctly manages pagination.
It also generated the correct Lambda handler in 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!
Diffs with the changes in app.py
The new Lambda handler function
Lastly, I review and refine. Even though Amazon Q Developer generated most of the code correctly, not everything was perfect. I had to make a few minor adjustments. The 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.
Despite these two minor adjustments, I was able to deploy and test the code generated in less than 5 minutes.

Different capabilities and prices

Amazon Q Developer is free to use during the preview period. When it will be generally available, some functionalities will stay freely available, some other will be only accessible for our paying customers. We don't have the details yet, but capabilities like enterprise single sign-on with AWS Identity Center, guardrails, and customizations with your own code base will be available to subscribers only. Stay tuned for more news.

Try it today

Amazon Q Developer is a coding assistant (in preview) that helps you to be more productive during all phases of your software development lifecycle. It can analyze your code and answer questions about it, generate code snippets and an entire feature across multiple files. It can also modernize your old Java 8 code to a recent version of Java.
By using Amazon Q Developer, you can accelerate your feature development process, reduce the time spent on repetitive tasks, and concentrate on delivering innovative solutions that drive your business forward.

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.