The Known and Unknown of Amazon Q Developer

Lydia Dely - Sep 3 - - Dev Community

When Amazon Q Developer was first announced at the re:Invent 2023 in Las Vegas, NV, I felt like I had finally found what I had been looking for throughout my entire career as a DevOps Engineer in SRE. I couldn't wait to get my hands dirty and meet this amazing best friend of mine "in person" as I immediately knew this buddy (available 24/7 only for me) will save me hours of a day's work.

Amazon Q Developer is part of Amazon Q family which is generative AI powered assistant for software development (Amazon Q Developer) and company knowledge (Amazon Q Business), and in this blog, I'll dive deep into Amazon Q Developer.
By the way, did you know why it's called Q? Q is short for 'Question,' but it also calls to mind fictional characters from both Star Trek and James Bond who are known for their power, resourcefulness, and expertise.

Q personas

Statistics and Facts
Organizations want to enable employees with generative AI as productivity improves more than 30% on average.

More than 80% of enterprises will have used generative AI APIs or deployed generative AI-enabled apps by 2026.
*According to Gartner, October 2023

How much time do developers spend coding?
Software.com analyzed data from more than 250 000 developers worldwide over a 3 month period, and they found that:

  • the median time that developers spend writing or editing code in their IDE is less than an hour per day (52 minutes),

  • per work week, developers spend less than 4 1/2 hours writing code,

  • only 10 % of developers spend more than 2 hours per day coding.

Amazon Q Developer vs. Amazon CodeWhisperer

Maybe you think now: "OK, but isn't it the same as Amazon CodeWhisperer?"
All of the features of CodeWhisperer were moved to Amazon Q Developer in April 2024, that means CodeWhisperer is now Amazon Q Developer. In addition, there are some more features of Amazon Q Developer that weren't available in CodeWhisperer, such as:

  • chatting about your resources (list, describe, and get guidance based on resources in your AWS account),
  • chatting about your costs (retrieve and analyze cost data from AWS Cost Explorer),
  • diagnosing console errors (with Amazon Q),
  • transforming your code (with Amazon Q Developer Agent for code transformation),
  • developing software (with Amazon Q Developer Agent for software development).

CodeWhisperer is where we got started [with code generation], but we really wanted to have a brand - and name - that fit a wider set of use cases.
(Doug Seven, Director, GM @ AWS| AWS AI Developer Experiences)

Why to use Amazon Q Developer?

Amazon Q Developer is your assistant for the entire software development lifecycle (SDLC):

  • helps developers and IT profesionals with all of their tasks - from coding, testing and upgrading to troubleshooting, performing security scanning and fixes, optimizing AWS resources and creating data engineering pipelines,
  • helps developers build faster and more securely by generating code suggestions and recommendations in near real time,
  • converses with developers to explore new AWS capabilities, learn unfamiliar technologies, and architect solutions.

Core Use Cases

  • Retire tech debt at scale
    Modernize projects and upgrade language version and dependencies
    with Amazon Q Developer Agent for code transformation.

  • Drive developer productivity
    Get inline coding recommendations, summarize and document code,
    scan for security issues, diagnose and troubleshoot bugs, and write
    unit tests.

  • Improve security and code quality
    Ship more secure code with less effort with code scanning and automated code recommendation.

Subsription and Pricing

Amazon Q Developer comes in two different tiers of use:

  • a Free tier (has limitation how much you interact with the service, for example user can have only 50 chat interaction per month) ,

  • a Professional tier called Q Developer Pro (has no limitation or much higher limits and costs $19 a month per user).
    While this might sound high, you might find that the efficiency and productivity boost from using the service is worth the cost.

The main features, such as chat, code completions, security scans, and reference tracking are available in both.

You can find official Amazon Q Developer pricing page here.

You can also find some key differences between tiers below:
Key differences between tiers
*LOC is lines of code.

Amazon Q Developer Integration and Setup

Amazon Q lives where you work, right inside your IDEs (JetBrains, IntelliJ IDEA, VS and VSCode) or even in the CLI (on Mac).

Workflow is as follows:

  1. In your IDE download the extension for Amazon Q. It’s available as an extension or plugin for JetBrains IDEs and VSCode and as the AWS Toolkit extension in Visual Studio.

  2. Authenticate yourself. You can do this in two ways:

  • the first way, if you want to use the service for free, is to authenticate yourself through your Builder ID.

sign-in

  • the second way is through the Amazon Q Developer Pro plan, that requires your administrator to set up an identity for you in IAM Identity Center (AWS SSO):

Your Administration needs to provide you Start URL and Region:

Pro sign-in

authenticating

extension access

access given

Integrate Q Developer into your organization and gain organization-wide capabilities to control what your accounts, users, and groups do with the service.

Amazon Q Developer is available as a feature in several other AWS services:

  • AWS Lambda,
  • AWS Glue,
  • Amazon SageMaker Studio,
  • Amazon Q Business,
  • Amazon Q in Amazon CodeCatalyst,
  • Amazon Q in Amazon Connect,
  • Amazon Q in AWS Glue,
  • Amazon Q in Amazon QuickSight,
  • Amazon Q in VPC Reachability Analyzer,
  • Amazon Q in Amazon EC2,
  • Amazon Q in AWS Chatbot.

Amazon Q Developer "Magic"

Now that we are already familiar with Q Developer, I'll show the features I like the most.

Q Developoer in nut shell

Amazon Q Developer Agent for code transformation

With Code Transform feature you can:

  • complete language upgrades in a fraction of the time (currently supports only upgrades from Java 8 or 11 to Java 17),
  • enhance security posture and performance,
  • accelerate migration for Windows to Linux (coming soon).

How does /transform work?

Open Amazon Q chat in your IDE and type /transform. It will automatically prompt to upgrade Java as follows:

transform

transf2

Then you need to add path to your Java code and your transformation starts. It takes usually up to 30 mins.

/dev Looking at this project, can  you tell me which version of java this project is using?
/usr/libexec/java_home -V #Current java varsion
/usr/libexec/java_home -v 1.8 #Path to java8 (need to update ~/.zshrc or ~/.bash_profile #depends what you are using in your IDE terminal)
Enter fullscreen mode Exit fullscreen mode
#if MAC:
brew tap adoptopenjdk/openjdk
brew install --cask adoptopenjdk8
brew install maven
Enter fullscreen mode Exit fullscreen mode

Below you can see newly generated Code Transformation plan by Amazon Q and Code Transformation Summary by Amazon Q.

Image plan

Image plan2

Image summary

Image summary2

done

Java has been successfully upgraded even you can see some red flags.
The reason why upgrade succeeded is that during the process Gen AI fixed errors itself.

Amazon Q Developer Agent for code transformation

At the end we can review our pom.xml file before and after upgrade.

Image pom.xml

Amazon has migrated tens of thousands of production applications from Java 8 or 11 to Java 17 with assistance from Amazon Q Developer. This represents a savings of over 4,000 years of development work for over a thousand developers (when compared to manual upgrades) and performance improvements worth $260 million dollars in annual cost savings.

Amazon Q Developer Agent for software development

Amazon Q Developer has an agent for software development that can autonomously perform a range of tasks–everything from implementing features, to documenting and refactoring code, write and implement entire application features in minutes right from a simple natural language prompt in your IDE.
Developers can collaborate with the agent to review and iterate on the plan before the agent implements it, connecting multiple steps together and applying updates across source files, code blocks, and test suites.

Don't forget to verify your new created tests by following command:
mvn verify -f "PATH to pom.xml file" or as follows

Image mvn

How does /dev work?

Type /dev in IDE Q chat window and describe your task or issue in as much detail as possible.

readme

Image readme

Customers have reported efficiency improvements of 25% faster initial development and up to a 40% increase in developer productivity.

Security scanning and remediation to improve security and code quality

Security scans look for two main things, code security and code quality analysis:

  • For code security, it detects security vulnerabilities, scans for secrets, and assesses the security of your infrastructure as code files. You can scan an entire codebase or you can analyze your code as you write it using automatic scans. For example, it might detect resource leaks, SQL injection, hardcoded database connection strings, infrastructure as code misconfiguration, and more.

Run project scan

By clicking run project scans, it will perform the scan on your local project directory, scanning both the active file you have open and any dependency files within the project.

After it scans your code it will provide you with a list of security issues found in your files.

Security Scan

You can then select each problem detected in the list of issues. It will take you to the line in your code where it found the issue. You can then hover over the line and see more details about the problem.
If you press the “explain” button in the description, it will send the error to the Q chat window, where it will provide more details and potential fixes for the issue.

Sometimes you can see fix your issue button that is only available for certain issues. This option is an automatic code fix. The description will show that there’s a code fix available, and you can select this fix and it will directly update your code for you.

  • For code quality scanning, it looks for quality issues, such as performance and efficiency problems, AWS best practices, and more.

Explain code with conversational coding

This is especially useful for new developers who may have just inherited a legacy code base and who may have questions about what some of the various code modules do.

Q Explain

As you can see, there is much more you can do, such as:

  • Refactor Code for Code Readability: Improve the readability of a specific code module by refactoring it. Break down complex functions into smaller, more manageable units, and apply meaningful variable and function names for better clarity.
  • Optimising your code can help you towards cost and sustainability goals, and so may provide you with some good options.
  • and many more...

Q Explain generated answer

Amazon Q Developer in the AWS Management Console

Ask questions and get guidance from 17 years of AWS knowledge, best practices, well-architected advice (best practices, AWS WAF, Amazon EC2 instance optimization).

chat

You can also tetrieve and analyze cost data from AWS Cost Explorer (in preview).

Inline coding companion in IDE and CLI

How does this kind of coding work?

  • based on your natural language prompt,

Image prompt

  • generate up to 5 suggestions (Tab for accept, Arrows for moving between suggestions),

Image a

  • by pressing Enter Q Developer generates code for you based on your private repositories.

Image 1

Image 2

Image 3

Image 4

Plus
I find this very helpful because if I were to write the code manually, I would have had to look up some of the exact wording and syntax, which would have taken me much longer and potentially could have been less accurate.
Even though the generated code need some manual fixes to meet IaC best practices, it still can save developers a lot of time.

Cons
You really need to know where your code is going for Q Developer to be helpful, though. Sometimes, Q Developer might get it wrong, suggest something you're not looking for, or not follow common coding best practices, so you need to stay focused. This tool isn't a replacement for a programmer and to get the most out of it, you need to know what you want your code to look like so you can pick the right suggestions from Q Developer.

EC2 instance type suggestion

Amazon Q can help you with choosing right instance type while creating EC2 instance.

Image advice

Image b

Troubleshooting

  • Troubleshoot error (Amazon S3, AWS Lambda, Amazon EC2, Amazon Elastic Container Service)

This is my fave!
I have written basic lambda for creating object in S3 bucket with some text. While testing it I've got an error. What now?

Image l1

Just click on Diagnose with Q and Q will help to troubleshoot.
Image l2

So I was missing inline policy, fixed it and rerun test and test succeeded.
Image l3

  • VPC Reachability Analyzer

In case you are experiencing a network problem, you can ask in AWS Management Console for help. It will forward you to network troubleshooting chat (this feature is in preview in N.Virginia).

Image ra

Q will help you identify and fix the issue.

Image fix

Image w

  • Debug and optimize code with conversational coding

  • Helps you optimize your AWS resources and costs

Conclusion and Findings

I believe that Q will become part of every aspect of how developers complete development tasks. Across Research, Design, Test and Maintain. From how developers find the information they need and how they understand code, to writing the actual code and figuring out bugs, all the way to doing the code reviews. Q will even brainstorm with developers how to improve applications. With Q, developers can spend more time building, innovating and experimenting.

Like all new tools, we need to learn how to get the best of them.

PS: If you're looking for information on Amazon Q Developer Security and couldn't find it, it's because I wrote a separate article on the topic. Check it out here.
https://dev.to/lydiadely/the-security-of-amazon-q-developer-50g

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .