Migrate a legacy app with config files baked into the VM image to an immutable deployment model. Where do you start?

IntermediateScenarioMigrations
Answer

Situation read → Immutable means the artifact never changes after build; config comes from outside at runtime.

What I'd do →

  1. Find all config on the box: diff a running server against a clean image, and check /etc, app directories and environment files. Ansible facts or rpm -Va/debsums help spot changed files.
  2. Split into code (goes in the image), config (environment-specific, goes to SSM, Secrets Manager or ConfigMaps) and data (goes to managed storage).
  3. Build the image in CI with Packer or Docker; no SSH-and-edit after.
  4. Deploy by replacing instances (ASG instance refresh) rather than patching them.
aws autoscaling start-instance-refresh --auto-scaling-group-name legacy-app --preferences MinHealthyPercentage=90
  1. Remove SSH access once you trust it; use SSM Session Manager for break-glass.

Why → If a server can be edited by hand, it eventually will be, and drift follows.

Interview tip → "Replace, don't patch" summarises immutable infrastructure.

All Real-World Interview questions Roadmap: Interview readiness

More on Migrations