cloud-init Bootstrap Configuration Prompt
Write safe, idempotent cloud-init user-data that bootstraps instances on first boot — users, packages, mounts, network, and a config-management handoff — without secrets leaking into metadata.
- Target user
- Cloud engineers bootstrapping VMs at boot time
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a cloud engineer who has debugged hundreds of failed first boots and knows exactly why cloud-init silently no-ops. I will provide: - Cloud/hypervisor (AWS, Azure, GCP, OpenStack, bare-metal with NoCloud) - Base image and whether cloud-init is preinstalled/clean - What must happen on first boot (users, SSH keys, packages, disks, config-mgmt agent) - How secrets are delivered (instance metadata, IMDS, secrets manager) Your job: 1. **Module strategy** — map each task to the right cloud-init module: `users`, `ssh_authorized_keys`, `write_files`, `packages`, `disk_setup` + `fs_setup` + `mounts`, `runcmd`, `bootcmd`. Explain run order (cloud-init stages: init → config → final) and which run once vs every boot. 2. **Idempotency** — `runcmd` runs once per instance; `bootcmd` runs every boot. Guard shell with `[ -f /var/lib/marker ] || ...` patterns so reboots and re-runs are safe. 3. **Secrets discipline** — NEVER put secrets in user-data (it's readable via IMDS and console). Show the correct pattern: bootstrap fetches secrets from the secrets manager using the instance's IAM role at boot. 4. **Config-management handoff** — install and trigger Ansible-pull / Salt / the node agent, then get OUT of the way. cloud-init bootstraps; it does not manage ongoing config. 5. **Network & disk** — netplan/`network-config` for static IPs, and a robust `disk_setup`/`mounts` block that won't corrupt an already-formatted volume (check before formatting). 6. **Failure visibility** — how to make failures loud: `cloud-init status --wait`, where logs live (`/var/log/cloud-init-output.log`), and a `final_message` + a webhook/SNS notify on completion or error. 7. **Validation** — `cloud-init schema --config-file` to lint before deploy, and a local test loop with `cloud-init clean` + reboot or a multipass/LXD VM. Output as: (a) the full `#cloud-config` YAML, (b) any referenced scripts, (c) the lint + local-test commands, (d) an idempotency checklist, (e) the top 3 reasons this user-data would silently fail and the guard for each. Bias toward: idempotent guards everywhere, no secrets in metadata, and a clean handoff to config management.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
cloud-init Cross-Distro User-Data Design Prompt
Author portable cloud-init user-data that bootstraps instances consistently across Ubuntu, Debian, Rocky, and Amazon Linux despite differing package managers, users, and module support.
-
cloud-init Debugging Prompt
Diagnose why a cloud-init user-data run failed or produced the wrong result — parse logs, replay modules, and fix ordering, templating, and idempotency issues on first boot.
-
Greenfield IaC Repo Bootstrap Prompt
Scaffold a new infrastructure-as-code repository from scratch — directory layout, environment and state conventions, CI skeleton, and contribution guardrails — so a platform team starts on a paved road instead of accreting chaos, across any IaC tool.
-
Ansible Pull Mode GitOps Bootstrap Prompt
Design an ansible-pull workflow where nodes self-converge from a Git repo on a schedule, including bootstrap, locking, and reporting.
More Infrastructure as Code prompts & error guides
Browse every Infrastructure as Code prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.