Skip to content

devopsgeek1979/terraform-basic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌍 Multi-Cloud Terraform DevOps Platform (AWS + Azure)

πŸ‘¨β€πŸ’» Author

Shashi Vashisht

πŸ”— GitHub: https://github.com/devopsgeek1979

πŸ”— LinkedIn: https://www.linkedin.com/in/shashi-pal1979/


πŸ“Œ Project Overview

This project demonstrates a production-style multi-cloud infrastructure deployment using Terraform across:

  • ☁️ AWS β†’ VPC, Subnet, EC2
  • ☁️ Azure β†’ Resource Group, VNet, Subnet

It also includes:

  • Remote backend (state management)
  • State locking (DynamoDB)
  • CI/CD pipeline using GitHub Actions
  • Clean Git workflow for deployment

πŸ—οΈ Architecture

Terraform
   β”‚
   β”œβ”€β”€ AWS (VPC + EC2)
   β”‚      └── Remote State β†’ S3 + DynamoDB
   β”‚
   └── Azure (VNet + Subnet)
          └── Remote State β†’ Azure Storage

πŸ“ Repository Structure

multi-cloud-terraform-devops-platform/
β”‚
β”œβ”€β”€ terraform/
β”‚   β”œβ”€β”€ aws/
β”‚   β”‚   β”œβ”€β”€ backend.tf
β”‚   β”‚   β”œβ”€β”€ provider.tf
β”‚   β”‚   β”œβ”€β”€ main.tf
β”‚   β”‚   └── variables.tf
β”‚   β”‚
β”‚   β”œβ”€β”€ azure/
β”‚   β”‚   β”œβ”€β”€ backend.tf
β”‚   β”‚   β”œβ”€β”€ provider.tf
β”‚   β”‚   β”œβ”€β”€ main.tf
β”‚   β”‚   └── variables.tf
β”‚
β”œβ”€β”€ .github/workflows/
β”‚   └── terraform.yml
β”‚
β”œβ”€β”€ .gitignore
└── README.md

βš™οΈ Prerequisites

Ensure the following tools are installed:

  • Terraform β‰₯ 1.3
  • AWS CLI
  • Azure CLI
  • Git

πŸ” Step 1: Configure Cloud Credentials

βœ… AWS Authentication

export AWS_ACCESS_KEY_ID=<your-access-key>
export AWS_SECRET_ACCESS_KEY=<your-secret-key>
export AWS_DEFAULT_REGION=ap-south-1

Verify:

aws sts get-caller-identity

βœ… Azure Authentication

az login

Verify:

az account show

🧱 Step 2: Create Remote Backend Infrastructure

⚠️ Mandatory before running Terraform


☁️ AWS Backend Setup

aws s3api create-bucket \
  --bucket my-terraform-state-bucket \
  --region ap-south-1

aws dynamodb create-table \
  --table-name terraform-locks \
  --attribute-definitions AttributeName=LockID,AttributeType=S \
  --key-schema AttributeName=LockID,KeyType=HASH \
  --billing-mode PAY_PER_REQUEST

☁️ Azure Backend Setup

az group create --name tf-rg --location centralindia

az storage account create \
  --name tfstateaccount \
  --resource-group tf-rg \
  --location centralindia \
  --sku Standard_LRS

az storage container create \
  --name tfstate \
  --account-name tfstateaccount

☁️ Step 3: Deploy AWS Infrastructure

cd terraform/aws

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

πŸ“¦ AWS Resources Created

  • VPC
  • Subnet
  • EC2 Instance

⚠️ AMI Fix (If Required)

aws ec2 describe-images --owners amazon \
--filters "Name=name,Values=amzn2-ami-hvm-*" \
--query 'Images[*].[ImageId,Name]' \
--output table

Update AMI in main.tf if needed.


☁️ Step 4: Deploy Azure Infrastructure

cd terraform/azure

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

πŸ“¦ Azure Resources Created

  • Resource Group
  • Virtual Network
  • Subnet

πŸ€– Step 5: CI/CD Pipeline (GitHub Actions)

Workflow file:

.github/workflows/terraform.yml

πŸ”Ή What It Does

  • Runs on push to main
  • Initializes Terraform for AWS & Azure
  • Validates configuration

πŸ”Ή How to Enable

  1. Push repo to GitHub
  2. Go to Actions tab
  3. Workflow runs automatically

πŸš€ Step 6: Upload This Project to GitHub

rm -rf .git

git init
git add .
git commit -m "Initial commit - multi-cloud terraform with remote backend"

git remote add origin https://github.com/devopsgeek1979/terraform-basic.git

git branch -M main
git push -u origin main --force

🧹 Cleanup (Destroy Infrastructure)

AWS

cd terraform/aws
terraform destroy -auto-approve

Azure

cd terraform/azure
terraform destroy -auto-approve

πŸ”’ Security Best Practices

For production environments:

  • Use IAM Roles instead of static keys
  • Use AWS Secrets Manager / Azure Key Vault
  • Enable Terraform remote backend (already done)
  • Enable state locking (DynamoDB)
  • Avoid committing secrets

🧠 Key Learning Outcomes

  • Multi-cloud Terraform deployment
  • Remote state management
  • State locking mechanism
  • CI/CD pipeline integration
  • Infrastructure automation best practices

πŸš€ Future Enhancements (Senior DevOps Level)

  • Terraform modules (reusable components)

  • Workspaces (dev/stage/prod)

  • Load Balancers + Auto Scaling

  • Kubernetes:

    • EKS (AWS)
    • AKS (Azure)
  • Monitoring (Prometheus + Grafana)

  • GitOps (ArgoCD)


⭐ Final Note

This repository demonstrates real-world DevOps practices including:

βœ” Multi-cloud architecture βœ” Infrastructure as Code βœ” CI/CD automation βœ” Remote state management

It is designed to showcase hands-on DevOps engineering capability at scale.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages