Prompt used:
“Generate a Terraform module that provisions an S3 bucket and aligns it with the API defined in the spec.”
What I ran it on
I started with a small OpenAPI definition in Postman for a Media Storage API that wraps S3, not just a generic bucket:
-
PUT /upload/{key}to upload media objects, withContent-Typerestricted toimage/jpeg,image/png, orvideo/mp4. -
GET /{key}andDELETE /{key}to read and delete objects from a given bucket. -
The server URL and
bucketparameter encode a naming convention likemedia-[a-z0-9]+-(dev|staging|prod), so the bucket name pattern is part of the contract, not a comment.
This gave Agent Mode a clear description of how the bucket should behave and how it would be used by clients.
What the agent built for me
From that API spec and a single prompt, Agent Mode produced a production-ready S3 Terraform module, not just a single resource:
-
main.tf-
aws_s3_bucketwithforce_destroy, standard tags (Name,ManagedBy = "Terraform") plus custom tags. -
aws_s3_bucket_versioningcontrolled by aversioning_enabledvariable. -
aws_s3_bucket_server_side_encryption_configurationthat supports AES256 by default and optionally KMS withkms_master_key_idandbucket_key_enabled. -
aws_s3_bucket_public_access_blockandaws_s3_bucket_ownership_controlswired to variables and defaulting to secure settings. -
aws_s3_bucket_lifecycle_configurationbuilt from a high-levellifecycle_rulesvariable using nesteddynamicblocks for transitions, expirations, and noncurrent versions. -
Optional
aws_s3_bucket_loggingdriven bylogging_enabled,logging_target_bucket, andlogging_target_prefix.
-
-
variables.tf-
A
bucket_namevariable with length and regex validation that matches AWS naming rules, turning my spec’s naming convention into real guardrails. -
Switches for versioning, force destroy, encryption mode, KMS key, public access flags, ownership mode, lifecycle rules, and logging, so teams can tune behavior without touching HCL
-
-
outputs.tf-
All the identifiers other stacks need: bucket ID, ARN, domain names, region, hosted zone ID.
-
Outputs for
versioning_enabled,encryption_algorithm, andkms_key_id, plus helper ARN patterns for bucket‑ and object‑level IAM policies.
-
-
README.md-
A clear module description, input/output tables, and a copy‑pasteable example:
module "s3_bucket" { source = "./terraform-aws-s3-bucket" bucket_name = "my-unique-bucket-name" versioning_enabled = true tags = { Environment = "production" } }
-
How I tested it with Terraform
As a follow-up, I asked Agent Mode to “Test the module with terraform init and terraform plan?”, and it generated a test.tf file to exercise the module in isolation:
-
It configured the AWS provider with
skip_credentials_validation,skip_metadata_api_check, andskip_requesting_account_id, plus mock access keys, so I could runplanlocally without real AWS credentials. -
It added a
random_stringresource to generate a unique suffix for the bucket name. -
It instantiated my module as
module "test_s3_bucket"with:bucket_name = “test-bucket-${random_string.bucket_suffix.result}” tags = { Environment = “test” Project = “terraform-module-test” ManagedBy = “terraform” } -
It exposed
test_bucket_idandtest_bucket_arnoutputs for quick verification.
With that file in place, I ran: terraform init and terraform plan and was able to validate that the generated module plans cleanly end‑to‑end without needing to hand-write any test harness.
What changed in my workflow
Normally, taking an API spec for S3-backed media storage all the way to a reusable, tested Terraform module means hours of work: designing the bucket config, encoding encryption and public access best practices, wiring lifecycle rules and logging, exposing useful outputs, writing documentation, and then building a separate test configuration to run plan.
With Agent Mode in Postman, I stayed in a single workspace: I defined the API once, used one prompt to get a production-grade S3 module, and a follow-up prompt to get a ready-to-run test.tf for terraform init and terraform plan. My role shifted from writing Terraform and test harnesses to reviewing them - which is exactly the kind of workflow upgrade I want from an AI agent.






