Introduction
If you've ever spent 40 minutes debugging a YAML indentation error in a GitHub Actions workflow, or manually crafting a Terraform module for the fifth time this week, you know the real pain of DevOps isn't the deploying – it's the typing. While the industry talks about platform engineering and GitOps, the day-to-day reality is still: copy, paste, tweak, pray. But there's a shift underway. AI assistants like ChatGPT and GitHub Copilot are becoming legitimate pair-programmers for infrastructure work, not just for application code.
This article isn't a list of generic 'write a Dockerfile' prompts you've seen a hundred times. It's a battle-tested collection of 15 specific, production-oriented prompts (plus variations) that I use weekly to automate infrastructure, debug CI/CD pipelines, and make sense of noisy logs. No fluff, no theory – just prompts that work, with real examples and the exact syntax you need.
Why this matters now: According to the 2025 State of DevOps Report by Puppet, teams with high AI adoption in their workflows report 23% faster deployment cycles on average. The tools are ready – are your prompts?
The Anatomy of a Good DevOps Prompt
Before diving in, understand the pattern. A weak prompt like "Fix my pipeline" gets you a generic answer. A strong prompt follows the CLEAR framework:
- Context: Provide the tool, version, and environment.
- Logic: Explain what you're trying to achieve, not just what you want.
- Example: Show a sample input/output.
- Action: Specify the format of the response (code, explanation, diff).
- Reference: Point to documentation or standards if relevant.
Here's a before/after comparison:
| Weak Prompt | Strong Prompt |
|---|---|
| "Write a Terraform module for AWS VPC" | "Create a Terraform module for AWS VPC with CIDR 10.0.0.0/16, 3 public and 3 private subnets across 3 AZs, with NAT gateways in each public subnet. Use Terraform 1.5+. Provide the code and a usage example." |
15 Battle-Tested DevOps Prompts
1. Infrastructure Code Generator (Terraform)
Prompt: "Act as a Senior Terraform Engineer. Generate a Terraform configuration for an AWS ECS Fargate service with an Application Load Balancer, auto-scaling based on CPU, and a security group that only allows traffic from the ALB. Use Terraform 1.5+, include variables.tf, main.tf, and outputs.tf. Use the official AWS provider version 5.x."
Why it works: It's specific, versioned, and outputs a complete module structure.
Example output snippet:
resource "aws_ecs_service" "app" {
name = var.app_name
cluster = aws_ecs_cluster.main.id
task_definition = aws_ecs_task_definition.app.arn
desired_count = var.desired_count
capacity_provider_strategy {
capacity_provider = "FARGATE"
weight = 1
}
load_balancer {
target_group_arn = aws_lb_target_group.app.arn
container_name = "app"
container_port = 8080
}
}
2. CI/CD Pipeline Debugger
Prompt: "Here's my GitHub Actions workflow for deploying a Node.js app to AWS Elastic Beanstalk. It fails at the 'Deploy' step with error: 'The supplied authentication has expired'. The workflow worked last week. Identify the likely cause and provide a fix. Include the exact YAML changes needed."
Then paste the workflow file. This prompt works because it gives the AI a concrete error and context.
3. Log Analysis and Root Cause Detection
Prompt: "Analyze the following log snippet from an Nginx server during a traffic spike. Identify any 5xx errors, trace the root cause (e.g., upstream timeouts, file descriptor exhaustion), and suggest specific Nginx configuration tweaks (worker_connections, proxy_read_timeout, etc.) to mitigate it. Here's the log: [paste logs]"
4. Kubernetes Manifest Optimizer
Prompt: "Given this Kubernetes Deployment YAML for a Java microservice, optimize it for production: add resource requests/limits, liveness and readiness probes, pod anti-affinity, and a horizontal pod autoscaler. Explain each change. Use API version apps/v1."
5. Ansible Playbook Writer
Prompt: "Write an Ansible playbook to install and configure Nginx on a group of Ubuntu 22.04 servers. Include a handler to restart Nginx on config change, and use variables for the server_name and root directory. Follow Ansible best practices (e.g., use the 'state: present' for packages, avoid shell when possible)."
6. Dockerfile Reviewer
Prompt: "Review this Dockerfile for a Python Flask app. Suggest improvements for security (non-root user, no root in final image), size (multi-stage builds), and caching (layer ordering). Provide the revised Dockerfile with comments."
7. Cloud Cost Estimator
Prompt: "Estimate the monthly cost of the following AWS architecture: 3 EC2 t3.medium instances (reserved 1 year, all upfront), 1 RDS db.t3.small (single AZ), 500GB S3 with standard storage, and 100GB data transfer out. Use on-demand pricing from the AWS Pricing Calculator (as of August 2026). Provide a breakdown."
Note: AI may not have live pricing, but it can give a solid estimate based on known rates. Always verify.
8. Multi-Cloud Comparison
Prompt: "Compare AWS CodePipeline, GitLab CI/CD, and GitHub Actions for a team of 10 developers working on a microservices project with 5 repos. Focus on: native integration with their ecosystems, pricing, scalability, and learning curve. Create a table with a final recommendation."
9. Security Hardening Advisor
Prompt: "Act as a DevSecOps expert. Here's a list of AWS resources I'm using (S3 buckets, IAM roles, EC2). List the top 5 security risks based on the CIS AWS Foundations Benchmark v3.0.0, and provide a remediation plan for each using Terraform or AWS CLI commands."
10. Legacy Infrastructure Migration Assistant
Prompt: "I have a legacy monolithic app running on a single EC2 instance with an attached EBS volume. I want to migrate it to Docker containers on ECS. Create a step-by-step migration plan, including how to handle stateful data, environment variables, and database connections. Assume the app is a PHP/MySQL monolith."
11. Incident Postmortem Helper
Prompt: "Here's a timeline of a production incident: [describe]. Write a blameless postmortem report following the Atlassian postmortem template. Include a timeline, root cause analysis, and action items with owners."
12. Infrastructure Documentation Generator
Prompt: "Given this Terraform module code (paste), generate comprehensive documentation with a README in Markdown, including a table of inputs/outputs, usage examples, and notes on how to modify for different environments. Use the terraform-docs format."
13. Configuration Drift Detector
Prompt: "Explain how to detect configuration drift in my AWS infrastructure that's managed by Terraform. Provide the exact commands to see drift (terraform plan) and how to integrate this into a CI pipeline. Also, mention tools like AWS Config and how they complement Terraform."
14. Disaster Recovery Plan Generator
Prompt: "Create a disaster recovery plan for a web application hosted on AWS (EC2, RDS, S3). Include RTO and RPO targets, backup strategies, failover steps, and a runbook. Use the AWS Disaster Recovery Service and consider a warm standby approach. Provide a checklist."
15. Prometheus Query Builder
Prompt: "I need a PromQL query to alert when the average CPU usage of my Kubernetes nodes exceeds 85% for 10 minutes. The metric is 'node_cpu_seconds_total' with mode labels. Write the query and a corresponding Prometheus alert rule YAML. Explain the query logic."
Example alert rule:
groups:
- name: node-cpu
rules:
- alert: HighNodeCPU
expr: avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m]) < 0.15)
for: 10m
labels:
severity: warning
annotations:
summary: "High CPU on {{ $labels.instance }}"
Practical Tips for Using AI in DevOps
- Verify, don't trust: AI-generated Terraform can have subtle bugs. Always run
terraform planin a sandbox first. - Use versioned prompts: Mention tool versions (e.g., "Kubernetes 1.29") to get accurate syntax.
- Iterate: The first response is rarely perfect. Ask follow-ups like "Now optimize for security" or "Add error handling."
- Combine with Copilot: For inline code completion, use GitHub Copilot in your IDE for quick snippets, and reserve ChatGPT for complex, multi-file tasks.
Conclusion
AI won't replace DevOps engineers, but it will replace those who don't use it. The prompts above are starting points – customize them to your stack, and you'll find yourself shipping infrastructure faster and debugging less. Start with one prompt from this list today, apply it to a real task, and iterate. The future of infrastructure is conversational – and it's already here.
What's your go-to AI DevOps prompt? Share your experience in the comments below, or reach out on LinkedIn. For more insights on AI-assisted workflows, explore our blog at asibiont.com/blog.
Comments