Why Infrastructure as Code Matters
Свайпніть щоб показати меню
Sven's team launched a new feature on a Thursday. The production stack — 14 EC2 instances, an Application Load Balancer, an RDS database, an SQS queue, two S3 buckets, eight security groups — had been built by hand over six months. On Saturday, half of us-east-1 had a brief networking issue. The team needed to spin up the entire stack in us-west-2 as a failover. It took 36 hours.
The team next door, with everything in code, did it in 23 minutes.
This chapter is about why "everything in code" is one of the most leveraged habits a cloud developer can build — and why every AWS Developer Associate exam covers it heavily.
What Infrastructure as Code Actually Means
Infrastructure as Code (IaC) is the practice of defining cloud resources in text files — YAML, JSON, or a programming language — and using those files as the source of truth for what exists in your AWS account.
Instead of clicking through the console to create a Lambda, an IAM role, and an S3 bucket, you write:
Resources:
MyBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-app-uploads
Then you run a deploy command, and AWS creates exactly what the file describes.
The Four Promises of IaC
IaC trades upfront effort for four big payoffs:
- Reproducibility — the same template builds the same stack in any region or account;
- Version control — every change to your infrastructure goes through Git, with diffs, reviews, and history;
- Rollback — if a deploy breaks something, revert the commit and redeploy;
- Documentation — the template is the documentation. There is no out-of-date diagram in Confluence. Sven's team had none of these. They had a Confluence page from January and a Slack thread.
ClickOps Does Not Scale
The opposite of IaC is the practice of clicking around the AWS console — informally called ClickOps. It works at the size of one developer and one project. It collapses at the size of:
- More than one environment (dev, staging, prod must match);
- More than one region for regional failover;
- More than one engineer (who created this security group? why?);
- More than one customer with isolated infrastructure. The day someone says "we need to give every enterprise customer their own VPC," ClickOps dies.
The AWS IaC Family
AWS gives you several ways to do IaC:
- AWS CloudFormation — the foundational service. YAML or JSON templates, declarative, supports almost every AWS service;
- AWS SAM (Serverless Application Model) — a thin layer on top of CloudFormation, optimized for Lambda + API Gateway + DynamoDB serverless apps;
- AWS CDK (Cloud Development Kit) — define infrastructure in TypeScript, Python, Java, Go, or C#. The CDK synthesizes a CloudFormation template under the hood;
- Terraform — third-party, multi-cloud. Common in industry but not an AWS-native service, so less emphasized on the exam. For the Developer Associate exam, focus on CloudFormation and SAM, with awareness of CDK. We will spend the next four chapters on each.
Where to Start
If you are new to IaC, the on-ramp is gentler than it looks. Start by writing a CloudFormation template for the smallest stack you can — a single S3 bucket. Deploy it. Modify it. Tear it down. Redeploy.
The mental shift, once it lands, is permanent: you stop thinking "I will go create that" and start thinking "I will add it to the template."
Дякуємо за ваш відгук!
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат