Getting Started with Amazon Q Developer Customizations

AWS Developers
17 Jul 202414:36

Summary

TLDRIn this engaging video, the narrator recounts a tale of rapid learning and code validation with Amazon Q Developer. After purchasing a book on microservices, they were tasked with implementing a new persistence layer. Initially, their PR was rejected due to non-compliance with company guidelines. Leveraging Amazon Q Developer's customization feature, they trained it on the company's coding style, leading to a successful code submission. Developer advocate Ricardo Ferreira demonstrates how to customize Amazon Q Developer with specific codebases for tailored recommendations, showcasing its potential for new developers and open-source contributions.

Takeaways

  • 📚 The video tells a story of a developer who had to quickly learn microservices with Spring Boot for a new task.
  • 🛠️ The developer's task was to implement a new persistence layer for an entity called 'Orders' using best practices and Spring Boot's support.
  • 🔍 To ensure adherence to coding standards, the developer used Amazon Q Developer for code validation and received feedback on company guidelines.
  • 🚫 The initial PR was rejected due to non-compliance with company implementation guidelines, such as base class inheritance and logging framework usage.
  • 🔄 The developer then utilized Amazon Q Developer's customization feature to align with the company's coding style, inspired by the Spring Petclinic sample application.
  • 👋 Ricardo Ferreira introduces the Amazon Q Developer customization feature, which trains the tool on a specific codebase for tailored recommendations.
  • 🔧 The customization feature is beneficial for new contributors to open source projects or developers working with proprietary APIs.
  • 📝 The process involves preparing code samples, creating a customization in Amazon Q Developer, and associating it with users or groups for access.
  • 🔗 The customization connects to code repositories or Amazon S3 buckets where the training code samples are stored.
  • ⏱️ Training the customization on code samples takes time, ranging from minutes to over an hour, depending on the complexity.
  • 📊 Amazon Q Developer provides a score to evaluate the quality of the code samples used for training, with scores ranging from 1 to 10.
  • 🎯 After activation, the customization influences the recommendations and code generation provided by Amazon Q Developer, ensuring they align with the trained codebase.

Q & A

  • What was the main challenge the developer faced in the script?

    -The developer faced the challenge of having their pull request (PR) rejected because the code did not follow the company's implementation guidelines, despite being technically correct.

  • What is the purpose of the Amazon Q Developer tool mentioned in the script?

    -Amazon Q Developer is a tool that helps developers by providing code recommendations and validations based on known coding best practices, and it can be customized to adhere to specific coding styles or company guidelines.

  • What is the Amazon Q Developer customization feature?

    -The Amazon Q Developer customization feature allows developers to train the tool using a specific codebase so that future recommendations and code generations align with the practices and styles of that codebase.

  • How did the developer initially validate their code?

    -The developer initially used Amazon Q Developer to validate their code, ensuring it was implemented based on known coding best practices.

  • What was the feedback given by the reviewers on the developer's PR?

    -The reviewers noted that while the code was technically correct, it did not follow some of the company's implementation guidelines, such as inheriting from the right base class and using the correct logging framework.

  • What sample application did the reviewers recommend the developer study?

    -The reviewers recommended studying the Spring Petclinic sample application, which is where the company's implementation guidelines come from.

  • How can Amazon Q Developer be trained to understand a specific codebase?

    -Amazon Q Developer can be trained by providing it with code samples from the specific codebase, either by pulling the code directly from a repository like GitHub or by uploading the samples to Amazon S3.

  • What is the significance of the numeric score provided by Amazon Q Developer after training?

    -The numeric score indicates the quality of the code samples provided for training, with 1 to 3 being poor, 4 to 7 fair, and 8 to 10 very good, reflecting how well the tool has learned from the samples.

  • What steps are involved in setting up the Amazon Q Developer customization feature?

    -The steps include preparing code samples, creating customization in Amazon Q Developer, providing the URI of the S3 bucket or repository, activating the customization, and associating it with users or groups to make it available for them.

  • How does the developer ensure that the customization is available in their IDE?

    -The developer needs to ensure that the customization is activated and then associated with the user or group that the developer's IAM belongs to, allowing access to the customization within the IDE.

  • What was the result when the developer used the customization feature in Amazon Q Developer?

    -The developer received code recommendations that were more aligned with the company's guidelines, including extending the correct base entity and using the appropriate logging framework.

Outlines

00:00

📚 Learning Microservices with Amazon Q Developer

The video script begins with the narrator recounting a personal experience where they had to quickly learn microservices using Spring Boot to complete a task. They purchased a book from Amazon and started implementing a new persistence layer for an entity called 'Orders'. After implementing the task according to best practices and using Amazon Q Developer for validation, their pull request was rejected due to not adhering to the company's specific implementation guidelines. The solution was to study the Spring Petclinic sample application and utilize the Amazon Q Developer's customization feature to align with the company's coding standards.

05:00

🛠️ Setting Up Amazon Q Developer Customization

The script continues with a detailed tutorial on setting up the Amazon Q Developer customization feature. The process involves creating a customization with a specific name, connecting to a repository or Amazon S3 bucket containing code samples for training, and activating the customization. The narrator, Ricardo Ferreira, explains the importance of providing a diverse set of code samples to train Amazon Q Developer to understand and replicate the coding style across various scenarios. The customization score is also discussed, which quantifies the quality of the training samples, and the process of associating the customization with users or groups to grant access.

10:01

🔑 Accessing and Utilizing Customization in IDE

The final paragraph of the script describes how to access the activated customization in an Integrated Development Environment (IDE) and use it to receive recommendations and code generations based on the trained code samples. The narrator demonstrates how to select the customization and test it by asking Amazon Q Developer to create a new entity class and repository implementation. The results show that the customization successfully provided recommendations that aligned with the company's coding standards, such as extending the base entity and using Log4J. The video concludes by encouraging developers to leverage the Amazon Q Developer customization feature to enhance their development process.

Mindmap

Keywords

💡Microservices

Microservices is an architectural style that structures an application as a collection of loosely coupled services, which implement business capabilities. In the video, the developer needs to learn about microservices with Spring Boot to implement a new task, highlighting its relevance to modern application development and the video's theme of rapid learning and application.

💡Spring Boot

Spring Boot is a popular Java-based framework used to create stand-alone, production-grade Spring applications with minimum configuration. The script mentions the developer buying a book about microservices with Spring Boot, indicating its significance in the context of building scalable and independent service components.

💡Persistence Layer

A persistence layer in software architecture is responsible for the data storage, retrieval, and search functionality. The video's main task involves implementing a new persistence layer for an entity called 'Orders,' demonstrating the core technical challenge the developer faces.

💡Entity Class

In object-oriented programming, an entity class represents a real-world entity or concept, often used in databases to define the structure of data. The script describes creating a new entity class as part of the task, which is a fundamental step in setting up the persistence layer.

💡JPA Annotations

JPA (Java Persistence API) annotations are a form of metadata used to declare persistence units and map object-relational structure in Java applications. The script refers to adding JPA annotations to the new entity class, which is essential for integrating the class with the database in a Spring Boot application.

💡Repository Pattern

The repository pattern is a design pattern used to separate the logic that retrieves and stores data in the database from the business logic that uses it. The script mentions implementing a repository pattern using Spring Boot support, which is a key practice in building a clean and maintainable codebase.

💡Amazon Q Developer

Amazon Q Developer, as depicted in the video, is a tool that helps developers by providing code recommendations and validations. The video's narrative revolves around the developer using Amazon Q Developer to validate and improve their code, emphasizing its utility in adhering to coding best practices and company guidelines.

💡Customization Feature

The customization feature in Amazon Q Developer allows the tool to be trained on a specific codebase, enabling it to provide recommendations and code generation aligned with the training code's style and practices. The video demonstrates how this feature can be used to tailor code suggestions to a company's or project's specific implementation guidelines.

💡Code Samples

Code samples are pieces of code that illustrate how to implement specific features or solve particular problems. In the script, the developer uploads code samples to Amazon S3 for training purposes, which is a critical step in customizing the Amazon Q Developer to understand and replicate the desired coding style.

💡PR (Pull Request)

A pull request (PR) is a feature in version control systems that allows developers to submit changes to a project, typically for review by other members of the team. The script mentions the developer's PR being rejected due to not following company guidelines, which leads to the exploration of Amazon Q Developer's customization feature.

💡Implementation Guidelines

Implementation guidelines are a set of rules or standards that dictate how code should be written in a particular project or company. The video discusses the developer's need to adhere to these guidelines, particularly by studying the Spring Petclinic sample application, which serves as the source of the company's coding standards.

Highlights

Developers sometimes need to quickly learn new skills to complete tasks, as illustrated by the story of using Amazon Q Developer.

The task was to implement a new persistence layer for an entity called Orders using microservices with Spring Boot.

Amazon Q Developer was used to validate code based on known coding best practices.

The initial PR was rejected due to not following the company's implementation guidelines.

The Spring Petclinic sample application was recommended as a reference for the company's coding guidelines.

Amazon Q Developer's customization feature allows training with a specific codebase for tailored recommendations.

Customization is beneficial for adhering to open source project guidelines or proprietary APIs.

Ricardo Ferreira introduces the Amazon Q Developer customization feature in a tutorial.

The tutorial covers setting up the customization feature from scratch and using it in an IDE.

Code samples for training can be pulled from a repository or uploaded to Amazon S3.

Different variations of the Spring Petclinic sample were used to train Amazon Q Developer.

The training process uses machine learning APIs and generative AI technologies.

A score is given by Amazon Q Developer to evaluate the quality of the provided code samples.

Customization needs to be associated with users or groups to be accessible.

Identity Center and AWS organization setup is required for associating customization with users or groups.

After activation, the customization influences the recommendations and code generations provided by Amazon Q Developer.

The customization feature allows for more specific and unique code recommendations based on learned code samples.

The video concludes by encouraging developers to start using the Amazon Q Developer customization feature.

Transcripts

play00:01

(pages rustling)

play00:04

- Every once in a while,

play00:05

developers have to learn something really quick

play00:07

so they can finish up a task.

play00:08

We're gonna tell the story

play00:09

about when that happened with me,

play00:11

and how Amazon Q Developer saved the day.

play00:15

Let's go. (lively music)

play00:18

It all started with me buying a book at Amazon

play00:20

about microservices with Spring Boot.

play00:23

I needed to learn this

play00:24

to be ready for a new task I was assigned to.

play00:28

The task was fairly simple,

play00:29

implement a new persistence layer

play00:31

for a entity of the system called Orders.

play00:34

All I needed to do was create a new entity class,

play00:37

add JPA annotations,

play00:39

and implement a repository pattern

play00:41

using the Spring Boot support for it.

play00:44

The stances had shown everything was working as expected.

play00:48

To make sure I was on the right track,

play00:50

I used an Amazon Q Developer to validate my code.

play00:54

Everything was implemented,

play00:55

based on known coding best practices.

play00:58

I filed a PR with my code

play01:00

and waited for the development team to review the task.

play01:03

(instrument squeaks)

play01:04

However, my PR got rejected. (instrument thuds)

play01:06

The reviewers shared that my code was technically correct,

play01:09

but it was not following

play01:11

some of the company's implementation guidelines.

play01:13

Details like inheriting from the right base class,

play01:16

usage of the correct login framework,

play01:18

was missing.

play01:20

They recommended studying

play01:21

the Spring Petclinic sample application,

play01:24

which is where the company's implementation guidelines

play01:26

come from.

play01:28

That's when I had the idea

play01:29

of using the Amazon Q Developer customization feature.

play01:34

Let me show you how I did it.

play01:36

Hi, there, my name is Ricardo Ferreira,

play01:38

and I'm a developer advocate here with AWS.

play01:41

I'm super excited to show you

play01:43

the Amazon Q Developer customization feature.

play01:46

So what this feature is about,

play01:47

it allows you to use a specific code base

play01:50

for training purposes

play01:51

so the next time you ask for a recommendation

play01:53

for an Amazon Q Developer,

play01:54

or perhaps even code generation,

play01:56

this is going to be provided,

play01:58

based on the training code.

play02:01

This is interesting for a lot of situations.

play02:03

For example, let's say you wanna start contributing

play02:05

to an open source project

play02:06

and you have to adhere to the implementation guidelines,

play02:09

so instead of spending weeks, and perhaps months,

play02:11

studying the code base,

play02:12

you can use that code base,

play02:14

send it to Amazon Q Developer,

play02:15

who is going to train for a couple of hours,

play02:18

and then you can start asking questions

play02:20

about how to do things,

play02:22

giving the specific code implementation practice

play02:25

of that sample code.

play02:27

The other situation could be

play02:28

you are the new developer

play02:29

of a team from a company that uses proprietary APIs,

play02:34

and obviously, those proprietary APIs

play02:36

are not available elsewhere,

play02:37

and Amazon Q Developer would never know

play02:40

how to handle them.

play02:42

So what you can do is ask your team leader

play02:45

to send a specific sample code to Amazon Q Developer,

play02:48

who is going to learn all the gimmicks

play02:51

and the implementation style

play02:52

from those APIs,

play02:53

and then the next time you ask for a recommendation

play02:54

about how to complete a task,

play02:56

guess what?

play02:57

Your recommendation is going to be custom-tailored

play03:00

specifically for you.

play03:02

In this video, I'm gonna show you

play03:03

how to set up from scratch

play03:05

the Amazon Q Developer customization feature,

play03:07

and also how you can use that customization

play03:11

specifically in your IDE

play03:13

to ask for recode recommendations.

play03:15

So without further ado, let's get to it.

play03:20

Your first step should be preparing your code samples

play03:22

for training purposes,

play03:23

and you can accomplish this in two ways.

play03:25

The first one is having Amazon Q Developer

play03:27

to pull the code directly from your repository,

play03:31

such as GitHub,

play03:31

or you can upload those code samples to Amazon S3,

play03:35

which is going to be the strategy I'm going to use here now.

play03:37

So as you can see here,

play03:38

I have this bucket called spring-petclinic-code,

play03:41

and then inside that folder,

play03:43

I've created a subfolder called code-content,

play03:45

where I've uploaded all my code samples

play03:48

that I want to use for training purposes.

play03:51

So in this scenario,

play03:52

I'm using famous Spring Petclinic sample,

play03:57

but as you can see here,

play03:58

I've provided different variations of the same sample.

play04:01

So the first one is using angular

play04:03

as the frontend framework,

play04:05

same backend, but a different frontend,

play04:08

and then the same backend,

play04:09

but using reactjs as frontend,

play04:11

and also a complete 100% sample of the same code

play04:16

using the rest APIs

play04:17

for communicating across the layer.

play04:18

So this is important

play04:20

for Amazon Q Developer to understand,

play04:23

in a more specific manner,

play04:25

how you are going to leverage your coding style,

play04:28

and how it can reuse it across multiple scenarios.

play04:31

When you start asking questions

play04:33

and you're creating your prompt

play04:35

about how the code should be generated,

play04:37

or even code suggestions,

play04:39

this is going to be extremely important

play04:41

about how Amazon Q Developer is going to,

play04:43

"Oh, okay, I'm going to match your intentions

play04:46

to what I have learned."

play04:48

Once you have uploaded all your code samples,

play04:51

you can go to Amazon Q Developer

play04:54

and then start creating your customization.

play04:57

So how you can do this,

play04:58

you're going to use this menu here,

play05:00

and then the customization feature,

play05:02

which is currently in preview,

play05:03

but probably, by the time you are watching this video

play05:06

it's going to be generally available for you to use,

play05:10

but the workflow is going to be virtually the same.

play05:13

So you're going to use this button here,

play05:15

Create Customization,

play05:16

and then you are going to name your customization.

play05:19

And this case, I'm gonna call spring-petclinic

play05:22

to remind me that all this training purpose

play05:25

is based on the famous Spring Petclinic code samples.

play05:28

And then you can use different connection providers.

play05:31

In this case, CodeStar, we can connect

play05:34

to different repositories such as GitHub,

play05:36

or you can select Amazon S3,

play05:38

which is going to be this case for this demo.

play05:40

So in here, you have to provide the URI of your S3 buckets

play05:45

to which you can click here, Browse S3,

play05:47

and then you can simply select the URI

play05:51

that you want to use.

play05:52

So in this case, I'm going to use this URI over here

play05:55

from the code-content,

play05:57

you're gonna click copy S3 URI,

play05:59

and then going back to Enter S3 URI,

play06:02

I'm going to simply paste here the content.

play06:04

Once you have done this, you can simply go,

play06:07

scroll down and click on Create Customization.

play06:11

Before I do this, just a heads-up

play06:12

that you can also use this feature called Log Deliveries,

play06:17

which is a way for you to kind of follow up

play06:20

and perhaps troubleshoot

play06:21

the whole training purposes,

play06:23

because as Amazon Q Developer is trained,

play06:26

it's going to flush events to whatever you set here.

play06:28

So in this case, I'm going to set for CloudWatch logs

play06:31

so we can actually perhaps go there

play06:34

if something goes wrong,

play06:36

and then follow up

play06:37

about what was the flow of the training purposes.

play06:40

Once you have done this,

play06:41

you can simply create customization.

play06:43

So how this works,

play06:46

because the training process, it's something

play06:48

that is going to leverage machine learning APIs

play06:51

and all the fancy generative AI technologies

play06:56

that Amazon is backed behind Amazon Q Developer.

play07:00

And then this is going to take a little bit of time.

play07:02

So this is not something

play07:03

that we're talking about, like, a couple of minutes,

play07:05

or perhaps ten minutes.

play07:07

In my tasks here, it usually takes from four or five minutes

play07:11

to one hour and a half.

play07:12

So what's gonna happen now

play07:14

is that I am going to fast-forward

play07:17

to the point where this process has finished.

play07:20

So see you in a minute.

play07:24

All right, so our customization has been properly created,

play07:27

and then we can go ahead and do the review of the score.

play07:30

So what is the score?

play07:32

It's a numeric value that Amazon Q Developer gives you

play07:36

to quantify how good or how bad your code samples are.

play07:40

So in order to review this,

play07:42

you are going to click here on this I button,

play07:45

and then you are going to use the scoring model number.

play07:48

So 1 to 3, it means

play07:49

that you've provided a poor set of code samples,

play07:52

4 to 7 is fair,

play07:53

it means that you can go ahead and activate,

play07:55

and chances are that you are going to receive

play07:57

some good recommendations from that,

play08:00

and 8 to 10 is very good,

play08:02

it means that there's no doubt

play08:04

that whatever recommendations are provided

play08:06

are going to provide some benefit for you.

play08:08

So in this case, we've ended up

play08:10

with the evaluation score of 5,

play08:12

which is in a range of fair,

play08:14

so we can actually go ahead and use this revision.

play08:17

So to activate this revision,

play08:19

just scroll down to the bottom of the page,

play08:20

and you are going to select the version

play08:23

that you are going to use.

play08:25

This is important, because once given,

play08:27

customization can have multiple versions,

play08:29

and this is important

play08:30

because even after you reactivate,

play08:33

you might decide to provide more code samples

play08:35

for the same customization,

play08:37

so you're gonna end up with multiple revisions.

play08:39

So I'm going to select this version and click on Activate.

play08:44

Now that your customization has been activated,

play08:47

it is ready to be used.

play08:48

However, there's one thing

play08:50

that I would like you to keep in mind

play08:51

before trying to use that customization.

play08:54

If you jump to your ID right now,

play08:56

and if you go to the Select Any Custom customization,

play08:59

you are going to see this message,

play09:00

"You don't have access to any Amazon Q customization,"

play09:04

and the only one available to you

play09:05

is going to be the Amazon Q foundation,

play09:07

which is the default one

play09:08

that comes out of the box with Amazon Q Developer.

play09:11

So why this happens,

play09:12

because the customization has to be associated

play09:16

with users and/or groups,

play09:19

so it becomes available to them.

play09:21

So what's gonna happen now

play09:22

is that you need to go back to your customization

play09:25

and then scroll down here to the bottom of the page

play09:28

and go to this tab, Users and Groups.

play09:30

So we're gonna click on here,

play09:32

and then either you are going to select specific individuals

play09:36

from your organization,

play09:37

or you can select specific groups

play09:39

that comprises one or multiple users.

play09:42

So in my case here, I'm going to select a group

play09:45

that I call StandardDeveloper,

play09:47

and this group is associated

play09:49

with multiple developers in my organization,

play09:52

and I'm going to add this group to my customization.

play09:55

So what's gonna happen right now

play09:57

is that any user that belongs to that organization

play10:00

is gonna be able to not only see, but to leverage

play10:04

that customization

play10:05

and any information that pertain

play10:08

from the code samples that was used for training purposes.

play10:12

If you are wondering

play10:13

where those users and/or groups are coming from,

play10:17

they are coming from the identity center

play10:19

that is associated

play10:20

with your Amazon Q Developer professional subscription.

play10:24

So if you have never done this before

play10:26

and you want to learn how to set up this,

play10:28

you can follow up this blog post that I've wrote

play10:31

that teaches you how to set up your own AWS organization,

play10:35

the Identity Center,

play10:36

and how to activate the pro subscription

play10:39

of Amazon Q Developer.

play10:40

In this tutorial, I show you everything about,

play10:43

since the creation of the organization,

play10:45

how to actually set the right permissions,

play10:48

the IAM roles for your AWS users

play10:51

so everything works flawlessly.

play10:53

The link is on the description below.

play10:57

Now that the customization has been associated

play10:59

with the proper group,

play11:01

I'm going to try one more time

play11:02

to select the customization from my ID.

play11:05

So I'm gonna click Amazon Q Developer

play11:07

and then select customization.

play11:08

So right now, you can see

play11:10

that the spring-petclinic customization is available to me.

play11:15

Remember that this is only available

play11:16

because the user IAM connected in the IDE

play11:19

belongs to that group called StandardDeveloper

play11:22

that I've associated with the customization.

play11:25

So I'm going to select this customization,

play11:27

and from this point on,

play11:29

all the recommendations and code generations

play11:31

that Amazon Q Developer is going to give me

play11:33

is going to be based on the learnings

play11:36

for the code samples that was used for training purposes.

play11:41

Let's now test if Amazon Q Developer is gonna be able

play11:44

to provide me with the recommendation I am expecting

play11:47

since I am using the customization created.

play11:50

So I am going to repeat the same prompt

play11:53

that I've used before

play11:54

to create me a new entity class,

play11:56

and a repository implementation using based on JPA.

play11:59

So I'm gonna hit Enter, and let's see how that goes.

play12:03

So let's review the code provided here as a suggestion.

play12:07

I'm gonna go back real quick,

play12:08

and then let's start by reviewing the entity implementation.

play12:12

So the first thing I've noticed

play12:13

is that now, it is extending base entity.

play12:17

This was part of the feedback provided on the PR,

play12:20

so it's good.

play12:22

It seems to be following the expected best practices,

play12:25

and also, it's using Log4J

play12:29

as the implementation framework,

play12:30

so it's no longer using Java Logging,

play12:33

which was also something that I did wrong

play12:37

when I submitted the PR originally.

play12:40

And for the repository implementation,

play12:43

it seems also to be using the right interface.

play12:46

So overall, I think it worked,

play12:49

because it seems to be using everything

play12:52

that was provided in the code samples

play12:55

as a reference about how the code should look like.

play12:59

So this is the proof

play13:00

that when you're using Amazon Q Developer,

play13:02

the customization feature is going to allow you

play13:05

to create more specific and unique recommendations

play13:09

for you to use and leverage in your code.

play13:13

So how did you like the new, exciting

play13:16

Amazon Q Developer customization feature?

play13:18

It's pretty awesome, right?

play13:20

It is almost as if it was magic,

play13:22

because when you ask for code recommendations

play13:25

or code generation

play13:26

Amazon Q Developer is able

play13:27

to provide exactly what you need.

play13:31

But guess what? There's no magic.

play13:33

All you gotta do is to provide a set of code samples

play13:36

for training purposes,

play13:37

and from that point on,

play13:38

Amazon Q Developer is able

play13:41

to not only learn what you need,

play13:43

but also to put in a context.

play13:45

Given your prompts, it's going to be able to provide you

play13:50

I highly encourage you to start developing

play13:53

with Amazon Q Developer customization feature.

play13:56

There have been never a better time to be a builder.

play14:05

(no audio)

play14:12

You're still here?

play14:17

It's over.

play14:21

Go build something.

play14:26

Go.

play14:32

(door slams) (quirky noise imitation)

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
Amazon Q DeveloperCode CustomizationSpring BootMicroservicesDeveloper AdvocateCoding Best PracticesMachine LearningAI TechnologyIDE IntegrationDeveloper Tools
Benötigen Sie eine Zusammenfassung auf Englisch?