Lesson 1 of 1 Amazon Q Developer

Developing and Testing Code with Amazon Q Developer

This lesson explains how Amazon Q Developer, the AWS generative AI assistant for developers, supports development in IDEs, on the command line, in the AWS console and in chat apps. The exam guide includes skills for using it for development assistance (1.1.11) and for generating automated tests (3.3.6).

Learning outcomes

After completing this lesson, you will be able to:

  • Identify what Amazon Q Developer can do in the IDE, on the command line and in the console.
  • Explain why AI-generated code and tests must be reviewed before they are accepted.
  • Identify the review checks that catch common weaknesses in generated code.

What it can do

Amazon Q Developer is the AWS generative AI assistant for software development, and it works in several places.

In the IDE, it suggests code inline as the developer types, and its chat explains code, answers questions and generates new code from a description. In agentic mode it can plan and make changes across several files, run commands and iterate on the result. It can generate unit tests for existing code, write documentation and review code for problems before it is committed. The exam guide includes using such assistants for development assistance and for generating automated tests.

Its security scanning examines code for vulnerabilities, such as injection risks, and for hard-coded credentials, and proposes fixes. Its transformation capability upgrades applications, for example from an older Java version to a newer one, updating dependencies and code. In the AWS Management Console, Q Developer explains error messages, helps troubleshoot resources and answers questions about AWS services and the resources in the account. The following table summarises these capabilities.

WhereCapabilities
IDEInline code completions; chat that explains and generates code; agentic changes across several files; unit test generation; documentation; code reviews
IDE (security)Security scans that find vulnerabilities and hard-coded credentials and suggest fixes
IDE (transformation)Upgrades applications, for example to newer Java versions
AWS consoleExplains errors, helps troubleshoot resources and answers questions about AWS and your account

The following list describes how these capabilities are customised and administered.

  • Q Developer can use your codebase as context, and organisations can customise suggestions with their internal libraries.
  • Administrators manage access through IAM Identity Center and control data-sharing settings.

Using AI output responsibly

AI-generated code can be wrong in ways that look convincing: it may call an API that does not exist, handle errors poorly or introduce a security weakness. It should therefore be treated like code from a new team member. The developer reviews it, runs the unit tests and security scans on it, and merges it only when they understand what it does. Tests generated by an assistant also need review, because a test that merely confirms the code's current behaviour can lock in a bug.

Two further concerns are licensing and data. Suggestions can resemble open-source code whose licence imposes obligations; Q Developer's reference tracking flags such suggestions and shows the repository and licence, so the team can decide whether to accept them. Prompts and context are sent to the service, so secrets, credentials and sensitive customer data should be kept out of them, and administrators should review the organisation's data-sharing settings.

Worked example

Using generated code responsibly

A developer asks Amazon Q Developer to write a function that uploads files to S3. The suggestion works, and the developer reviews it before accepting:

Review questionFinding
Does it hard-code credentials or bucket names?Bucket name hard-coded; moved to an environment variable
Does it handle errors and retries?No; added handling for ClientError
Is it least privilege?Suggested IAM policy used s3:*; narrowed to s3:PutObject on one prefix
Is it tested?Asked Q to generate unit tests; reviewed and kept them
Any security findings?Ran a Q security scan on the project

AI assistants speed up writing code, but the developer remains responsible for its correctness and security, exactly as for code copied from any other source.

Check yourself

What should a developer do before committing code generated by Amazon Q Developer?

Show answer

Review and test it like any other code: check that it is correct and secure and follows the project's standards, run the tests, and scan it for security issues. Generated code can look right and still be wrong.

Exam Tips

Remember for the exam

  • To generate unit tests or review code with AI in the IDE, use Amazon Q Developer.
  • To scan code for vulnerabilities and secrets, use Q Developer security scanning.
  • To identify suggestions that resemble open-source code, use reference tracking.
  • Always review and test AI-generated code before merging it.