Arkinu
AWS service comparison

AWS CloudFormation vs AWS Elastic Beanstalk: differences and when to use each

AWS CloudFormation
AWS Elastic Beanstalk

Often confused on the examQuestions tend to offer one as a distractor for the other: look for the phrase in the scenario that tips the balance.

Management and Governance

AWS CloudFormation

Infrastructure as code service: you describe the AWS resources you want in a template, and CloudFormation provisions and configures them as a single unit (a stack). It lets you replicate infrastructure consistently and manage its changes as if it were code.

Exam phrases that point here

  • «provision infrastructure as code in a repeatable and predictable way»

    CloudFormation creates and manages a set of related resources from a declarative template: the same file produces the same environment every time, with version control and automatic rollback.

    When not: If the team only wants to upload a web application's code and have AWS handle capacity and deployment, AWS Elastic Beanstalk fits (it uses CloudFormation under the hood). If it prefers to define the infrastructure with a programming language, there is the AWS CDK, which generates CloudFormation templates.

  • «replicate the same environment in another Region or for another team»

    A parameterized template can be deployed as many times as needed; CloudFormation generates unique names from the stack name so that stacks do not collide with each other.

    When not: The template recreates the infrastructure, not the data: for disaster recovery you have to replicate or back up the data separately (snapshots, cross-Region replication, AWS Backup). If it has to be repeated across many accounts and Regions at once, the clue points to StackSets.

  • «review the impact of a change before applying it to production infrastructure»

    A change set compares the current stack with the new template or parameters and shows which resources will be added, modified, replaced, or deleted, without touching anything until it is executed.

    When not: A change set does not guarantee that the update will complete successfully: some failures only appear when it is executed. And if the question is how to discover changes made by hand outside CloudFormation, it is about drift detection, not a change set.

  • «deploy the same configuration to multiple accounts and Regions from a single place»

    A StackSet uses a single template to create, update, or delete stacks in the chosen accounts and Regions; with service-managed permissions and AWS Organizations, it also deploys to new accounts in an OU.

    When not: If the question asks for teams to launch approved products on their own with limited permissions, AWS Service Catalog fits. If it asks for a whole multi-account environment with controls already included, AWS Control Tower, which uses StackSets internally.

  • «keep the data when the stack is deleted»

    A resource's deletion policy (DeletionPolicy) lets you retain it or create a snapshot, for example of an EBS volume or an RDS database, when the stack is deleted.

    When not: It only takes effect when the stack or the resource is deleted. For periodic copies retained according to a policy, the service is AWS Backup or scheduled snapshots.

  • «install and configure software on instances when the stack is created»

    CloudFormation can pass bootstrap scripts to EC2 instances (user data and its helper scripts) and wait for the application to signal that it has started before considering the stack created.

    When not: If the task is to configure, patch, or run commands on servers that already exist, on an ongoing basis, AWS Systems Manager fits. For pre-built images, you start from your own AMI.

Often paired with

  • AWS Service Catalog
Study AWS CloudFormation →

Compute

AWS Elastic Beanstalk

Service for deploying web applications on AWS: you upload your code and Elastic Beanstalk provisions the resources (Amazon EC2 instances in Standard mode or an Amazon EKS cluster in Cluster mode) and configures load balancing, health monitoring, and scaling. It saves you from setting up and configuring that infrastructure by hand.

Exam phrases that point here

  • «quickly deploy a web application without having to manage the underlying infrastructure»

    With Elastic Beanstalk you upload your code and the service creates and manages the load balancer, the Auto Scaling group, the EC2 instances, and health monitoring.

    When not: If the scenario asks not to manage even instances (functions that run on events), think of AWS Lambda; if the application is already containerized and you want to orchestrate the containers, think of Amazon ECS or Amazon EKS. And if the goal is to describe all the infrastructure as reusable code, think of AWS CloudFormation.

  • «developers just want to upload their code, but keep control of the instances and the load balancer»

    Unlike many platform-as-a-service offerings, Elastic Beanstalk creates ordinary AWS resources in your account: you can choose the instance type, use Spot, log in to the instances, or change the configuration.

    When not: If the scenario does not mention an application to deploy but rather building the infrastructure piece by piece, the clue is not Beanstalk but services such as EC2, Auto Scaling, and Elastic Load Balancing configured directly.

  • «deploy a new version with no downtime and a quick rollback if it fails»

    Elastic Beanstalk offers deployment policies such as immutable (the new version is installed on new instances; Standard mode only) or a blue/green deployment with two environments and a URL swap.

    When not: The all at once policy is the fastest but leaves the application out of service for a moment. If the scenario does not use Beanstalk but EC2 or Lambda directly, the answer usually involves AWS CodeDeploy.

  • «upgrade to an incompatible platform version without affecting users»

    A blue/green deployment creates a new environment with the new platform and, once it has been tested, swaps the URLs (CNAMEs) of the two environments.

    When not: If it is a minor update or a patch of the same platform, this is not needed: if enabled, managed platform updates apply it on their own during the maintenance window.

  • «keep the operating system and the application server patched automatically»

    Elastic Beanstalk managed platform updates apply patches and minor versions in a weekly maintenance window, using an immutable mechanism that does not interrupt the service.

    When not: Major versions are not applied automatically, because they can break compatibility. And if the instances are not managed by Beanstalk, patching usually goes through AWS Systems Manager (Patch Manager).

Often paired with

  • Amazon EC2
  • Elastic Load Balancing (ELB)
  • Amazon EC2 Auto Scaling
Study AWS Elastic Beanstalk →