Skip to content

anandray/serverless-AWS-cost-optimization

Repository files navigation

Serverless AWS Cost Optimization

Gateway

AWS Terraform

This GitHub repository showcases the powerful trio of Terraform, AWS Lambda, and Event Bridge for achieving cost optimization in your AWS infrastructure. With a focus on automation and intelligent strategies, you can effectively reduce AWS expenditure without compromising performance or functionality.

🔑 Key Features

  • Infrastructure as Code: Define your AWS infrastructure in a declarative manner using Terraform configurations, enabling easy versioning, management, and environment reproducibility.

  • Lambda Functions: Explore the creation of serverless functions using AWS Lambda to perform specific tasks in response to events. Examples include processing incoming data or triggering automated actions.

  • Event Bridge: Learn how to leverage AWS Event Bridge to establish event-driven architectures, enabling decoupled communication between different services. This facilitates efficient cost optimization through event filtering and routing.

  • Cost Optimization Techniques: Discover various techniques for AWS cost optimization, including intelligent resource scaling, serverless architecture design patterns, efficient event routing, and usage-based cost analysis.

  • Sample Workflows: Find practical examples of cost optimization workflows that combine Terraform, Lambda functions, and Event Bridge rules. These workflows automate common tasks, minimize resource usage, and reduce unnecessary costs.

⚡️ Prerequisites

  • You must have an AWS account and configure your CLI profile.
  • Terraform must be installed. Learn how to install Terraform
  • Please first completed part one you will need the EC2 instance ID's i-xxxxxxxxxxxxx from the output provided after this deployment is done. You can also copy them from the console once is completed Part one EC2 Creation

⚠️ Cautions

  • As an AWS best practice, grant this code least privilege, providing only the necessary permissions to perform a task. For more information, see Grant Least Privilege in the AWS Identity and Access Management User Guide.
  • This code has been tested in the us-east-1 AWS Region only. However, it should work in any other region.
  • Running this code may result in charges to your AWS account.

▶️ How to Run This Code

🚀 Quick Start

cd serverless_AWS_cost_optimization
terraform init
terraform validate
terraform plan
terraform apply --auto-approve

💥 Quick Destroy

terraform destroy --auto-approve

📌 Notes

- clone this Git repo
- cd to the the directory serverless_AWS_cost_optimization
- copy __EC2_ID's__ from previous deployment and paste them each on __start.py__ and __stop.py__ place holders
- use terraform __init__ command to initialize the Terraform working directory and to download plugins for a provider (aws)
- terraform validate command will validate the code before actual deployment
- terraform plan command will show the execution code before making the actual deployment
- terraform apply
- Alternate command : terraform apply -auto-approve
- terraform destroy
- Alternate command : terraform destroy -auto-approve
- terraform fmt -recursive # A way to format the terraform code

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published