參考答案
AWS offers a native IaC service called AWS CloudFormation. You define templates (in YAML/JSON) describing resources like EC2 instances, VPCs, S3 buckets, etc., and CloudFormation provisions them in order, handling dependencies. Alternatively, many DevOps teams use Terraform (an open-source IaC tool) for AWS, which is cloud-agnostic but very popular for AWS automation.
A good answer can mention both:
- CloudFormation: tightly integrated, supports all AWS resources, allows you to manage stacks (groups of resources). You might use CloudFormation to set up the entire infrastructure for an application (network, security groups, EC2, RDS database, etc.). It's declarative – you describe the end state and CloudFormation figures out create/update/delete actions. CloudFormation also has a concept of Change Sets so you can review changes before applying.
- Terraform: also declarative and widely used. Companies often prefer Terraform if they operate multi-cloud or find its language (HCL) more flexible. Terraform uses a state file to track created resources. In an AWS DevOps scenario, you might use Terraform scripts stored in Git, and perhaps run Terraform in a pipeline (with something like terraform plan/apply steps). In fact, AWS CodeBuild can be used to run Terraform, and there are AWS blog posts demonstrating Terraform-based pipelines .
- AWS CDK (Cloud Development Kit): If you want to show extra knowledge, mention AWS CDK, which lets you write infrastructure code in higher-level languages (Python, TypeScript, etc.) which then synthesize to CloudFormation templates. This is relatively new but shows you're aware of modern IaC trends.
Benefits on AWS: consistency across regions and accounts, ability to version and code-review infra changes. You can also tie IaC into CI/CD: for example, pushing a CloudFormation template to an S3 bucket and triggering a deployment, or using CodePipeline with a CloudFormation action to deploy infra changes.
Example: "I'm a fan of Terraform on AWS. In one project, we codified everything: VPCs, subnets, security groups, EC2 instances, and even CodePipeline itself using Terraform. We stored .tf files in Git; our Jenkins pipeline would run terraform plan for review and then terraform apply. This approach meant we could recreate our entire AWS stack from scratch in a new region in about 20 minutes. It also prevented configuration drift. Alternatively, AWS's own CloudFormation is great – I've used it for simpler setups. For instance, we had a CloudFormation template for a basic web app environment (Auto Scaling Group, Load Balancer, RDS database). Developers could launch a full stack for testing by simply deploying the template."