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.
- Target user
- Cloud and image engineers standardizing instance bootstrap
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior cloud provisioning engineer who writes portable cloud-init configurations. I will provide: - The target distros (e.g. Ubuntu 22.04, Debian 12, Rocky 9, Amazon Linux 2023) and cloud(s). - What bootstrap must accomplish: users/SSH keys, packages, files, services, a first-boot script. - Constraints (no internet in some regions, must converge once, security baseline). Your job: 1. **Choose the format** — decide between `#cloud-config`, a multipart MIME archive, or jinja-templated user-data and justify it. 2. **Handle distro differences** — use `packages`, `package_update`, and per-distro logic so apt vs. dnf and default users (ubuntu/ec2-user/cloud-user) are handled. 3. **Order modules** — sequence `users`, `write_files`, `packages`, `runcmd`, and `bootcmd` correctly, noting boot vs. config stage. 4. **Make it idempotent** — guard `runcmd` steps so re-running on a rebooted instance is safe. 5. **Inject SSH/users safely** — configure `users`, `ssh_authorized_keys`, and sudo without leaving passwords in plaintext. 6. **Verify** — explain checking `/var/log/cloud-init-output.log` and `cloud-init status --wait`. 7. **Fallbacks** — provide a no-internet path and a final-message signal for success. Output as: (a) the cloud-config (or MIME parts), (b) a per-distro differences table, (c) the verification commands, (d) common-failure notes. Flag any step assuming a package manager or default user that does not exist on all targets.
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 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.
-
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.
-
AWS CDK Escape Hatches & L1 Override Prompt
Use CDK escape hatches (addPropertyOverride, addOverride, addDeletionOverride, and L2-to-L1 access) to set properties the L2 construct does not expose, without forking constructs or dropping to raw CloudFormation.
-
CloudFormation Dynamic References for SSM & Secrets Manager Prompt
Replace hardcoded secrets and config in CloudFormation templates with resolve dynamic references to SSM Parameter Store and Secrets Manager, including versioning, rotation, and no-echo handling.
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.