The Terraform configuration provisions the entire AWS network and compute foundation for Innovatech Chile. It creates a 3-tier VPC with six subnets spread across two availability zones, attaches the required gateways, and launches three EC2 instances — one per tier — each protected by a chained security group architecture.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/DevOpsDuoc/Evaluacion02_Devop_Innovatech/llms.txt
Use this file to discover all available pages before exploring further.
Provider configuration
The project requires Terraform 1.0 or later and uses the AWS provider pinned to the~> 5.0 range. Authentication relies on environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN) that AWS Academy injects at session start.
00-versions.tf
Network: VPC and subnets
The VPC uses the10.0.0.0/20 CIDR block (4,096 addresses) with DNS support and DNS hostnames enabled. Six /24 subnets are distributed across us-east-1a and us-east-1b in three tiers.
01-network.tf
Subnet layout
| Tier | Subnet | CIDR | AZ |
|---|---|---|---|
| Public (web) | public-subnet-1 | 10.0.0.0/24 | us-east-1a |
| Public (web) | public-subnet-2 | 10.0.1.0/24 | us-east-1b |
| Private (app) | private-app-subnet-1 | 10.0.2.0/24 | us-east-1a |
| Private (app) | private-app-subnet-2 | 10.0.3.0/24 | us-east-1b |
| Private (data) | private-data-subnet-1 | 10.0.4.0/24 | us-east-1a |
| Private (data) | private-data-subnet-2 | 10.0.5.0/24 | us-east-1b |
map_public_ip_on_launch = true. App and data subnets have no direct internet access.
Gateways and routing
An Internet Gateway (academy-igw) handles inbound and outbound internet traffic for the public subnets. A NAT Gateway (academy-nat) allows private instances to reach the internet for outbound requests without exposing them to inbound connections.
01-network.tf
- Public route table —
0.0.0.0/0→ Internet Gateway; associated with both public subnets. - Private route table —
0.0.0.0/0→ NAT Gateway; associated with all four private subnets.
S3 VPC endpoint
A Gateway-type VPC endpoint routes S3 traffic directly inside the AWS network, bypassing the NAT Gateway and eliminating per-GB NAT charges for S3 access.01-network.tf
The S3 endpoint automatically adds routes to the associated route tables. No extra configuration is required after
terraform apply.Security groups
Traffic flows in one direction through three chained security groups:sg_web → sg_app → sg_datos. Each inner layer only accepts connections from the layer above it.
EC2 instances
All three instances use the latest Amazon Linux 2023 AMI (al2023-ami-*-x86_64) and the t3.micro instance type. The IAM instance profile wraps the pre-existing LabRole, granting SSM Session Manager access without opening extra inbound ports.
02-compute.tf
| Instance | Subnet | Security group | Public IP |
|---|---|---|---|
ec2-web | public-subnet-1 | sg_web | Elastic IP |
ec2-app | private-app-subnet-1 | sg_app | None |
ec2-datos | private-data-subnet-1 | sg_datos | None |
ec2-web receives a dedicated Elastic IP that persists across instance stops and starts:
02-compute.tf
Variables
variables.tf
key_name to the name of the key pair created in your AWS Academy lab session before running terraform apply.
Outputs
After a successful apply, Terraform prints four values needed for Ansible inventory and SSH jump configuration:03-outputs.tf