How amanm13/instance-details works
Main Components Identification
• Application Component:
• A Python Flask application (located in the application/app directory) that serves an endpoint (/ec2) to display details of running EC2 instances.
• It is containerized using Docker (Dockerfile, .dockerignore) and uses packages like gunicorn, boto3, and Flask.
• Infrastructure Component:
• Terraform code (under the terraform directory) sets up the AWS infrastructure. This includes distinct resource configurations for DynamoDB (for Terraform state locking), S3 (to store terraform state), VPC (virtual networking), EC2 (the compute resource that can host the application), and Route 53 (for DNS).
• The Terraform code is modular – you have dedicated modules for each resource type (ec2, dynamodb_table, s3, vpc, route_53). Additionally, each resource (e.g., EC2, R53, VPC) has its own top-level directory indicating resource provisioning steps.
Relationships and Interactions
• The application, once containerized, will run on an AWS EC2 instance provisioned by Terraform.
• The Flask application makes AWS SDK (boto3) calls to query running EC2 instances as part of its core functionality.
• Terraform automates the provisioning of infrastructure such as the EC2 instance, VPC, security groups, load balancer (ALB), auto scaling groups (ASG), and DNS configurations (via Route 53).
• The Terraform state is stored in an S3 bucket, with state locking enforced by a DynamoDB table, ensuring safe concurrent modifications.
Architectural Patterns and Design Principles
• Separation of Concerns: The project clearly separates application logic from infrastructure provisioning.
• Modular Infrastructure: The Terraform configuration uses modules for each AWS resource type, making the deployment both reusable and maintainable.
• Containerization: The application is containerized, ensuring consistent deployment environments, which is ideal when integrating with cloud resources.
• IaC Best Practices: The use of remote state storage (S3) and DynamoDB for lock management is a best practice to maintain consistency and reduce risk of conflicts.
• Component is well annotated with its technologies: mention Flask, Gunicorn, and boto3 on the application side; Docker containerization; and Terraform configurations on the infrastructure side.