Infrastructure
Infrastructure
The foundational environment for operating IT systems. Includes servers, networks, and storage. Can be codified with IaC.
Infrastructure
The foundational environment for operating IT systems. Includes servers, networks, and storage. Can be codified with IaC.
Infrastructure is the foundational environment for operating IT systems. It includes all the components an application needs to run, such as physical/virtual servers, networks, storage, databases, and load balancers.
Traditional infrastructure meant managing physical servers directly, but in the cloud era, virtualized resources are controlled through APIs. IaaS (AWS, GCP, Azure) provides compute, storage, and networking, while PaaS (Heroku, App Engine) abstracts away the platform as well.
Infrastructure as Code (IaC) defines infrastructure as code. Terraform and Pulumi create resources declaratively, and Ansible configures servers. Version control in Git tracks change history, and code review prevents mistakes.
In practice, development/staging/production environments are managed consistently as code. During disaster recovery (DR), infrastructure is automatically created in another region, and security groups and IAM policies are also managed as code to maintain compliance.
# Terraform - AWS 인프라 정의
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
backend "s3" {
bucket = "myapp-terraform-state"
key = "production/terraform.tfstate"
region = "ap-northeast-2"
}
}
# VPC 네트워크
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
tags = { Name = "main-vpc" }
}
resource "aws_subnet" "public" {
count = 2
vpc_id = aws_vpc.main.id
cidr_block = "10.0.${count.index + 1}.0/24"
availability_zone = data.aws_availability_zones.available.names[count.index]
map_public_ip_on_launch = true
tags = { Name = "public-subnet-${count.index + 1}" }
}
# EC2 인스턴스
resource "aws_instance" "web" {
count = var.instance_count
ami = data.aws_ami.amazon_linux.id
instance_type = var.instance_type
subnet_id = aws_subnet.public[count.index % 2].id
vpc_security_group_ids = [aws_security_group.web.id]
iam_instance_profile = aws_iam_instance_profile.web.name
root_block_device {
volume_size = 20
volume_type = "gp3"
encrypted = true
}
tags = {
Name = "web-${count.index + 1}"
Environment = var.environment
}
}
# RDS 데이터베이스
resource "aws_db_instance" "main" {
identifier = "myapp-db"
engine = "postgres"
engine_version = "15.4"
instance_class = "db.t3.medium"
allocated_storage = 50
storage_encrypted = true
multi_az = true
db_subnet_group_name = aws_db_subnet_group.main.name
skip_final_snapshot = false
}
Senior: "We need to build a DR environment in a new region. How long would it take to replicate it with Terraform?"
Junior: "If we reuse the existing modules and only change the variables, 1-2 days. We'll also need to set up VPC peering."
Interviewer: "What are the advantages of Infrastructure as Code?"
Candidate: "Version control tracks change history, code review prevents mistakes, and environments stay consistent. Infrastructure can be quickly recreated during disaster recovery, and test environments can be replicated identically, which also improves development productivity."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Reviewer: "The security group has 0.0.0.0/0 inbound open. Is that intentional?"
Developer: "Oh, I opened it while testing and it got committed. I'll change it so access is allowed only from CloudFront/ALB."