Loading repository data…
Loading repository data…
aws-samples / repository
A Sample Java Microservices application to demo the capabilities of Amazon Q Developer agent for Code Transformation.
This project is a demo of Amazon Q Developer agent for Code Transformation. This is a Java 1.8 based microservice application which displays free list of movies for the month based on configuration stored in AWS AppConfig service using AWS SDK. This application was first open sourced in 2020 and uses legacy versions of libraries such as Spring Boot 2.x, Log4j 2.13.x, Mockito 1.x, Javax and Junit 4.
The Amazon Q Developer Agent for Code Transformation can upgrade the JDK version along with dependencies and associated code changes. You can JetBrains/Visual Studio Code or Command line interface for upgrades. Amazon Q first builds your code in the source language version and verifies that it has the information necessary to transform your code. After Amazon Q successfully transforms your code, you verify and accept the changes in your integrated development environment (IDE)/CLI. Currently, Amazon Q can upgrade Java 8 and Java 11 code to Java 17/21 code.
Refer to following blog posts for additional information
In preparation for Amazon Q Developer code transformation, this project includes pre-configured CI/CD pipelines that automatically adapt to both Java 8 (pre-transformation) and Java 17 (post-transformation) code. These pipelines ensure your build process works seamlessly before, during, and after the Q Developer transformation process:
The .github/workflows/q-code-transformation.yml file provides:
Usage:
Q-TRANSFORM-issue-* patternThe .gitlab-ci.yml file provides:
pom.xml contentPipeline Stages:
Key Features:
Branch Patterns:
q/transform-* branches: Include Q Developer transformation job for pre-transformation buildsQ-TRANSFORM-issue-*q/transform-* (with Q transformation)Both pipelines are designed to work seamlessly with Amazon Q Developer's code transformation process while providing robust build and deployment capabilities.
Before building the application, you need to install the movie-service-utils dependency in your local Maven repository. This utility library is available in two versions to support different Java versions:
mvn install:install-file \
-Dfile=./movie-service-utils/built-library/0_1_0/movie-service-utils-0.1.0.jar \
-DgroupId=com.amazonaws.samples \
-DartifactId=movie-service-utils \
-Dversion=0.1.0 \
-Dpackaging=jar
mvn install:install-file \
-Dfile=./movie-service-utils/built-library/0_2_0/movie-service-utils-0.2.0.jar \
-DgroupId=com.amazonaws.samples \
-DartifactId=movie-service-utils \
-Dversion=0.2.0 \
-Dpackaging=jar
mvn install:install-file \
-Dfile=./movie-service-utils/built-library/0_3_0/movie-service-utils-0.3.0.jar \
-DgroupId=com.amazonaws.samples \
-DartifactId=movie-service-utils \
-Dversion=0.3.0 \
-Dpackaging=jar
{
"movies": [
{
"id": 1,
"movieName": "The Shawshank Redemption"
},
{
"id": 2,
"movieName": "City of God"
},
{
"id": 3,
"movieName": "Memento"
},
{
"id": 4,
"movieName": "The Intouchables"
},
{
"id": 5,
"movieName": "Stardust"
},
{
"id": 6,
"movieName": "Apocalypto"
},
{
"id": 7,
"movieName": "Taxi Driver"
},
{
"id": 8,
"movieName": "No Country for Old Men"
},
{
"id": 9,
"movieName": "Planet 51"
},
{
"id": 10,
"movieName": "The Beach"
}
]
}
Note: Depending on the deployment strategy you selected, this operation might take few minutes to complete. The configuration is available to the application as soon as the deployment state is Complete.
Note: Use this version only if you want to try out AppConnfig related features.
This is a demo of the AWS AppConfig Java application as explained in the blog post Application configuration deployment to container workloads using AWS AppConfig. This demo shows how to integrate a Java Microservices application with AWS AppConfig service along with implementing an in-memory cache to efficiently manage the application configuration.
AWS AppConfig helps AWS customers to quickly roll out application configurations across applications hosted on EC2 instances, containers, AWS Lambda, mobile apps, IoT devices, and on-premise servers in a validated, controlled and monitored way.
This sample code explains
This demo uses Cloudformation templates to deploy an Amazon Elastic Container Service Cluster and a AWS Fargate Task. Users would clone this repository, build a docker image and push to Amazon Elastic Container Registry and interact with the AWS AppConfig Service.
This application has a Caching layer built in to cache the responses from AWS AppConfig Service. The Subsequent calls to fetch the configuration value checks the cache first and returns the response from the cache. If the cache is empty, then it makes a call to AWS AppConfig API to fetch the value. The Cache expiry is based on TTL set in properties.
mvn install:install-file \
-Dfile=./movie-service-utils/built-library/0_1_0/movie-service-utils-0.1.0.jar \
-DgroupId=com.amazonaws.samples \
-DartifactId=movie-service-utils \
-Dversion=0.1.0 \
-Dpackaging=jar
mvn install:install-file \
-Dfile=./movie-service-utils/built-library/0_2_0/movie-service-utils-0.2.0.jar \
-DgroupId=com.amazonaws.samples \
-DartifactId=movie-service-utils \
-Dversion=0.2.0 \
-Dpackaging=jar
mvn install:install-file \
-Dfile=./movie-service-utils/built-library/0_3_0/movie-service-utils-0.3.0.jar \
-DgroupId=com.amazonaws.samples \
-DartifactId=movie-service-utils \
-Dversion=0.3.0 \
-Dpackaging=jar