Deploying a Full Stack AWS Architecture Using Terraform: Ensuring High Availability in AWS
Ravindra Singh

Ravindra Singh @ravindras

About: I deploy and manage infrastructure and applications across AWS and GCP Cloud. Certified in these platforms, I use Terraform and CI/CD tools to build scalable, secure solutions.

Location:
Pune, India
Joined:
Oct 31, 2023

Deploying a Full Stack AWS Architecture Using Terraform: Ensuring High Availability in AWS

Publish Date: Apr 15 '24
113 9

In this blog, we will learn how to deploy autoscaling group with an application load balancer,EFS, RDS, Route 53, ACM , WAF and Cloudwatch using step-by-step guides

we'll delve deeper into the benefits, provide troubleshooting advice, and share insights for an advanced HA setup on AWS.

Overview of the Architecture

Our target architecture, designed for high availability, comprises various AWS services, each with a specific role in the stack:

1. DNS Configuration with AWS Route 53
Begin with setting up your DNS using AWS Route 53. It will direct traffic to your application, ensuring that the domain name is resolved to the right resources.

2. Load Balancing with High Availability
Implement the AWS ALB for distributing the traffic evenly across your EC2 instances. The ALB also checks the health of the instances and only routes traffic to the healthy ones.

3. Securing the Transmission
Utilize AWS Certificate Manager to handle the SSL/TLS certificates. This is crucial for encrypting data in transit and providing a secure channel for your users.

4. Protecting Your Application
Configure AWS WAF to protect your application from common web exploits that could affect availability, compromise security, or consume excessive resources.

5. Elasticity with Auto Scaling
Use Auto Scaling to maintain application availability and allow the number of Amazon EC2 instances to scale up or down automatically according to conditions you define.

6. Persistent Storage Across Instances
Employ Amazon EFS, which provides a simple interface that allows your application to access shared file storage.

7. Database with High Availability
Set up Amazon RDS with a master and a replica in different Availability Zones to ensure that your database is highly available and resilient to infrastructure failures.

8. Monitoring and Alerting
With AWS CloudWatch, keep an eye on your application's performance and set up alerts for any anomalies that might indicate issues with availability.

9. Streamlined Development Workflow
Leverage a CI/CD pipeline using GitHub Actions to enable your developers to integrate and deliver code changes more rapidly.

10. Infrastructure as Code with Terraform
Finally, use Terraform to script the creation of all these services in AWS. Terraform will allow you to deploy this entire architecture in a repeatable and predictable manner.

Advanced Architecture Benefits

Resiliency and Redundancy: By distributing resources across multiple Availability Zones, you create a fault-tolerant system that mitigates the risk of a single point of failure.

Scalability: Auto Scaling and Elastic Load Balancing respond dynamically to traffic fluctuations, maintaining performance during demand spikes without manual intervention.

Security: AWS WAF and AWS Shield provide advanced protection layers against DDoS attacks and unexpected traffic patterns.
Automation: Terraform’s infrastructure as code (IaC) approach allows for repeatable builds and simplifies the process of applying changes to the infrastructure with minimal human error.

Troubleshooting Tips

Health Checks: Regularly monitor the health of EC2 instances via ALB health checks. Unhealthy instances should be investigated for issues like configuration errors, depleted resources, or failed deployments.

Database Failovers: RDS failover events can be triggered by instance or AZ failures. Always monitor your RDS dashboard for failover events and configure alarms to alert you immediately.

Latency: High latency can indicate misconfigured Auto Scaling or issues with your database. Tools like AWS X-Ray can help in tracing requests and diagnosing the bottlenecks.

If you prefer a video tutorial to help guide you through the setup of deploying a Full Stack AWS Architecture Using Terraform

Comments 9 total

  • Reazul
    Reazul Apr 15, 2024

    Wonderful

  • Karl Valcourt
    Karl ValcourtApr 16, 2024

    Just created my very own project with AWS and such, but this is very inspirational and high level. Thank you for sharing!

    • Ravindra Singh
      Ravindra SinghApr 16, 2024

      Thank you so much @karlkarl281995 I'm glad you found the project inspiring.
      If you have any questions about it or if there's anything specific you'd like to know more about, feel free to ask.

  • thoroc
    thorocApr 18, 2024

    IF you are a dev, you really want to use the AWS CDK or at the very least the TFCDK. Code as infrastructure is such a powerful thing compared to endless sea of config files.

  • Ismael Rodrigues
    Ismael RodriguesApr 27, 2024

    How much this would cost in about one month?

    • Ravindra Singh
      Ravindra SinghApr 29, 2024

      Estimated Cost Calculations for AWS Services:

      Network Load Balancer (NLB):
      1 Load Balancer x $0.0239 per hour x 730 hours per month = $17.45 USD

      EC2 Instances (m5a.xlarge):
      1 Instance x $0.111 per hour x 730 hours in a month = $81.03 USD
      For 2 Instances = $81.03 x 2 = $162.06 USD

      RDS (db.m4.large) for MySQL:
      1 Instance x $0.49 per hour x 730 hours in a month = $357.70 USD

      Elastic File System (EFS):
      100 GB of storage = $8.78 USD per month

      Note: Actual costs may differ based on your specific configuration, resource usage, and AWS pricing changes.

Add comment