AWS Logo
Menu
Dynamic AWS Service Selection

Dynamic AWS Service Selection

Automating AWS Service Selection with Dynamic Decision Engine

Published May 3, 2025

Dynamic AWS Service Selection: Automating AWS Service Selection with Dynamic Decision Engine

Introduction
Selecting the right AWS services for an application architecture can be overwhelming, require deep expertise and significant time investment. To simplify this, I have created a Dynamic, rule-based cloud service decision engine that automates AWS service selection based on structured input criteria provided by user. This approach ensures consistency, accelerates decision-making, and align with AWS best practices and AWS Well-Architect Framework.
The Challenges
In rapidly evolving cloud environments, architects and developers encounter several challenges, including:
  • Complex Decision Trees: Identifying the best mix of services tailored to particular application requirements.
  • Manual Configuration Effort: The labor-intensive process of setting up and configuring services.
  • Absence of Visualization: Challenges in visualizing the architecture prior to deployment.
  • Lack of Visual Representation: Architects facing challenges to visualize infrastructure before deployment.
These challenges often lead to inefficiencies, higher costs, and possible misconfigurations.
Introducing the Dynamic AWS Service Selection Engine
Dynamic AWS Service Selection
Dynamic AWS Service Selection
This solution consists of below key layers
  • Requirement Definition
User specify their application requirements in a structured YAML format, ensuring clarity and streamlined processing.
Example YAML Input:
ServiceSelectRequest:
- compute_preference: microservices
- container_management: aws_managed
- serverless_integration: yes
- database_type: relational
Key Parameters:
  • compute_preference: microservices or monolithic
  • container_management: aws_managed or self-managed
  • serverless_integration: yes or no
  • database_type: relational or NoSQL
  • Decision Engine
A rule-based decision engine analyze the YAML input and maps it to optimal AWS services using a predefined Decision Tree Mode.
Sample Decision Logic
  • IF ``serverless_integration`` is ``yes``, include ``AWS Lambda
  • IF ``database_type`` is ``relational``, suggest ``Amazon RDS
  • IF ``database_type`` is ``No_SQL``, suggest ``Amazon DynamoDB
  • IF ``compute_prefereence`` is microservices, suggest ``EKS + API Gateway
Improved scalability:
  • The decision logic is adaptable for additional AWS services (example, AWS Fargate for container management)
  • Supports integration with AWS Trusted Advisor for optimizing recommendations
  • CloudFormation Template Generation
Once services are selected, the system dynamically generate a CloudFormation template, enabling automated AWS resource provisioning, in accordance with best practices of IaC.
  • Parameterized Templates - Allow users to input variables dynamically
  • Modular Design - Supports multiple environments (Dev, Test, Staging and Production)
  • Compliance with AWS Best Practices - Ensure proper IAM policies and architecture security.
  • Visualization
To enhance clarity, provides an interactive interface to explore the architecture decisions as a decision tree or graph-based representation. This improves understanding and aids architects in validating selections.
  • Deployment and Confirmation
Once the architecture is finalized, user can review and confirm AWS service selection. The CloudFormation template is deployed, provisioning resources in AWS
Key Benefits
  • Automated & Scalable AWS Service Selection - Reduces manual effort and improve efficiency.
  • IaC compliance - Enhances version control and repeatability
  • Architecture Decision Tree Visualization - Provides transparency and helps refine decisions.
  • Multi-Technology Compatibility - Works with .NET , Python
Sample Code Snippet - .NET Implementation
  • Decision Tree algorithm
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
class AWSServiceSelector
{
static void Main()
{
string yamlContent = System.IO.File.ReadAllText("requirements.yaml");
var requirements = JObject.Parse(yamlContent);
var awsServices = new List<string>();
if ((string)requirements["manage_own_containers"] == "Yes") {
awsServices.Add((string)requirements["use_kubernetes"] == "Yes" ? "Amazon EKS" : "Amazon ECS");
}
if ((string)requirements["serverless_integration"] == "Yes") {
awsServices.Add("AWS Lambda");
}
if ((string)requirements["database"] == "relational") {
awsServices.Add("Amazon RDS");
}
else {
awsServices.Add("Amazon DynamoDB");
}
Console.WriteLine("Selected AWS Services: " + string.Join(", ", awsServices));
}
}
  • Generating CloudFormation Scripts
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json; // Using JSON serialization for structured output
class Program
{
static void Main()
{
var awsServices = new List<string> { "Amazon EKS", "AWS Lambda" };
// CloudFormation template dictionary
var cloudFormationTemplate = new Dictionary<string, object>
{
{ "AWSTemplateFormatVersion", "2010-09-09" },
{ "Resources", new Dictionary<string, object>() }
};
var resources = (Dictionary<string, object>)cloudFormationTemplate["Resources"];
foreach (var service in awsServices)
{
if (service == "Amazon EKS") {
resources["EKSCluster"] = new Dictionary<string, object>
{
{ "Type", "AWS::EKS::Cluster" },
{ "Properties", new Dictionary<string, string> { { "Name", "MyCluster" } } }
};
}
else if (service == "AWS Lambda") {
resources["LambdaFunction"] = new Dictionary<string, object>
{
{ "Type", "AWS::Lambda::Function" },
{ "Properties", new Dictionary<string, string> { { "Runtime", "python3.9" } } }
};
}
}
// Serialize the dictionary to JSON format (CloudFormation uses YAML, but JSON is valid too)
string jsonOutput = JsonConvert.SerializeObject(cloudFormationTemplate, Formatting.Indented);
// Write to file
File.WriteAllText("cloudformation.json", jsonOutput);
Console.WriteLine("CloudFormation template generated successfully!");
}
}
Sample Code Snippet - Python Implementation
  • Decision Tree algorithm
import yaml
with open("requirements.yaml", "r") as file:
requirements = yaml.safe_load(file)
aws_services = []
if requirements.get("manage_own_containers") == "Yes":
aws_services.append("Amazon EKS" if requirements.get("use_kubernetes") == "Yes" else "Amazon ECS")
if requirements.get("serverless_integration") == "Yes":
aws_services.append("AWS Lambda")
if requirements.get("database") == "relational":
aws_services.append("Amazon RDS")
else:
aws_services.append("Amazon DynamoDB")
print("Selected AWS Services:", aws_services)
  • Generate CloudFormation Scripts
cloudformation_template = {
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {}
}
for service in aws_services:
if service == "Amazon EKS":
cloudformation_template["Resources"]["EKSCluster"] = {
"Type": "AWS::EKS::Cluster",
"Properties": {"Name": "MyCluster"}
}
elif service == "AWS Lambda":
cloudformation_template["Resources"]["LambdaFunction"] = {
"Type": "AWS::Lambda::Function",
"Properties": {"Runtime": "python3.9"}
}
with open("cloudformation.yaml", "w") as file:
yaml.dump(cloudformation_template, file)
print("CloudFormation template generated!")
  • Generating CloudFormation Scripts
cloudformation_template = {
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {}
}
for service in aws_services:
if service == "Amazon EKS":
cloudformation_template["Resources"]["EKSCluster"] = {
"Type": "AWS::EKS::Cluster",
"Properties": {"Name": "MyCluster"}
}
elif service == "AWS Lambda":
cloudformation_template["Resources"]["LambdaFunction"] = {
"Type": "AWS::Lambda::Function",
"Properties": {"Runtime": "python3.9"}
}
with open("cloudformation.yaml", "w") as file:
yaml.dump(cloudformation_template, file)
print("CloudFormation template generated!")
GitHub Repo
https://github.com/MahendhiranK/CloudDecisionTree
 

9 Comments