This is a submission for the Amazon Q Developer "Quack The Code" Challenge: Crushing the Command Line
What I Built
I built DevOps Config File Generator, a command-line automation tool powered by the Amazon Q Developer CLI. It intelligently generates essential DevOps configuration files—such as Dockerfiles, Terraform scripts, Kubernetes manifests, and GitHub Actions workflows—based on prompt templates or custom input.
Setting up infrastructure and CI/CD pipelines typically involves repetitive boilerplate files. While customizable, these files often follow predictable patterns that are time-consuming and error-prone to recreate manually. My tool solves this by:
- Providing ready-to-edit, high-quality configs
- Reducing setup time and manual errors
- Enabling prompt-based, context-aware file generation
It’s like having an AI-powered config assistant that assists with your DevOps daily tasks.
Demo
🎥 Video 1: Generating a Dockerfile using a pre-defined prompt
python3 main.py dockerfile
In this video, you can see the usage of the Dockerfile config prompt defined in the CONFIG dictionary within the config.py file. The command python3 main.py dockerfile is run, which triggers the tool to start a subprocess that interacts with the Amazon Q CLI using the chat option. The result is then saved to a Dockerfile in the root directory.
🎥 Video 2: using the --prompt
flag
In the second demo, you can see the usage of --prompt
flag and then passing a completely custom prompt that overwrites the previous Dockerfile, allowing the user to generate a Dockerfile based on their specific requirements and needs
🎥 Video3: using interactive mode with --multi-stage
demostration capabilities
In this lengthy demo, I:
- Choose a file type interactively
- Provide a prompt to generate an AWS VPC with public/private subnets
- Enable
--multi-stage
for step-by-step confirmation
This results in separate generation stages for main.tf
, variables.tf
, and outputs.tf
, each requiring approval before proceeding—perfect for infrastructure tasks.
Code Repository
You can explore the full source code for this project on my GitHub repository.
The README includes installation instructions and guides for trying the tool locally.
How I Used Amazon Q Developer
I used Amazon Q Developer CLI as the intelligence engine behind a lightweight Python wrapper. Here's how:
- Configuration via
config.py
To manage various file generation scenarios, I created a centralizedCONFIG
dictionary in config.py. Each entry defines a prompt and the corresponding output files. Here's an example for generating a generic Dockerfile:
CONFIG = {
'dockerfile': {
'prompt': 'Generate a simple generic Dockerfile template for a containerized application. Include comments explaining each instruction. Do not assume a specific language or framework.',
'files': ['Dockerfile']
},
}
- Triggering Q CLI with Python
Using
subprocess.run([...])
, my tool wraps Amazon Q’schat
command to automate code generation:
subprocess.run(['q', 'chat', '--trust-all-tools', '--prompt', prompt])
This allows for seamless prompt execution and result handling within a Python environment.
- Tool Permissions and a Word of Caution
In my demo, I used the
--trust-all-tools
flag so Q could write files directly (fs_write) without asking for confirmation every time. ⚠ Important warning: Using--trust-all-tools
can be risky because it gives Q blanket access to system-level operations like writing files, executing commands, and interacting with AWS. You should only use it in safe or sandboxed environments. To learn more about this flag and tool-level permissions, refer to:
Multi-Stage Mode = Safer Generations
Enable the --multi-stage
mode to break the generation process into two phases:
- Plan – Preview changes or file content
- Execute – Approve or edit before committing to the file system
This is especially helpful for generating multiple files or sensitive infrastructure code.
Use Q as a Live Coding Assistant
Instead of relying on tools like Amazon Q to write code for you, try using them to teach you how to write it. Think of it like having training wheels while you explore new technologies—guiding you through best practices as you build real-world solutions.
Amazon Q can work like a context-aware CLI chatbot. Try:
cat Dockerfile | q "Explain and optimize this for production"
or
aws cloudformation describe-stacks | q "Summarize this output and point out misconfigurations"
Think of CONFIG
like an Extensible Prompt Library
You can easily add new file types by updating the CONFIG
dictionary—no need to change the Python logic.
Experiment Freely, then Edit
Because Q’s output is saved locally, you can iterate on your config until it meets your standards. You own the final version.
🙏 Thank You!
Working on this project was a lot of fun, not just for the competition, but for the love of building and experimenting. I genuinely enjoyed every step, especially discovering how powerful Amazon Q can be. I didn’t expect such outstanding results from it, and I’m excited to keep exploring what it can do.
Top comments (0)