CloudFormation and Elastic Beanstalk are not rivals, they solve different problems. CloudFormation is AWS's infrastructure-as-code service: you describe servers, networks, buckets and permissions in a template, and AWS builds them. Elastic Beanstalk is a Platform-as-a-Service: you upload application code, and it provisions a sensible environment, deploys the code, and handles scaling and health checks. If you want control over every resource, use CloudFormation. If you want to ship an app without designing the infrastructure, start with Elastic Beanstalk and use CloudFormation underneath it. This guide walks through evaluating the two, trying each one, and combining them safely.

What You'll Need

  • An AWS account with billing enabled and access to the AWS Management Console, the AWS CLI, or both.
  • An IAM user or role with permissions for CloudFormation, Elastic Beanstalk, EC2, S3, IAM and Auto Scaling. Broad admin permissions are easy but risky; scope them where you can.
  • For Beanstalk deployments: an application archive (zip, war or jar) or a source repository, plus a supported platform such as Python, Node.js, Java, .NET, PHP, Ruby or Docker.
  • For CloudFormation: a template in YAML or JSON. Start from an AWS sample template if you have not written one before.
  • Awareness of cost: both create chargable resources such as EC2 instances, load balancers and S3 storage. Clean up when you finish testing.

Step-by-Step

  1. List what your application actually needs. Write down the compute type, whether it needs a database, whether it must sit behind a load balancer, and how much control you need over networking. A simple web app with standard scaling needs maps cleanly to Elastic Beanstalk. A custom multi-tier architecture with specific security groups, private subnets and cross-account roles is a CloudFormation job.
  2. Decide on your control-versus-speed trade-off. Elastic Beanstalk manages the EC2 instances, Auto Scaling group, load balancer and security groups for you, which means less design work but less ability to bend the environment to an unusual shape. CloudFormation gives you every knob and no hand-holding. If your team is small and the app is conventional, pick Beanstalk first.
  3. Open the CloudFormation console and inspect a sample template. In the AWS Management Console, go to CloudFormation and look at the template designer or the sample templates offered in the create-stack flow. Note the Resources section: every logical resource maps to a real AWS object. Labels and menu wording can differ slightly by console version or region. Reading one sample teaches you more about the model than any comparison article.
  4. Do a dry run of CloudFormation with a small stack. Choose Create stack, upload a template that creates something harmless such as an S3 bucket with a unique name, review the change set if offered, acknowledge that CloudFormation may create IAM resources if the template does, and create the stack. Watch the Events tab until the status reads CREATE_COMPLETE. Then delete the stack and confirm the bucket disappears. That round trip shows you both the power and the discipline of infrastructure as code: resources exist only because the template says so.
  5. Deploy a hello-world application on Elastic Beanstalk. Open Elastic Beanstalk, choose Create application, give it a name, and select a platform and platform branch that matches your runtime. Upload your archive or point it at a sample application. Beanstalk then creates an environment with an EC2 instance, security group, Auto Scaling group and, for a load-balanced environment, an elastic load balancer. Wait until the environment health shows OK, then open the environment URL to confirm the app responds.
  6. Compare what appeared in your account. After the Beanstalk environment is live, open the EC2 and CloudFormation consoles. Beanstalk's own environment resources appear in CloudFormation as a stack named after the environment, because Beanstalk is built on CloudFormation under the hood. This is the key insight for the comparison: Beanstalk is an opinionated layer that writes CloudFormation for you. You are never choosing one or the other completely, you are choosing whether to write the templates yourself.
  7. Test a change in each system. In CloudFormation, edit the template, upload the updated version, and apply the change set. In Beanstalk, deploy a new application version and watch it roll through the environment. Note the difference in blast radius: a template change can alter networking or IAM, while a Beanstalk deployment mostly replaces application code and environment configuration.
  8. Plan how you will customise Beanstalk when defaults are not enough. Beanstalk supports configuration files in an .ebextensions folder inside your application bundle, and saved configurations for environment settings. For anything beyond that, put shared infrastructure such as databases, VPCs and IAM roles in your own CloudFormation stacks and let Beanstalk reference them. This keeps stateful or security-sensitive resources outside the application lifecycle.
  9. Choose your deployment workflow. If you go CloudFormation-first, keep templates in version control, use change sets to preview updates, and consider stack sets if you need the same baseline in several accounts or regions. If you go Beanstalk-first, use the EB CLI for repeatable deploys, keep environment configuration in files rather than console clicks, and treat the environment as replaceable.
  10. Clean up your trial resources. Delete the test Beanstalk environment and any CloudFormation stacks you created, checking that load balancers, instances and buckets are gone. Terminated resources stop billing, but orphaned resources left behind by failed stacks can linger.

Common Mistakes

  • Treating Beanstalk as a database host. Beanstalk environments are meant to be replaceable. A database created inside the environment can be lost when the environment is rebuilt. Put databases in RDS, ideally in a separate CloudFormation stack.
  • Editing resources by hand after CloudFormation created them. Manual changes are drift. The next stack update may overwrite them or fail. Make the change in the template instead.
  • Assuming Beanstalk hides CloudFormation entirely. It does not, and that is good news: you can inspect the generated stack to learn how the environment is wired, but you should not edit that stack directly.
  • Deleting a CloudFormation stack without reading what it will delete. Stack deletion removes every resource in the stack, including databases and buckets with data. Check the deletion policy and retention settings first.
  • Forgetting that Beanstalk needs a supported platform version. Deprecated platform branches are retired; choose a current branch when creating the environment.

Tips

  • Use CloudFormation change sets before every production update so you can see exactly which resources will be modified, replaced or deleted.
  • Keep shared foundations (VPC, subnets, IAM roles, RDS) in their own stacks and pass outputs into application stacks.
  • Tag resources consistently in your templates; tags make cost allocation and cleanup far easier.
  • Use Beanstalk's saved configurations to capture a working environment setup so it can be recreated identically.
  • Prefer small, single-purpose stacks over one giant template. Smaller stacks fail faster and localise problems.

Troubleshooting

If a CloudFormation stack fails, open the Events tab and read from the first error upward, not the last. The bottom error is usually a consequence of the first one. Common causes are a missing IAM permission, a resource name collision, or an invalid parameter. Fix the template, then update the stack if it rolled back cleanly, or delete it and start again if it is stuck in a failed state.

If a Beanstalk environment shows degraded health, check the environment's health page and recent events for the failing instance or deployment. A failed deploy usually means the application crashed on startup, a required environment variable is missing, or the platform runtime does not match your code. Review the instance log bundle from the console, correct the bundle or configuration, and redeploy. If the environment itself is broken beyond repair, you can terminate it and create a fresh one from a saved configuration, provided your data lives outside the environment.

If the console does not let you delete a stack because a resource cannot be removed, identify that resource in the events, remove its protection if it has deletion protection enabled, and confirm whether it must be retained. Do not force-delete data stores.

Frequently Asked Questions

Is Elastic Beanstalk built on CloudFormation?

Yes. Beanstalk creates a CloudFormation stack for each environment. That is why the two services are complementary rather than alternatives.

Can I use both in the same project?

Yes, and it is common. Keep databases, networking and shared IAM in your own CloudFormation stacks, and let Beanstalk manage the application environment.

Which is cheaper?

Neither service adds a separate charge for its own basic use; you pay for the underlying resources such as EC2 instances, load balancers and storage. Costs depend on what you create, so check the AWS pricing pages for those resources.

Do I need to know YAML to use CloudFormation?

Not strictly, because JSON templates are also supported, but YAML is easier to read and is the more common choice. Starting from a sample template reduces the learning curve.

Does Beanstalk work for containers?

Yes, Docker is one of the supported platforms. If you need fine-grained container orchestration, Elastic Container Service is the more direct fit.

Can I move a Beanstalk app to plain CloudFormation later?

You can rebuild the environment as your own templates, but it is a migration rather than a switch. Plan it as a fresh deployment, not an in-place conversion.