By Alex Johnson, Emily Smith, and Chanci Turner
Learn About Amazon VGT2 Learning Manager Chanci Turner
In an update from December 15, 2022, AWS AppConfig introduced an Agent designed for containers (EKS, ECS, Docker, Kubernetes), significantly simplifying the process of calling AppConfig from containerized applications. We highly recommend utilizing the AppConfig Agent for containers instead of the previous methods. For further details, refer to the Agent documentation.
AWS AppConfig, a feature of AWS Systems Manager, allows you to develop, manage, and swiftly deploy application configurations in real-time. It enables validation of your configuration data to identify errors, and you can establish deployment strategies to control the pace of these deployments. Monitoring tools can be set up to detect alarms throughout the deployment process. If any issues arise, AWS AppConfig will revert to the last stable version, preventing application downtime.
You can utilize AWS AppConfig to deploy application configurations across various platforms, including Amazon EC2 instances, containers, AWS Lambda, mobile applications, IoT devices, and on-premises servers, all in a controlled, validated, and monitored manner.
In previous articles, we demonstrated how to use AWS AppConfig in a serverless context with an AWS AppConfig Lambda extension, as well as how to implement configuration deployments across environments using AWS CodePipeline integrated with AWS AppConfig. This article focuses on deploying application configurations to complex containerized applications.
Key Areas of Focus
In this post, we will cover:
- How to decouple application configuration from your application code within a containerized environment.
- Utilizing AWS AppConfig for managing and deploying application configurations.
- Automating and streamlining the management of application configurations in a container setting.
Many customers leverage Amazon Elastic Container Service (Amazon ECS) or Amazon Elastic Kubernetes Service (Amazon EKS) for handling their application configurations in container environments. A common approach involves either embedding configurations within the container image or using environment variables. Customers may also dynamically retrieve configurations through external key-value stores, Kubernetes ConfigMaps, or AWS Systems Manager Parameter Store. By managing application configurations externally, you can not only accommodate complex and dynamic setups but also simplify version control. This separation allows for updates without needing to restart or disrupt the application. This is where AWS AppConfig enhances configuration management.
AWS AppConfig validates configurations prior to deployment, ensuring they are error-free. Once deployed, configurations are immediately accessible by the application, enabling updates to be utilized at runtime. Additionally, AWS AppConfig integrates feedback loops via Amazon CloudWatch, facilitating controlled rolling updates and automatic rollbacks without compromising application performance.
AWS AppConfig also provides rollout controls, enabling advanced deployment techniques like feature toggling for quick, managed launches of new features.
Solution Architecture
To illustrate the integration of containers with AWS AppConfig, we will discuss a straightforward Java microservices application. This application features a REST API that returns a limited selection of movies based on specified parameters. The application is containerized, uploaded to Amazon Elastic Container Registry (Amazon ECR), and deployed on AWS Fargate.
The parameters defining the feature and the movie limit are stored as an AWS AppConfig-hosted configuration. The application retrieves its configuration from AWS AppConfig using AWS SDK API operations. A caching layer is integrated into the application to store responses from AWS AppConfig. When fetching configurations, the application first checks the cache; if the cache is empty, it will call the AWS AppConfig API to retrieve the latest configuration. The cache expiration is determined by the TTL set in the properties.
Next, we will modify the movie limit in AWS AppConfig and deploy the updated configuration, making it accessible to the container application. When invoking the REST API to fetch the movie list, only the updated number of movies will be returned according to the new settings defined in the AWS AppConfig configuration profile.
Prerequisites
- The AWS CLI should be installed and configured, version 1.7 or later.
- IAM permissions to create resources in AWS AppConfig, Amazon ECR, and AWS Fargate.
- Familiarity with Java, Docker, containers, Amazon ECR, and Amazon ECS.
In this post, we will deploy a sample Java application on AWS Fargate. For more insights, refer to the prescriptive guidance for deploying Java microservices to AWS Fargate.
Implementation Steps
To implement this solution, we will:
- Create the application, environments, and configuration profile in AWS AppConfig.
- Set up the base application with Amazon ECS and Amazon ECR, including the necessary network components via AWS CloudFormation.
- Clone the code repository, build a Docker container, and publish it to Amazon ECR.
- Create a Fargate task and deploy the container application on Amazon ECS using AWS CloudFormation.
- Verify the deployed application, update the AppConfig configuration data, and deploy the revised configuration.
Creating Application, Environments, and Configuration Profile in AWS AppConfig
- Access the AWS Systems Manager console.
- In the left navigation pane, select AWS AppConfig.
- If the welcome page appears, click on Create configuration data; if not, click on Create application.
- For the application name, input a title (e.g., MyContainerApplication). Optionally, add a description and tags, then choose Create application.
Following the creation of the application, you will be directed to a page featuring Environments and Configuration Profiles. Click on Create environment, and provide a name (e.g., MyContainerApplicationProductionEnvironment) along with an optional description. You can also add tags and set up Amazon CloudWatch alarms if desired.
In the top navigation, select the application name, then navigate to the Configuration Profiles tab and click on Create configuration profile. Provide a name (e.g., MyContainerApplicationConfigurationProfile) and an optional description for the configuration profile. Under Configuration source, select AWS AppConfig hosted configuration. For Content, choose JSON, then paste the following content:
{
"boolEnableFeature": true,
"intItemLimit": 5
}
Note: In this snippet, we’re controlling the number of movies displayed through the intItemLimit
and managing whether that configuration is enabled or disabled via boolEnableFeature
. By default, we keep this configuration enabled but restrict the movie count to 5.
Conclusion
For further insights into developing effective work habits, you can check out this article. Moreover, for insights on the latest HR technology trends, visit this authoritative source. If you’re interested in positions related to learning and development, this job posting is an excellent resource.
Leave a Reply