Capstone – End-to-End Hybrid On-Prem & Cloud Deployment Pipeline
Real-world enterprise platforms rarely run a single language or a single hosting environment. You might have a core billing API written in ASP.NET Core, a customer-facing gateway in Node.js, on-prem servers for compliance workloads, and cloud instances for elastic scale. Stitching these together manually is fragile and slow.
In this capstone, you will combine the complete HashiCorp automation stack—Packer, Terraform, Vault, Consul, and Nomad—into one cohesive, repeatable pipeline. Every layer hands off cleanly to the next, from building immutable images all the way to live service discovery and a clean terraform destroy teardown.
- Packer: Build versioned, immutable container images for both an ASP.NET Core API and a Node.js gateway.
- Terraform: Provision the target infrastructure, network, Vault policies, and Nomad job deployments declaratively.
- Vault: Issue short-lived, dynamic secrets injected directly into running services without hardcoding credentials.
- Consul & Nomad: Schedule both workloads across hybrid nodes with automatic health checks and DNS/HTTP service discovery.
- Clean Teardown: Decommission all jobs, secrets, and infrastructure in one command using
terraform destroy.
1. How the Five Tools Fit Together
Each tool in the pipeline owns a single responsibility. Because they share HCL (HashiCorp Configuration Language) and native integrations, you avoid brittle glue scripts.
| Stage | Tool | Responsibility in This Pipeline | Output Passed Forward |
|---|---|---|---|
| 1. Build | Packer | Bakes ASP.NET Core & Node.js into immutable, tagged images | Versioned image tags + packer-manifest.json |
| 2. Provision | Terraform | Creates networks, Vault roles/secrets, and submits Nomad jobs | Live infrastructure & Terraform state |
| 3. Secure | Vault | Generates dynamic, lease-bound API keys & DB credentials | Short-lived secrets injected at runtime |
| 4. Discover | Consul | Registers healthy service instances & resolves service endpoints | Dynamic service catalog & health checks |
| 5. Schedule | Nomad | Runs ASP.NET Core & Node.js across on-prem and cloud nodes | Healthy, self-healing application allocations |
2. End-to-End Animated Architecture
Watch how an application release flows from Packer image builds through Terraform provisioning, pulls dynamic secrets from Vault, registers in Consul, and runs on Nomad.
Automated Hybrid Pipeline: Packer → Terraform → Vault + Consul → Nomad
Each stage highlights in sequence: Packer builds the images, Terraform provisions state, Vault injects dynamic secrets, Consul registers services, and Nomad schedules both ASP.NET Core and Node.js across hybrid datacenters.
3. Hands-On Lab: Full End-to-End Pipeline
You can run this entire capstone locally using Docker plus HashiCorp CLI binaries (packer, terraform, vault, consul, nomad) in dev mode. This mirrors a production hybrid topology without incurring cloud charges.
Project folder structure
hybrid-capstone/
├── packer/
│ └── images.pkr.hcl # Builds ASP.NET Core & Node.js images
├── terraform/
│ ├── main.tf # Vault secrets/policies + Nomad jobs
│ └── variables.tf # Release version & cluster endpoints
├── nomad/
│ ├── dotnet-api.nomad.hcl # ASP.NET Core job (dc=onprem)
│ └── node-gateway.nomad.hcl # Node.js job (dc=cloud)
└── scripts/
└── start-stack.sh # Starts local Consul, Vault, Nomad
Step 1: Start local Consul, Vault, and Nomad agents
Open a terminal and launch the three control-plane services in dev mode. In production, these run as clustered systemd services across your on-prem and cloud subnets.
Start the local control plane
# Terminal 1: Consul (Service Discovery)
consul agent -dev -ui
# Terminal 2: Vault (Dynamic Secrets)
vault server -dev -dev-root-token-id="root-dev-token"
# Terminal 3: Nomad (Hybrid Workload Scheduler)
nomad agent -dev -bind=0.0.0.0 -network-interface='{{ GetDefaultInterfaces | attr "name" }}'
Step 2: Build immutable ASP.NET Core & Node.js images with Packer
Create packer/images.pkr.hcl. This single template produces both upgradix/dotnet-api:v2.0.0 and upgradix/node-gateway:v2.0.0 and writes a build manifest.
File: packer/images.pkr.hcl
packer {
required_plugins {
docker = {
version = ">= 1.0.8"
source = "github.com/hashicorp/docker"
}
}
}
variable "release_version" {
type = string
default = "v2.0.0"
}
source "docker" "dotnet_api" {
image = "mcr.microsoft.com/dotnet/aspnet:8.0"
commit = true
changes = [
"ENV ASPNETCORE_URLS=http://+:5000",
"EXPOSE 5000",
"LABEL com.upgradix.service=dotnet-api",
"LABEL org.opencontainers.image.version=${var.release_version}"
]
}
source "docker" "node_gateway" {
image = "node:20-alpine"
commit = true
changes = [
"ENV PORT=3000",
"EXPOSE 3000",
"LABEL com.upgradix.service=node-gateway",
"LABEL org.opencontainers.image.version=${var.release_version}"
]
}
build {
name = "capstone-release"
sources = [
"source.docker.dotnet_api",
"source.docker.node_gateway"
]
post-processor "docker-tag" {
only = ["docker.dotnet_api"]
repository = "upgradix/dotnet-api"
tags = [var.release_version]
}
post-processor "docker-tag" {
only = ["docker.node_gateway"]
repository = "upgradix/node-gateway"
tags = [var.release_version]
}
post-processor "manifest" {
output = "packer-manifest.json"
strip_path = true
}
}
Build both images
cd packer
packer init .
packer build -var "release_version=v2.0.0" .
cd ..
Step 3: Define Nomad jobs with Consul discovery & Vault secrets
First, create the ASP.NET Core job in nomad/dotnet-api.nomad.hcl. It registers itself in Consul as dotnet-api and pulls its runtime API secret from Vault via a Nomad template block.
File: nomad/dotnet-api.nomad.hcl
job "dotnet-api" {
datacenters = ["dc1"]
type = "service"
group "api" {
count = 1
network {
port "http" { to = 5000 }
}
service {
name = "dotnet-api"
port = "http"
provider = "consul"
tags = ["onprem", "aspnet-core"]
check {
type = "http"
path = "/health"
interval = "10s"
timeout = "2s"
}
}
task "dotnet-server" {
driver = "docker"
vault {
policies = ["capstone-app-policy"]
}
template {
data = <<EOF
{{ with secret "secret/data/capstone/runtime" }}
API_SHARED_KEY="{{ .Data.data.api_key }}"
DB_CONNECTION="{{ .Data.data.db_conn }}"
{{ end }}
EOF
destination = "secrets/app.env"
env = true
}
config {
image = "upgradix/dotnet-api:${release_version}"
ports = ["http"]
}
}
}
}
Next, create the Node.js gateway job in nomad/node-gateway.nomad.hcl. Notice how it uses Consul's template query (service "dotnet-api") to discover the ASP.NET Core API address dynamically—no hardcoded IP addresses anywhere.
File: nomad/node-gateway.nomad.hcl
job "node-gateway" {
datacenters = ["dc1"]
type = "service"
group "gateway" {
count = 1
network {
port "http" { to = 3000 }
}
service {
name = "node-gateway"
port = "http"
provider = "consul"
tags = ["cloud", "nodejs"]
}
task "node-server" {
driver = "docker"
vault {
policies = ["capstone-app-policy"]
}
# Inject both Consul-discovered upstream URL and Vault secret
template {
data = <<EOF
{{ range service "dotnet-api" }}
DOTNET_API_URL="http://{{ .Address }}:{{ .Port }}"
{{ end }}
{{ with secret "secret/data/capstone/runtime" }}
API_SHARED_KEY="{{ .Data.data.api_key }}"
{{ end }}
EOF
destination = "secrets/gateway.env"
env = true
}
config {
image = "upgradix/node-gateway:${release_version}"
ports = ["http"]
}
}
}
}
Step 4: Provision Vault secrets & Nomad jobs with Terraform
Create terraform/main.tf to tie everything together. Terraform configures the Vault policy, writes the runtime secret, and deploys both Nomad jobs with the exact Packer release_version.
File: terraform/main.tf
terraform {
required_providers {
vault = {
source = "hashicorp/vault"
version = "~> 4.2"
}
nomad = {
source = "hashicorp/nomad"
version = "~> 2.3"
}
}
}
variable "release_version" {
type = string
default = "v2.0.0"
}
provider "vault" {
address = "http://127.0.0.1:8200"
token = "root-dev-token"
}
provider "nomad" {
address = "http://127.0.0.1:4646"
}
# 1. Vault Policy granting read-only access to capstone secrets
resource "vault_policy" "capstone_app" {
name = "capstone-app-policy"
policy = <<EOT
path "secret/data/capstone/runtime" {
capabilities = ["read"]
}
EOT
}
# 2. Store runtime credentials in Vault KV v2
resource "vault_kv_secret_v2" "runtime_secrets" {
mount = "secret"
name = "capstone/runtime"
data_json = jsonencode({
api_key = "dyn-key-2026-rotatable"
db_conn = "Server=hybrid-sql.service.consul;Database=Orders;User=app_svc;"
})
}
# 3. Deploy ASP.NET Core API on Nomad
resource "nomad_job" "dotnet_api" {
jobspec = templatefile("${path.module}/../nomad/dotnet-api.nomad.hcl", {
release_version = var.release_version
})
depends_on = [vault_policy.capstone_app, vault_kv_secret_v2.runtime_secrets]
}
# 4. Deploy Node.js Gateway on Nomad
resource "nomad_job" "node_gateway" {
jobspec = templatefile("${path.module}/../nomad/node-gateway.nomad.hcl", {
release_version = var.release_version
})
depends_on = [nomad_job.dotnet_api]
}
Apply the full stack with Terraform
cd terraform
terraform init
terraform apply -var="release_version=v2.0.0" -auto-approve
Expected output (abbreviated)
vault_policy.capstone_app: Creation complete after 0s [id=capstone-app-policy] vault_kv_secret_v2.runtime_secrets: Creation complete after 0s [id=secret/data/capstone/runtime] nomad_job.dotnet_api: Creation complete after 2s [id=dotnet-api] nomad_job.node_gateway: Creation complete after 2s [id=node-gateway] Apply complete! Resources: 4 added, 0 changed, 0 destroyed.
Step 5: Verify Consul discovery and Nomad allocations
Confirm that both services are running in Nomad and registered as healthy in Consul.
Verify live services
nomad job status
consul catalog services
Expected output
ID Type Priority Status Submit Date dotnet-api service 50 running 2026-11-27T19:45:10+05:30 node-gateway service 50 running 2026-11-27T19:45:12+05:30 consul dotnet-api node-gateway
Step 6: Run a clean teardown with terraform destroy
When your test or ephemeral environment is finished, tear down all Nomad jobs, Vault secrets, and Vault policies in reverse dependency order with a single command.
Clean teardown
terraform destroy -var="release_version=v2.0.0" -auto-approve
Expected output
nomad_job.node_gateway: Destruction complete after 1s nomad_job.dotnet_api: Destruction complete after 1s vault_kv_secret_v2.runtime_secrets: Destruction complete after 0s vault_policy.capstone_app: Destruction complete after 0s Destroy complete! Resources: 4 destroyed.
root-dev-token in production Terraform code. Use Vault's AppRole, OIDC, or cloud IAM authentication so Terraform and Nomad authenticate with short-lived, least-privilege tokens.4. Step-by-Step Execution Breakdown
v2.0.0, guaranteeing identical runtimes across on-prem and cloud hosts.secrets/app.env in memory, and automatically renews or rotates credentials before lease expiry.DOTNET_API_URL into the Node.js gateway.terraform destroy cleanly stops both workloads, deregisters them from Consul, and removes the Vault secrets without leaving orphaned resources.5. Hands-On Practice
Update count = 1 to count = 3 in nomad/node-gateway.nomad.hcl and run terraform apply.
Expected result: Nomad launches 3 gateway allocations and Consul registers all 3 healthy instances automatically.
Build new Packer images with -var "release_version=v2.1.0", add an update { max_parallel = 1 } stanza to your Nomad job, and run terraform apply -var="release_version=v2.1.0".
Expected result: Nomad replaces allocations one at a time with zero downtime.
Add a Nomad constraint block so dotnet-api schedules only on nodes with meta.env = "onprem" and node-gateway schedules on meta.env = "cloud".
Hint: Use attribute = "${meta.env}" inside the Nomad constraint stanza.
6. Interview Questions
Answer: Each tool excels at one layer of the lifecycle: Packer handles immutable image building, Terraform manages declarative infrastructure state, Vault secures dynamic secrets, Consul provides cross-environment service discovery, and Nomad schedules both containers and non-containerized binaries across hybrid nodes with minimal operational overhead.
Answer: Secrets are never baked into Packer images or committed to Git. Instead, Nomad requests short-lived tokens from Vault on behalf of each task, renders secrets into an in-memory tmpfs volume (secrets/), and automatically revokes the token when the allocation stops.
terraform destroy in this pipeline?
Answer: Terraform reads its state graph and destroys resources in reverse dependency order: it stops the Node.js and ASP.NET Core Nomad jobs first (which automatically deregisters them from Consul), and then deletes the Vault KV secrets and access policies, leaving a completely clean environment.
Conclusion
You now have a complete blueprint for running polyglot workloads—ASP.NET Core and Node.js—across hybrid on-prem and cloud infrastructure without manual intervention. By pairing immutable Packer builds with Terraform state, Vault dynamic secrets, Consul discovery, and Nomad scheduling, your team gains faster releases, stronger security, and effortless teardowns.
Official Documentation
- HashiCorp Packer Documentation
- HashiCorp Terraform Documentation
- HashiCorp Vault Documentation
- HashiCorp Consul Documentation
- HashiCorp Nomad Documentation
Upgradix by Shrash Studio – Learn Technology. Build Your Future.
Discussion & Comments
0No comments yet
Start the discussion above — ask a question, share a tip, or reply to a comment.