Softwr

Software · head to head

AWS CloudFormation vs AWS CodeBuild

AWS CloudFormation logo

AWS CloudFormation

Software

Declarative infrastructure as code for AWS, free for AWS resources

From
Free
Free plan
Yes
AWS CodeBuild logo

AWS CodeBuild

Software

Pay-per-minute managed build service for compiling, testing and packaging code

From
$0.005/minute
Free plan
No

The short version

  • AWS CloudFormation is free; AWS CodeBuild starts at $0.005/mo.
  • Only AWS CloudFormation lists stacks and templates; only AWS CodeBuild lists managed build environments.
  • Where AWS CloudFormation falls short: it only manages AWS, so multi-cloud estates need Terraform or Pulumi alongside it.
  • Where AWS CodeBuild falls short: billing is rounded per minute on EC2 compute, so many short jobs cost more than their actual run time suggests.

How do AWS CloudFormation and AWS CodeBuild differ?

AWS CloudFormation and AWS CodeBuild differ on starting price (Free against $0.005/minute), pricing model and free tier (Yes against No). Only the attributes on which AWS CloudFormation and AWS CodeBuild actually diverge.

Attributes where AWS CloudFormation and AWS CodeBuild differ
AttributeAWS CloudFormationAWS CodeBuild
Starting priceFree$0.005/minute
Pricing modelNo charge for AWS resource types; extensions per handler operationPer build minute by instance type
Free tierYesNo
PlatformsWeb, Linux, macOS, WindowsWeb, Linux, Windows

Which features does each one have?

They share no listed features; 6 appear only for AWS CloudFormation and 6 only for AWS CodeBuild. Drawn from each product's published feature list. An absence here means we hold no record of it - not that the product lacks it.

Only in AWS CloudFormation

  • Stacks and templates
  • Change sets
  • Drift detection
  • StackSets
  • Rollback
  • Registry extensions

Only in AWS CodeBuild

  • Managed build environments
  • Lambda and EC2 compute
  • Reserved capacity
  • Buildspec files
  • Caching
  • GitHub Actions runners

What is each one used for?

AWS CloudFormation is most often brought in for recreating identical dev, staging and production environments on AWS; AWS CodeBuild for building and pushing container images to Amazon ECR from a CodePipeline stage. The jobs each tool is most often brought in to do.

AWS CloudFormation

  • Recreating identical dev, staging and production environments on AWSnot AWS CodeBuild
  • Deploying one baseline of security resources across many accounts with StackSetsnot AWS CodeBuild
  • Serverless applications packaged with AWS SAMnot AWS CodeBuild
  • Previewing and auditing infrastructure changes through change setsnot AWS CodeBuild

AWS CodeBuild

  • Building and pushing container images to Amazon ECR from a CodePipeline stagenot AWS CloudFormation
  • Running unit tests in parallel across many ephemeral containersnot AWS CloudFormation
  • Self-hosted GitHub Actions runners that need IAM access to AWS resourcesnot AWS CloudFormation
  • Compiling for Arm using cheaper Graviton-based build instancesnot AWS CloudFormation

Where do AWS CloudFormation and AWS CodeBuild fall short?

AWS CloudFormation's most cited limit: it only manages AWS, so multi-cloud estates need Terraform or Pulumi alongside it. AWS CodeBuild's: billing is rounded per minute on EC2 compute, so many short jobs cost more than their actual run time suggests. Documented limitations, not opinions. Every one is a constraint you would hit in normal use.

AWS CloudFormation

  • It only manages AWS, so multi-cloud estates need Terraform or Pulumi alongside it
  • Raw templates are verbose and hard to reuse, which is why many teams add CDK on top
  • A failed update can leave a stack in a stuck state such as UPDATE_ROLLBACK_FAILED that needs manual intervention
  • New AWS features sometimes arrive in CloudFormation after the console and API, so you wait or script around the gap
  • Deleting a stack deletes its resources, so a mistaken delete of a stack with data needs DeletionPolicy discipline

AWS CodeBuild

  • Each build starts from a clean environment, so dependency installs and image pulls repeat unless caching is configured, which inflates build minutes
  • Billing is rounded per minute on EC2 compute, so many short jobs cost more than their actual run time suggests
  • There is no built-in repository, pipeline UI or code review, so you need CodePipeline or a third-party system to trigger and track releases
  • Windows and larger instance types cost several times the Linux small rate, and the pricing table has dozens of instance rows to compare
  • Debugging a failed build is slower than on a local runner because you rely on logs or session manager rather than a persistent machine

How much do AWS CloudFormation and AWS CodeBuild cost?

AWS CloudFormation is free to use; AWS CodeBuild starts at $0.005/mo. Plan by plan below, from each vendor's own pricing page.

AWS CloudFormation

Free
  • AWS resource typesFree
    • No additional charge for using CloudFormation with AWS resources
    • You pay for the resources the stack creates
  • Third-party extensionsOn request
    • $0.0009 per handler operation, first 1,000 per month free
    • $0.00008 per second of handler duration beyond 30 seconds

AWS CodeBuild

$0.005/minute
  • Linux general1.small$0.005/minute
    • 3 GB memory, 2 vCPUs
    • 100 free build minutes per month on general1.small or arm1.small
  • Linux general1.large$0.02/minute
    • 15 GB memory, 8 vCPUs
    • general1.2xlarge is $0.20 per minute
  • Lambda compute$0.00001/second
    • Billed per second from $0.00001 (1 GB Arm) to $0.0002 (10 GB x86-64)
    • Suited to short builds

Which should you pick?

Choose AWS CloudFormation if

  • You need stacks and templates.
  • You want to start without paying.
  • You work on Web, Linux, macOS, Windows.
  • You also want change sets.

Choose AWS CodeBuild if

  • You need managed build environments.
  • You work on Web, Linux, Windows.
  • You also want lambda and ec2 compute.

Questions people ask

Is AWS CloudFormation or AWS CodeBuild better?
It depends on the job. AWS CloudFormation fits recreating identical dev, staging and production environments on AWS; AWS CodeBuild fits building and pushing container images to Amazon ECR from a CodePipeline stage. AWS CloudFormation starts at Free and AWS CodeBuild at $0.005/minute.
Which is cheaper, AWS CloudFormation or AWS CodeBuild?
AWS CloudFormation has a free tier; the other does not. Paid plans start at Free for AWS CloudFormation and $0.005/minute for AWS CodeBuild.
Does AWS CloudFormation or AWS CodeBuild run on more platforms?
AWS CloudFormation runs on Web, Linux, macOS, Windows. AWS CodeBuild runs on Web, Linux, Windows.
Can I use AWS CloudFormation for free?
Yes. AWS CloudFormation has a free tier, so you can try it without paying. AWS CodeBuild starts at $0.005/minute.
What is AWS CloudFormation best used for?
AWS CloudFormation is most often used for recreating identical dev, staging and production environments on aws, deploying one baseline of security resources across many accounts with stacksets, serverless applications packaged with aws sam, previewing and auditing infrastructure changes through change sets. Of those, recreating identical dev, staging and production environments on aws and deploying one baseline of security resources across many accounts with stacksets are not what AWS CodeBuild is typically brought in for.
What can AWS CloudFormation do that AWS CodeBuild cannot?
AWS CloudFormation covers Stacks and templates, Change sets, Drift detection, StackSets. AWS CodeBuild covers Managed build environments, Lambda and EC2 compute, Reserved capacity, Buildspec files.

Answered from the vendors’ own pages

AWS CloudFormation: Does CloudFormation cost money?

Not for AWS resource types. You pay for the resources it creates; third-party extensions are billed at $0.0009 per handler operation after 1,000 free.

AWS CodeBuild: How much does CodeBuild cost?

Linux general1.small is $0.005 per build minute, general1.medium $0.01 and general1.large $0.02, per the AWS pricing page. 100 build minutes per month on small instances are free.

AWS CloudFormation: CloudFormation or Terraform?

CloudFormation is AWS-only with state managed by AWS; Terraform spans many providers and keeps its own state.

AWS CodeBuild: Does CodeBuild replace Jenkins?

It replaces the build agents, not the orchestration. You still need CodePipeline, webhooks or another trigger for pipeline logic.

AWS CloudFormation: How does CDK relate?

CDK lets you write infrastructure in a programming language and synthesises CloudFormation templates.

AWS CodeBuild: Can CodeBuild run GitHub Actions?

Yes. CodeBuild can act as managed runners for GitHub Actions workflows, billed at CodeBuild compute rates.

Share

Related pages

Other head to heads