DevOps Classroom notes 21/Sep/2024

AWS Ntier Architecture

  • Ntier is very popular architecture for deploying web applications
    • web-tier: Webservers will be hosted which serve webpages and they will be accessed directly/indirectly from internet
    • app/business tier: This tier has applications which run the business logic
    • data tier: we store the data in the database

Phase 1: Create basic network and subnets

  • Goal
    Preview
  • We have two categories of subnets of here

    • public subnets (web-1, web-2)
    • private subnets (others)
  • Refer Here for changes done to create vpc and subnets
  • Now lets add an internet gateway Refer Here for changes
  • Now lets create a public route table and private route table and associate them to subnets Refer Here for the changes
  • Now lets add route for public route table to forward to internet gateway Refer Here
    Preview
  • Now we need to create security groups

    • web
      • allow 80 and 22 port from any where
    • app
      • allow 8000 port within vpc
    • db
      • allow 3306 port within vpc
  • Refer Here for the changes
  • Now lets try to create a ec2 instance in web
    • ami id
    • key pair
    • security group
    • subnet
    • public ip
    • instance type
  • Refer Here for creating an ec2 instance and outputs

Conditional resource creation

  • We have already used the count meta argument, in the count if we pass zero then resource will not be created. Refer Here
resource "aws_internet_gateway" "ntier" {
  # conditional creation
  count  = length(var.public_subnets) > 0 ? 1 : 0
  vpc_id = aws_vpc.ntier.id
  tags = {
    Name = "ntier-igw"
  }

}

Locals

Outputs

Terraform block

  • Refer Here for official docs of terraform block
  • From terraform block we can restrict
    • provider versions
    • which terraform version is required to run the template
  • Versioning constraints Refer Here
  • Refer Here for changes in providers to restrict terraform and providers version

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube