Multi-Environment Infrastructure Platform
Dev/staging/production, Terraform modules, CI/CD and isolation.
Overview
Build a multi-environment infrastructure platform with dev/staging/production separation, shared modules, environment CI/CD and isolation.
The problem
Manage consistent infrastructure across dev, staging and production.
Why it matters
This is a real, in-demand scenario: Manage consistent infrastructure across dev, staging and production.. Teams that can ship and run a infrastructure like this solve an actual business need and are hired for that ability.
What you'll build
- Multi-env structure
- Promotion pipeline
- Isolation
What you'll learn
- Env management
- IaC at scale
Business problem
Teams need environments that are consistent yet isolated.
Technical problem
Manage per-environment state and promotion without drift.
When you're done: A working infrastructure project — code committed, tests passing, and documented in your portfolio.
Requirements
User requirements
- Consistent envs
- Separation
- Promotion
System requirements
- Terraform
- Environments
- CI
Functional requirements
- Env structure
- Shared modules
- Env-specific state
- CI promotion
Non-functional requirements
- Isolated
- Repeatable
Technical requirements
- workspaces or folders
- remote state
Security requirements
- Prod access restricted
Operational requirements
- Promote via pipeline
Constraints
- Terraform
Success criteria
- Envs consistent
- Changes promote safely
Flows
Request Flow
- 1
Browser
User requests the application over HTTPS.
- 2
CDN / DNS
Edge routes the request to the origin.
- 3
Load Balancer
Distributes traffic across healthy app instances.
- 4
Application
Handles the request, applies business logic.
- 5
Cache
Serves fast reads for hot data.
- 6
Database
Persists data and returns results.
Project Structure
Root of the client application source.
Setup
- 1
Prerequisites
You need the tools required by Terraform, AWS, CI/CD installed and available on your PATH.
- 2
Clone project
Clone the repository locally.
1. Clone the repositorygit clone <your-repo-url> <project-folder> - 3
Install dependencies
Install the project dependencies.
1. Initialize a Node.js projectLinux / Windowsnpm init -yExpected
Creates a package.json with defaults.
If it fails
command not found: npm
Fix
Install Node.js LTS from the official site, then reopen your terminal.
- 4
Configure environment
Set the environment variables documented for this project. Never commit secrets.
1. Create the environment filecp .env.example .env # then edit values - 5
Start project
Run the development command and confirm it starts.
1. Start the development serverLinux / Windowsnpm run devExpected
Dev server starts; watch terminal for the local URL.
If it fails
Port 3000 is already in use
Fix
Run on another port: npm run dev -- --port 3001, or stop the conflicting process.
- 6
Verify
Open the printed local URL and confirm the primary flow works.
Build Phases
0 of 8 phases complete
Objective: Establish the next milestone of the cloud infrastructure.
What changes: The project advances to the next coherent state, keeping the previous milestones working.
Files touched
Relevant source and configuration files for this milestone.Run
1. Initialize a Node.js projectLinux / Windowsnpm init -yExpected
Creates a package.json with defaults.
If it fails
command not found: npm
Fix
Install Node.js LTS from the official site, then reopen your terminal.
Tasks
- Implement the specific behaviour required for this milestone.
- Verify the previous milestone still works.
Validate: The milestone behaves as expected and does not break existing functionality.
Common mistakes
- • Skipping validation and moving on before confirming the milestone works.
Objective: Establish the next milestone of the cloud infrastructure.
What changes: The project advances to the next coherent state, keeping the previous milestones working.
Files touched
Relevant source and configuration files for this milestone.Run
1. Install the terraform packageLinux / Windowsnpm install terraformExpected
Adds terraform to node_modules and package.json.
If it fails
npm ERR! network / EACCES
Fix
Check your network or run with sudo on Linux/macOS; on Windows run the terminal as Administrator.
Tasks
- Implement the specific behaviour required for this milestone.
- Verify the previous milestone still works.
Validate: The milestone behaves as expected and does not break existing functionality.
Common mistakes
- • Skipping validation and moving on before confirming the milestone works.
Objective: Establish the next milestone of the cloud infrastructure.
What changes: The project advances to the next coherent state, keeping the previous milestones working.
Files touched
Relevant source and configuration files for this milestone.Run
1. Start the development serverLinux / Windowsnpm run devExpected
Dev server starts; watch terminal for the local URL.
If it fails
Port 3000 is already in use
Fix
Run on another port: npm run dev -- --port 3001, or stop the conflicting process.
Tasks
- Implement the specific behaviour required for this milestone.
- Verify the previous milestone still works.
Validate: The milestone behaves as expected and does not break existing functionality.
Common mistakes
- • Skipping validation and moving on before confirming the milestone works.
Objective: Establish the next milestone of the cloud infrastructure.
What changes: The project advances to the next coherent state, keeping the previous milestones working.
Files touched
Relevant source and configuration files for this milestone.Run
1. Build the application for productionLinux / Windowsnpm run buildExpected
A production bundle is emitted to the output directory.
If it fails
Build fails with a type or syntax error
Fix
Read the error message, fix the referenced file, and re-run the build.
Tasks
- Implement the specific behaviour required for this milestone.
- Verify the previous milestone still works.
Validate: The milestone behaves as expected and does not break existing functionality.
Common mistakes
- • Skipping validation and moving on before confirming the milestone works.
Objective: Establish the next milestone of the cloud infrastructure.
What changes: The project advances to the next coherent state, keeping the previous milestones working.
Files touched
Relevant source and configuration files for this milestone.Tasks
- Implement the specific behaviour required for this milestone.
- Verify the previous milestone still works.
Validate: The milestone behaves as expected and does not break existing functionality.
Common mistakes
- • Skipping validation and moving on before confirming the milestone works.
Objective: Establish the next milestone of the cloud infrastructure.
What changes: The project advances to the next coherent state, keeping the previous milestones working.
Files touched
Relevant source and configuration files for this milestone.Tasks
- Implement the specific behaviour required for this milestone.
- Verify the previous milestone still works.
Validate: The milestone behaves as expected and does not break existing functionality.
Common mistakes
- • Skipping validation and moving on before confirming the milestone works.
Objective: Establish the next milestone of the cloud infrastructure.
What changes: The project advances to the next coherent state, keeping the previous milestones working.
Files touched
Relevant source and configuration files for this milestone.Tasks
- Implement the specific behaviour required for this milestone.
- Verify the previous milestone still works.
Validate: The milestone behaves as expected and does not break existing functionality.
Common mistakes
- • Skipping validation and moving on before confirming the milestone works.
Objective: Establish the next milestone of the cloud infrastructure.
What changes: The project advances to the next coherent state, keeping the previous milestones working.
Files touched
Relevant source and configuration files for this milestone.Tasks
- Implement the specific behaviour required for this milestone.
- Verify the previous milestone still works.
Validate: The milestone behaves as expected and does not break existing functionality.
Common mistakes
- • Skipping validation and moving on before confirming the milestone works.
Commands
npm init -yExpected
Creates a package.json with defaults.
If it fails
command not found: npm
Fix
Install Node.js LTS from the official site, then reopen your terminal.
npm install terraformExpected
Adds terraform to node_modules and package.json.
If it fails
npm ERR! network / EACCES
Fix
Check your network or run with sudo on Linux/macOS; on Windows run the terminal as Administrator.
npm run devExpected
Dev server starts; watch terminal for the local URL.
If it fails
Port 3000 is already in use
Fix
Run on another port: npm run dev -- --port 3001, or stop the conflicting process.
npm run buildExpected
A production bundle is emitted to the output directory.
If it fails
Build fails with a type or syntax error
Fix
Read the error message, fix the referenced file, and re-run the build.
Testing
Unit tests
Core logic and pure functions behave correctly.
npm init -ySuccess: All unit tests pass without errors.
Integration tests
Components integrate correctly with data sources and services.
npm testSuccess: Integration tests pass for the primary flows.
API tests
Endpoints respond to valid and invalid input correctly.
npm testSuccess: API tests cover happy and failure paths.
End-to-end tests
A user can complete the primary journey end to end.
npm run test:e2eSuccess: The main user journey completes successfully.
Security tests
No obvious security regressions are introduced.
npm auditSuccess: No high or critical vulnerabilities.
Debugging & Troubleshooting
Provider initialization fails
Why: The provider cannot be downloaded or is version-conflicted.
Check: Re-run init verbosely.
terraform init
Fix: Check network, registry access, and required_version constraints.
Prevent: Pin provider versions and document network requirements.
State lock conflict
Why: Another process holds the state lock.
Check: Identify the lock holder.
terraform apply # wait for lock
Fix: Wait for it to release, or unlock if it is stale.
Prevent: Use locking backends (S3 + DynamoDB) and avoid concurrent applies.
Invalid variable or missing value
Why: A variable was referenced but not provided.
Check: Review variables.tf and the plan input.
terraform plan
Fix: Provide the value via tfvars, a variable block, or the CLI.
Prevent: Add validation blocks and sensible defaults.
Permission denied applying changes
Why: The credentials lack the required IAM permissions.
Check: Identify the failing resource and the error.
terraform apply
Fix: Grant the minimal permissions needed for the resource actions.
Prevent: Use least-privilege roles and test plans before applying.
Security
Security is treated as a core requirement: input is validated, secrets are protected, and dependencies are kept up to date.
Input validation
Validate and sanitize all user input before use.
Secrets management
Store secrets in environment variables, never in source.
Dependency hygiene
Regularly audit dependencies for known vulnerabilities.
Observability
Logs
- Node and service logs shipped to a centralized sink
- Infrastructure deployment logs
Metrics
- CPU, memory, disk, network
- Container metrics
- Queue depth
Traces
- Service-to-service traces
Health checks
- Readiness and liveness probes
- End-to-end health probe
Alerts
- Resource exhaustion alerts
- Unexpected downtime alert
Dashboards
- Node, container and application dashboards
SLIs
- Availability — Uptime of the service endpoints
SLOs
- Availability — 99.9% over 30 days
Deployment
- 1
Prepare for deployment
Build the production artifact.
1. Build for productionnpm run build - 2
Deploy
Deploy to the project target platform following its documented steps.
1. Deploynpm run deploy # or the platform-specific command - 3
Verify
Confirm the deployed application responds and its health check passes.
1. Check healthcurl -I https://<your-deployed-url>
Documentation
Project Overview
Build a multi-environment infrastructure platform with dev/staging/production separation, shared modules, environment CI/CD and isolation. This is a advanced infrastructure project in the cloud infrastructure space, built to demonstrate real engineering, not just copied code.
What You Will Build
- Multi-env structure - Promotion pipeline - Isolation
Problem Statement
Teams need environments that are consistent yet isolated. Manage per-environment state and promotion without drift.
Technology Stack
Terraform, AWS, CI/CD
Installation
Clone the repository and install dependencies with the documented commands.
Local Development
Run the development command and open the printed local URL.
Testing
Run the test commands documented in the Testing section and confirm they pass.
Deployment
Follow the documented deployment steps for this project's target platform.
Interview Explanation
Use the Interview section to explain the architecture, technology choices and trade-offs.
Build Process
Phases guide the build in 8 checkpoints. Complete each and validate before moving on.
Interview Prep
30-second pitch
I built Multi-Environment Infrastructure Platform — manage consistent infrastructure across dev, staging and production. It uses Terraform, AWS, CI/CD and solves teams need environments that are consistent yet isolated.
2-minute walkthrough
Build a multi-environment infrastructure platform with dev/staging/production separation, shared modules, environment CI/CD and isolation. The core requirements were Env structure, Shared modules, Env-specific state. I structured the work around Structure environments, Promote configs, Isolate environments and validated the result with the documented tests.
Architecture
The architecture is described by the interactive diagram in the Architecture section, which maps the request and deployment flows.
Why these technologies
I chose Terraform, AWS, CI/CD because they are the pragmatic, well-supported tools best suited to building a infrastructure of this kind.
Why this architecture
The structure exists to keep concerns separated, make each piece testable, and scale the project cleanly as requirements grow.
At scale
At scale I would introduce caching, move to a service boundary structure, add proper observability, and enforce stricter contracts between components.
What can fail
The data source becomes unavailable, A dependency introduces a breaking change, Performance degrades under load, Configuration drift between environments
Monitoring
Monitoring is covered in the Observability section, focusing on distributed metrics, logs, traces and SLOs.
Security
Security was handled by validating input, protecting secrets, and following the practices listed in the Security section.
Deployment strategy
Deployment follows the steps in the Deployment section for the target platform, with a health check to confirm success.
What I'd do differently
With more time I would add deeper test coverage, stronger observability, and automated deployment.
Practice Q&A
Why did you build Multi-Environment Infrastructure Platform?
To demonstrate Structure environments and Promote configs on a real, portfolio-worthy project.
What was the hardest part?
Coordinating the pieces so each stays correct as the project grows, and validating end to end.
How do you handle failure and scale?
By designing explicit failure handling and scale considerations into the architecture.
Extensions
- Add deeper test coverage
- Add observability and alerting
- Harden security
- Automate deployment