All configuration for the MEAN stack deployment is driven through input variables defined inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/mcamacho97/terraform-mean-stack-aws/llms.txt
Use this file to discover all available pages before exploring further.
variables.tf. None of the variables carry default values — every setting must be explicitly provided, which ensures that deployments are intentional and environment-specific. At runtime, Terraform reads your values from a terraform.tfvars file that you create locally; a separate backend.hcl file supplies the S3 remote state configuration. Both files are gitignored to keep secrets and environment-specific values out of version control.
This project requires Terraform >= 1.12. Check your installed version with
terraform version before proceeding.Configuration Files
Before running any Terraform commands, create your local variable files from the provided example:| File | Purpose | Committed? |
|---|---|---|
terraform.tfvars | Your variable values for the deployment | ❌ gitignored |
backend.hcl | S3 backend configuration (bucket, key, region) | ❌ gitignored |
Project Identity
Project name used as a prefix for all AWS resource names. The value is interpolated into every resource name via
locals.tf — for example, a project name of "terraform-mean" produces resources such as terraform-mean-vpc, terraform-mean-alb, terraform-mean-node-1, and terraform-mean-mongodb.Deployment environment label. Applied as the
Environment tag on all resources and used to distinguish between parallel deployments in the same AWS account.Accepted values: lab, dev, qa, prodAWS region where all infrastructure will be provisioned. The availability zone variables must correspond to zones within this region.
Network Configuration
CIDR block for the VPC. All subnets must fall within this address space. The recommended
/16 block provides 65,536 addresses with room for future subnet expansion.CIDR block for Public Subnet A. This subnet is placed in
availability_zone_1 and hosts Node.js Server 1. Instances here receive public IP addresses.CIDR block for Public Subnet B. This subnet is placed in
availability_zone_2 and hosts Node.js Server 2. A second public subnet in a separate AZ enables multi-AZ ALB target registration.CIDR block for the Private Subnet that hosts the MongoDB instance. Resources in this subnet have no direct public internet access — outbound traffic is routed through the NAT Gateway.
Availability Zone for Public Subnet A and the Private Subnet (MongoDB). Both Node 1 and MongoDB land in this AZ, minimising cross-AZ traffic between the application tier and the database tier.
Availability Zone for Public Subnet B. Node.js Server 2 is deployed here, distributing the compute tier across two AZs for resilience behind the ALB.
Compute
EC2 instance type applied to all three instances — Node 1, Node 2, and MongoDB. Using the same type across all instances simplifies cost estimation and capacity planning.
Number of Node.js application instances to provision. The default example value is
2, which matches the two public subnets and provides basic redundancy behind the ALB. Adjusting this value beyond 2 requires corresponding subnet and AZ additions to the network configuration.Security
The CIDR block permitted to connect via SSH to the Node.js instances. This value is written into the security group ingress rule for port 22. You must supply a
/32 host address (a single IP), not a range.To find your current public IP:Complete Example File
The following is the fullterraform.tfvars.example provided in the repository. Copy it to terraform.tfvars and replace the placeholder values before running terraform apply.
Common Tags
All AWS resources created by this project are tagged automatically vialocals.tf. The common_tags local is passed to every module, so you can filter and identify resources in the AWS Console, Cost Explorer, and CloudTrail without manual tagging.
| Tag Key | Value |
|---|---|
Project | Value of var.project_name |
Environment | Value of var.environment |
ManagedBy | "Terraform" |
locals.tf alongside the names map that constructs every resource name from var.project_name: