Skip to content

Latest commit

 

History

History
113 lines (80 loc) · 5.27 KB

File metadata and controls

113 lines (80 loc) · 5.27 KB

Complete DevOps Project 2: Terraform Multi-Environment Infrastructure Project

This project demonstrates the use of Terraform to create a complete infrastructure setup, including networking, RDS instances, and Elastic Cache. The project is organized into separate environments (dev and prod) using workspaces and incorporates a Lambda function to send email notifications when the infrastructure state changes. 1682176156190

Table of Contents

Overview

This project provisions the following resources:

  • Networking components such as VPC, Internet Gateway, NAT Gateway, Route Tables, and Security Groups.
  • EC2 instances for bastion and application hosts.
  • RDS instance and Elastic Cache using Terraform modules.
  • Separate workspaces for dev and prod environments.
  • A Lambda function to detect changes in the Terraform state file and send email notifications.

Features

1. Networking

The project creates a VPC with the following components: Screenshot 2023-05-04 014145

  • An Internet Gateway to provide a connection between the VPC and the internet.
  • A NAT Gateway to allow instances in private subnets to access the internet.
  • Public and private subnets for hosting various resources.
  • Public and Private Route Tables to manage traffic between subnets and the internet.
  • Security Groups for allowing SSH from the public internet and application access within the VPC. Screenshot 2023-05-04 014336

2. EC2 Instances

Two EC2 instances are created in this project:

  • A bastion host with a public IP address and an associated Security Group for SSH access. This instance is placed in the public subnet.
  • An application host with a private IP address and an associated Security Group for application access. This instance is placed in the private subnet. Screenshot 2023-05-04 014157

3. Database and Cache

An RDS instance and Elastic Cache are provisioned using Terraform modules:

  • The RDS instance is created using the AWS RDS service and is managed by Terraform. Screenshot 2023-05-04 015507
  • The Elastic Cache instance is created using the AWS RDS service and is managed by Terraform. Screenshot 2023-05-04 015541

4. Workspace and Environment Setup

The project is organized into separate environments (dev and prod) using workspaces:

  • Workspaces are created for the dev and prod environments. Screenshot 2023-05-04 031429
  • Variable definition files (.tfvars) are used to manage different configurations for each environment.
  • A local-exec provisioner is used to print the public IP of the bastion host. Screenshot 2023-05-04 014059

5. Additional Features

  • The infrastructure code is uploaded to a Github project.
  • A Lambda function is set up to trigger when changes are detected in the Terraform state file. The function sends email notifications for these changes. Screenshot 2023-05-04 020415 Screenshot 2023-05-04 020612 Screenshot 2023-05-04 031052 Screenshot 2023-05-04 031651 Screenshot 2023-05-04 024657

Prerequisites

  • Terraform 0.12.x or later
  • AWS CLI and an AWS account with necessary permissions

Usage

  1. Clone the repository:
git clone https://github.com/yourusername/complete-devops-project-2.git
cd complete-devops-project-2
  1. Initialize Terraform:
terraform init
  1. Create a new Terraform workspace for the desired environment (dev or prod):
terraform workspace new <workspace_name>
  1. Update the respective .tfvars file with the required values for your environment.

  2. Apply the Terraform configuration:

terraform apply -var-file=<environment>.tfvars
  1. To destroy the infrastructure, run:
terraform destroy -var-file=<environment>.tfvars

License

This project is licensed under the MIT License. See the LICENSE file for details.