Posts

Showing posts from February, 2023

Terraform Series - LifeCycles

Image
  In this post we will see an interesting concept called "LifeCycle Rules". This is almost like a hook to tell terraform on what needs to be done. There are 3 lifecycle rules: 1) Prevent Destroy 2) Create Before Destroy 3) Ignore Changes resource "local_file" "name" {   filename = "/root/pets.txt"   content = "We love pets"   file_permission = "0700" } I am using the resource "local_file" to create a file with a content and permission "0700". # local_file.name: resource "local_file" "name" {     content              = "We love pets"     directory_permission = "0777"     file_permission      = "0700"     filename             = "/root/pets.txt"     id                   = "978236bb65828b96bae1df000a4f9d6e6c5ca5a8" } Modifying the permission back "0755" with lifecycle rules....

Terraform Series - SSH Passwordless Login

Image
  In today's post will see how to set up passwordless login for an EC2 instance via terraform. First Method, I created a key pair called "ec2key" and I downloaded the private key. I am going to create an EC2 instance using aws_instance resource and refer to the imported key as key_name = "ec2key" # Terraform Block terraform {   required_providers {     aws = {       source   = "hashicorp/aws"     }   } } # Provider Block provider "aws" {   profile = "default" # AWS Credentials configured via AWS CLI.   region   = "us-east-1" } # Resource Block resource "aws_instance" "ec2demo" {   ami           = "ami-0b5eea76982371e91" # Amazon Linux in us-east-1   instance_type = "t2.micro"   subnet_id = "subnet-0cfdbb9ad42fcf3c9"   security_groups = [ "sg-0495b116a9de10f0c" ]   key_name = "ec2key"   tags = {     "Name" = "web...

AWS Terraform Syllabus

Image
  1) Terraform Basics. 2) Installation and setup TF. 3) Configure AWS CLI. 4) Terraform Settings, Providers and Resources. 5) Terraform Input Variables, DataSources, Output Values. 6) Terraform Loops, MetaArguements, Splat Operator. 7) AWS VPC 3-Tier Design. 8) AWS EC2 Instance with Security Group with Terraform. 9) AWS Classic Load Balancer. 10) AWS Application Load Balancer. 11) AWS ALB Context Path Routing. 12) AWS ALB Host Header Routing. 13) AWS ASG with Launch Configuration and Template. 14) AWS Cloud Watch Alarms. 15) TF Remote State Storage with S3. 16) Launching static site using TF.

Terraform Series - Classic Loadbalancer

Image
  This post is all about automation of https://rsinfomindss.blogspot.com/2023/02/aws-classic-loadbalancer.html I have created 4 TF Files: 1) Classiclb.tf - Contains Loadbalancer configuration. 2) Securitygroup.tf - Contains security group to allow incoming traffic on port 80. 3) Application_EC2.tf - Contains EC2 configuration. 4) appinstall.sh - Shell script to setup web server. module "elb" {   source   = "terraform-aws-modules/elb/aws"   version = "4.0.1"   name = "testlb"   depends_on = [     aws_instance . ec2demo   ]   subnets = [ "subnet-0cfdbb9ad42fcf3c9" ]   security_groups = [ module . loadbalancer_sg . this_security_group_id ]   #security_groups = ["sg-0495b116a9de10f0c"]   internal = false   listener = [     {       instance_port     = 80       instance_protocol = "HTTP"       lb_port         ...

AWS - Classic LoadBalancer

Image
In todays post we will see how to set up a classic load balancer for serving static web content. Now, I have the loadbalancer setup. Going to provision VM using terraform. Updating the EC2 security group to allow inbound traffic on port 80. Test the connection by accessing the EC2 Public IP and it works. Now, Lets add the EC2 instance behind the Load Balancer. Now, lets access the load balancer DNS Name. It works. In the next post will automate this process using Terraform.