Organizations can optimize their migration and modernization tasks by streamlining the containerization course of for legacy functions. With the appropriate instruments and approaches, groups can remodel conventional functions into containerized options effectively, lowering the time spent on guide coding, testing, and debugging whereas enhancing developer productiveness and accelerating time-to-market. Throughout containerization initiatives, organizations can handle compatibility, dependencies, and configurations effectively utilizing automated instruments and finest practices, serving to to maintain tasks on schedule and inside funds parameters. Growth groups can focus extra on innovation by automating routine duties corresponding to utility structure evaluation, deployment script creation, and atmosphere configuration, resulting in smoother transitions throughout totally different phases of the modernization journey.
On this submit, you’ll be taught how one can use Amazon Q Developer command line interface (CLI) with Mannequin Context Protocol (MCP) servers integration to modernize a legacy Java Spring Boot utility operating on premises after which migrate it to Amazon Internet Providers (AWS) by deploying it on Amazon Elastic Kubernetes Service (Amazon EKS). The Amazon Q Developer CLI helps automate frequent duties within the modernization course of. You’ll introduce chaos into the system after profitable modernization. Then you definately’ll troubleshoot it utilizing Amazon Q Developer CLI. You’ll carry out all these actions utilizing pure language prompts with out writing code.
Amazon Q Developer goes past coding to assist builders and IT professionals with lots of their duties—from coding, testing, and deploying to troubleshooting, performing safety scanning and fixes, modernizing functions, optimizing AWS assets, and creating knowledge engineering pipelines. Amazon Q for the command line integrates contextual info, offering Amazon Q with an enhanced understanding of your use case, enabling it to offer related and context-aware responses. The MCP is an open commonplace that permits AI assistants to work together with exterior instruments and providers. It defines a structured method for AI fashions to find obtainable instruments, request instrument execution with particular parameters, and obtain and course of instrument outcomes. You’ll use MCP to increase the capabilities of Amazon Q Developer CLI by connecting it to customized instruments and providers.
Though we’re showcasing the potential of Amazon Q Developer CLI on this finish -to-end migration and modernization journey, in the event you’re utilizing one of many supported built-in growth environments (IDEs) and Java variations, you should utilize the /remodel
command to carry out the step 2. For extra info, go to Upgrading Java variations from Amazon Q Developer.
Resolution overview
MCP servers act like a common connector for AI fashions, enabling them to work together with exterior techniques, fetch dwell knowledge, and combine with numerous instruments seamlessly. This permits Amazon Q to offer extra contextually related help by accessing the knowledge it wants in real-time. The next structure diagram reveals how Amazon Q Developer CLI connects to exterior knowledge sources by MCP servers.
The next is a abstract of the performance of the structure:
- You’ll configure MCP consumer in Amazon Q Developer CLI utilizing mcp.json file.
- You’ll log in to Amazon Q Developer CLI and ask queries in pure language.
- Relying in your question, Amazon Q Developer decides which MCP server(s) that you just configured or current instruments to invoke for performing the duty. At current, Amazon Q Developer helps stdio native MCP servers solely.
- The MCP server interacts with the respective exterior system to get the dwell knowledge that’s utilized by Amazon Q to carry out the required activity.
The answer follows these high-level steps, as proven within the following graphic:
- Create legacy Java Spring Boot utility
- Improve Java and Spring Boot variations
- Containerize the upgraded utility
- Deploy the appliance on Amazon EKS
- Introduce chaos
- Troubleshoot and repair
Conditions
You could have the next configured earlier than you begin establishing the demo:
Configure MCP in Amazon Q Developer CLI
MCP configuration in Amazon Q Developer CLI is managed by JSON information. You’ll configure Amazon Bedrock EKS MCP Server. On the time of this writing, solely the stdio transport is supported in Amazon Q Developer CLI.
Amazon Q Developer CLI helps two ranges of MCP configuration:
- World configuration:
~/.aws/amazonq/mcp.json
– Applies to all workspaces - Workspace configuration:
.amazonq/mcp.json –
Particular to the present workspace
On this demonstration, we’re utilizing workspace configuration, however you should utilize both of them. Observe these steps:
- Create a brand new workspace folder and inside that folder create
.amazonq/mcp.json
file with the next content material:
- Open a terminal, navigate to the workspace folder that you just created in step 1, and enter the next command to log into Amazon Q Developer CLI. Observe the instruction on the display to login to Amazon Q Developer on the command line:
q login
- Provoke the chat session by coming into
q
after which/instruments
to validate that the Amazon EKS MCP server is configured, as proven within the following screenshot. By default, it gained’t be trusted.
Migrate and modernize Java Spring Boot utility
Emigrate and modernize a Java Spring Boot utility, full the steps within the following sections.
Create legacy Java Spring Boot utility
To create a legacy Java Spring Boot utility, you first construct a legacy Java 8, Spring Boot 2.3.x bookstore utility, which you’ll modernize and migrate to AWS. Return to Amazon Q Developer CLI and use pure language question to create the previous utility. Observe these steps:
- You should utilize your individual phrases or use the next immediate to generate the code. The immediate generates the pattern payloads to check the appliance. Make a copy of these payloads for later use. To grasp extra about finest practices for immediate engineering, consult with Mastering Amazon Q Developer Half 1: Crafting Efficient Prompts within the AWS DevOps & Developer Productiveness Weblog.
- Present approval to generate the legacy utility.
Amazon Q Developer CLI generates the working code with Java 8 utilizing Spring Boot 2.3.x framework.
- Discover the generated undertaking information and validate the Java and Spring Boot variations.
- Present the next immediate to run the appliance.
- Check the microservice utilizing a REST API consumer or utilizing curl command. You may as well ask Amazon Q Developer CLI to check the appliance and repair errors, making ready a totally practical service!
- After testing is full, cease the microservice. Your legacy utility is now able to be modernized.
- (Optionally available) Ask Amazon Q Developer CLI to generate a part and sequence diagram for the legacy utility.
Seek advice from the next video for a fast demo.
Improve Java and Spring Boot variations
Improve the legacy Java Spring Boot utility that you just created within the earlier step utilizing Amazon Q Developer CLI.
As talked about beforehand, in the event you’re utilizing one of many supported built-in growth environments (IDEs) and Java variations, you should utilize the /remodel
command inside your IDE to carry out this step.
- Use your individual phrases or the next immediate to replace the legacy utility. Amazon Q Developer performs required adjustments in each maven pom.xml and Java code to improve to Java 21 and Spring Boot 3.5.0. It builds the code after the improve. If the construct fails, then Amazon Q Developer iteratively tries to repair the construct by making use of vital code and configuration adjustments.
- After the undertaking improve is full, validate the pom.xml for Java and Spring Boot variations. Discover the adjustments made to the Java code. The next instance code from pom.xml validates the up to date Java and Spring Boot variations:
- Present the next immediate to run the appliance:
- Retest the microservice and make it possible for it’s nonetheless working as anticipated. You should utilize Amazon Q Developer CLI to check, troubleshoot, and repair the upgraded utility, if wanted.
- After testing is full, cease the microservice. Your legacy utility is now upgraded to Java 21 and Spring Boot 3.5.0.
Seek advice from the next video to know extra.
Containerize the upgraded utility
Containerize the appliance in order that the appliance could be run on each x86_64 and ARM64 {hardware}:
- Use your individual phrases or the next immediate to create docker picture for the appliance Amazon Q Developer creates the Dockerfile to your utility and builds it to create pictures that may be run on x86_64 and ARM64 techniques.
- Discover and validate the Dockerfile created by Amazon Q Developer to your utility.
- Present the next immediate to run the appliance in your native system:
- Check the microservice utilizing a REST API consumer or utilizing curl command. When it’s finished, cease the docker container utilizing the next immediate:
Your utility is now containerized and examined on the native system. The heavy lifting of the making the code and configuration adjustments, updating the dependency, and writing Dockerfile is finished by Amazon Q Developer.
Seek advice from the next video for a demo.
Deploy the appliance on Amazon EKS
Deploy the containerized utility on Amazon EKS. To take action, create a brand new EKS cluster and use Helm Chart to deploy the appliance. Amazon Q Developer CLI makes use of Amazon EKS MCP server to carry out a few of these actions. Amazon Q Developer CLI makes use of the default profile except instructed to make use of one other.
- Use your individual phrases or the next immediate to push the docker picture to an Amazon Elastic Container Registry (Amazon ECR) repository:
- Present the next immediate to deploy the picture into a brand new EKS cluster utilizing Helm chart:
- Enter the next command within the Amazon Q chat session to test the appliance pods are operating. Alternately, ask Amazon Q chat to get the pods utilizing kubectl:
- Check the microservice once more to make it possible for the deployed utility is working as anticipated.
Your containerized utility is now operating efficiently on the EKS cluster. This completes the migration and modernization of the legacy Java Spring Boot utility.
Seek advice from the next video for a demo.
Introduce chaos
In real-world advanced functions, whereas Amazon Q Developer performs the heavy lifting of upgrading, containerizing, and deploying the appliance on AWS, you may encounter application-specific environmental points. On this step, you’ll simulate an out-of-memory (OOM) difficulty by introducing chaos into the system. You may introduce the chaos utilizing one of many under choices:
You may introduce the chaos utilizing AWS Fault Injection Service EKS Pod actions or by following the under steps:
- Apply a patch deployment to cut back reminiscence allocation:
- Introduce stress:
Wait till the pods crashes with an OOM error.
Seek advice from the next video for a demo.
Troubleshoot and repair
Troubleshoot the difficulty utilizing Amazon Q Developer CLI with EKS MCP server:
- Use your individual phrases or the next immediate to start out troubleshooting the appliance utilizing Amazon Q Developer CLI. It would take a number of iterations to establish the foundation trigger and potential repair.
- After you validate that Amazon Q Developer CLI can establish the foundation reason for the difficulty and recommend a possible answer, present approval to let it repair the difficulty:
- Validate the appliance is operating positive by checking the pod standing and invoking the APIs utilizing curl command or a REST API consumer.
Modifications associated to safety in Amazon EKS are out of scope for this submit. Observe the safety finest practices earlier than shifting into manufacturing. Utilizing Amazon Q Developer, you’ll be able to speed up the migration and modernization journey, however because the proprietor of the code, you might want to do the due diligence on the adjustments.
Because of the inherent nondeterministic nature of the FMs, the responses of the Amazon Q Developer CLI may not be precisely similar as these proven within the demo. You could modify the prompts accordingly.
Seek advice from the next video for a demo.
Clear up
Correctly decommissioning provisioned AWS assets is a vital finest follow to optimize prices and improve safety posture after concluding proofs of idea and demonstrations. Observe the steps to delete the assets created in your AWS account:
- Use your individual phrases or the next immediate to establish the assets that have been created throughout this demonstration.
- Fastidiously validate whether or not Amazon Q Developer has appropriately recognized solely the specified assets to be deleted after which present approval. If unsure, manually delete them.
- Delete the
.amazonq/mcp.json
file out of your workspace folder to take away MCP configuration for Amazon Q Developer CLI.
Conclusion
On this submit, you realized how Amazon Q Developer CLI with Amazon EKS MCP server integration interprets pure language queries, mechanically converts them into applicable instructions, and identifies the required instruments for execution. You upgraded a legacy Java Spring Boot utility, then containerized it to help deployment on multi-architectural computes. You deployed the appliance on Amazon EKS, launched chaos, and resolved the problems utilizing pure language queries. Utilizing Amazon Q Developer CLI, you’ll be able to enhance your developer’s productiveness many occasions over. We encourage you to discover further use circumstances and share your suggestions with us!
Additional research
For extra info on Amazon Q Developer CLI and AWS MCP servers:
In regards to the authors
Biswanath Mukherjee is a Senior Options Architect at Amazon Internet Providers. He works with massive strategic clients of AWS by offering them technical steerage emigrate and modernize their functions on AWS Cloud. Along with his in depth expertise in cloud structure and migration, he companions with clients to develop modern options that leverage the scalability, reliability, and agility of AWS to fulfill their enterprise wants. His experience spans numerous industries and use circumstances, enabling clients to unlock the complete potential of the AWS Cloud.
Upendra V is a Senior Options Architect at Amazon Internet Providers, specializing in Generative AI and cloud options. He helps enterprise clients design and deploy production-ready Generative AI workloads, implement Massive Language Fashions (LLMs) and Agentic AI techniques, and optimize cloud deployments. With experience in cloud adoption and machine studying, he allows organizations to construct and scale AI-driven functions effectively.