Prompt
How do I define cloud infrastructure in code instead of using the console?
Latest observation
Oct 24, 2026
OpenAI APIWeb search: off
To define cloud infrastructure in code instead of clicking around in the cloud console, you use Infrastructure as Code (IaC).
What it is
IaC means writing declarative or scripted files that describe the resources you want, such as:
- virtual networks
- servers / instances
- databases
- storage buckets
- IAM roles and permissions
- load balancers
- Kubernetes clusters
Then a tool reads that code and creates or updates the infrastructure for you.
Common IaC tools
Popular options include:
- Terraform — cloud-agnostic, very common
- AWS CloudFormation — AWS-specific
- Azure Bicep / ARM templates — Azure-specific
- Google Cloud Deployment Manager — GCP-specific
- Pulumi — lets you use general-purpose languages like Python, TypeScript, Go
Basic workflow
- Write infrastructure definitions in code
- Run a tool to validate/plan changes
- Apply the changes to provision resources
- Store the code in version control like Git
- Reuse it across environments like dev, staging, prod
Example with Terraform
A simple Terraform file might define an AWS S3 bucket:
provider "aws" {
region = "us-east-1"
}
resource "aws_s3_bucket" "example" {
bucket = "my-example-bucket-12345"
}
Then you run:
terraform init
terraform plan
terraform apply
Why use it
- reproducible environments
- easier reviews via code changes
- less manual error
- faster setup
- better collaboration
- easier rollback and auditability
Good practices
- keep IaC in Git
- modularize reusable pieces
- parameterize per environment
- avoid manual console changes if possible
- use state management carefully
- run plan/review before apply
If you want, I can show you how to define a simple cloud setup in Terraform, AWS CloudFormation, or Pulumi.