A company's IT team manually provisions S3 buckets, EC2 instances, security groups, and IAM roles for each new project using the AWS Management Console. This process often results in configuration errors, such as overly permissive security rules or incorrect tagging, which the security team then has to fix manually. The company wants to define its entire infrastructure in a declarative template file, store it in version control, and have AWS automatically create or update the resources based on that template. Which AWS service should the company use to meet these requirements?
AWS CloudFormation is the correct service for infrastructure as code. It allows you to define all AWS resources in a declarative template, version-control the template, and automatically create or update the resources as a stack.
Why this answer
AWS CloudFormation is the correct service because it allows you to define your entire infrastructure—including S3 buckets, EC2 instances, security groups, and IAM roles—in a declarative JSON or YAML template. You can store this template in version control, and CloudFormation automatically provisions or updates the resources to match the template, eliminating manual configuration errors like overly permissive security rules or incorrect tagging.
Exam trap
The trap here is that candidates confuse AWS Elastic Beanstalk as an infrastructure-as-code solution because it automates deployment, but it does not provide the declarative template control over all AWS resources that CloudFormation offers.
Why the other options are wrong
AWS Elastic Beanstalk is a PaaS service for deploying and scaling web applications, not for declaratively defining all infrastructure resources (like S3 buckets, IAM roles) in a template. It abstracts infrastructure management rather than providing full control via a declarative template.
AWS OpsWorks is a configuration management service that uses Chef or Puppet, not a declarative template service for defining infrastructure as code. It does not store templates in version control and automatically create/update resources based on a declarative template file.
AWS CodeDeploy automates code deployments to running instances, not infrastructure provisioning. It does not define or manage infrastructure resources like S3 buckets, EC2 instances, or IAM roles from a declarative template.