Skip to main content

Claude/ChatGPT Prompt to Write a Production AWS VPC Terraform Module

Generate a production-ready Terraform VPC module for AWS with public/private subnets, NAT, flow logs, variables, outputs, and example usage.

Vul de plaatshouders in

Edit the values, then copy your finished prompt.

Jouw Prompt
prompt.txt

                                

What this prompt does

This prompt casts the model as a senior cloud infrastructure engineer writing a reusable Terraform VPC module -- working HCL with sane defaults and documented inputs, not pseudocode. You set [terraform_version], [vpc_cidr], [az_count], and [nat_strategy], and it produces a VPC with public/private subnets, gateways, flow logs, tagging, typed variables, outputs, a README, and a runnable example.

The structure works because a hand-rolled VPC is where subtle subnet and route mistakes hide for months. [vpc_cidr] and [az_count] drive how subnets are carved and spread across availability zones. [nat_strategy] becomes a flag toggling single NAT versus one-per-AZ -- a real cost-versus-availability tradeoff the module exposes rather than hard-codes. [terraform_version] pins the module so syntax matches your toolchain. Flow logs to S3 and a secure default security-group posture come baked in, so the baseline is tagged and observable from the first apply rather than retrofitted later.

When to use it

  • You're standing up AWS networking and want a clean, tagged, flow-logged VPC baseline.
  • You'd rather use a reusable module than copy-paste console clicks into HCL.
  • You need public and private subnets spread correctly across multiple AZs.
  • You want NAT strategy as a toggle so dev can run single and prod one-per-AZ.
  • You need VPC flow logs to S3 and a sane default security-group posture.
  • You want typed variables, meaningful outputs, a README, and an example call.
  • You want a consistent tagging strategy with an input to merge your org's extra tags.

Example output

You get the full file tree of the module: the VPC, subnets, internet gateway, NAT gateways behind the [nat_strategy] flag, route tables, flow-log config, tagging, typed input variables with descriptions and defaults, outputs (vpc_id, subnet IDs, route table IDs), a README, and a runnable example module call. It's pinned to your Terraform version and meant to pass terraform fmt and validate, so it behaves like a module you can reuse rather than a one-off snippet.

Pro tips

  • Set [vpc_cidr] and [az_count] together so the subnet carving leaves enough room per AZ.
  • Flip [nat_strategy] to one NAT per AZ before production -- single-NAT saves money but is a real availability risk.
  • Pin [terraform_version] to your actual toolchain so the generated HCL matches what you run.
  • Run terraform fmt and validate on the output immediately; the prompt asks for it, so leftover issues surface fast.
  • Use the merge-extra-tags input so the module's tagging strategy composes with your org's required tags.
  • Check the default security-group posture matches your policy before applying; defaults should be tightened, not loosened.
  • Carve [vpc_cidr] with future subnets in mind so adding an AZ later doesn't force a re-CIDR.

Frequently Asked Questions

Does this prompt return working Terraform or pseudocode?
It returns working HCL with sane defaults and documented inputs, organized as a full file tree with a runnable example module call. It is pinned to your `[terraform_version]` and intended to pass `terraform fmt` and `validate` rather than being a sketch.
Can I switch between single NAT and one-per-AZ?
Yes. The `[nat_strategy]` variable becomes a flag toggling single NAT versus one NAT per AZ. Single-NAT saves money but is a real availability risk, so flip it to one-per-AZ before production rather than leaving the cheaper default in place.
Are VPC flow logs included?
Yes, the module ships VPC flow logs to S3 plus a secure default security-group posture. Check that the default posture matches your policy before applying, since defaults should be tightened to your needs rather than loosened.
What outputs does the module expose?
It exposes meaningful outputs including vpc_id, subnet IDs, and route table IDs, alongside typed input variables with descriptions and defaults. Those outputs let other stacks consume the network via remote state or data sources without hard-coding IDs.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

Meer in Terraform & Infrastructure as Code Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support