Need advice about which tool to choose?Ask the StackShare community!
AWS CloudFormation vs Amazon EC2 Container Service: What are the differences?
Key differences between AWS CloudFormation and Amazon EC2 Container Service
Managed Services vs. Container Orchestration: AWS CloudFormation is a managed service that provides infrastructure as code, allowing users to define and provision AWS resources in a predictable and repeatable manner. It focuses on the provisioning and management of infrastructure resources. On the other hand, Amazon EC2 Container Service (ECS) is a container orchestration service that helps users to run, manage, and scale containerized applications using Docker containers. It focuses on managing the deployment and lifecycle of containerized applications.
Granularity of Control: With AWS CloudFormation, users have fine-grained control over the provisioning and configuration of infrastructure resources. It allows users to specify details such as instance types, storage volumes, network settings, and security groups. In contrast, Amazon ECS abstracts the underlying infrastructure and provides a higher-level control over containers. Users define container specifications, such as CPU and memory requirements, and Amazon ECS takes care of the underlying infrastructure provisioning and coordination.
Resource Management: AWS CloudFormation manages infrastructure resources as a stack. Users define a template that describes the resources they need, and CloudFormation creates and manages the stack based on that template. It provides features like rolling updates and drift detection. In contrast, Amazon ECS manages containers as tasks and services. Users define tasks that specify container images, networking, and resource requirements. ECS takes care of deploying and scaling those tasks, managing container instances, and load balancing traffic.
Integration with Other AWS Services: AWS CloudFormation integrates with various AWS services, enabling users to create and provision resources from different services as part of a stack. Users can define dependencies between resources, enabling efficient provisioning and management. Amazon ECS integrates tightly with other AWS services, such as Amazon Elastic Container Registry (ECR) for container image storage, and Amazon Elastic Load Balancing (ELB) for load balancing container traffic. This integration simplifies the overall deployment and management process.
Infrastructure-as-Code vs. Containerization: AWS CloudFormation focuses on defining infrastructure resources as code and managing the infrastructure lifecycle. It enables users to declaratively define and version their infrastructure. Amazon ECS, on the other hand, focuses on containerization and managing the application lifecycle. It provides features like task definitions and service definitions to define and manage containerized applications.
Deployment and Management: AWS CloudFormation provides features like change sets, drift detection, and rollback, which enable users to safely deploy and manage changes to their infrastructure. It supports blue-green deployments and other advanced deployment strategies. With Amazon ECS, users can easily update their containerized applications by creating new task definitions and deploying new versions of services. It handles the deployment and management of containers, making it easier to scale and update applications.
In Summary, AWS CloudFormation is a managed service for infrastructure provisioning and management, while Amazon EC2 Container Service is a container orchestration service for running and managing containerized applications.
Ok, so first - AWS Copilot is CloudFormation under the hood, but the way it works results in you not thinking about CFN anymore. AWS found the right balance with Copilot - it's insanely simple to setup production-ready multi-account environment with many services inside, with CI/CD out of the box etc etc. It's pretty new, but even now it was enough to launch Transcripto, which uses may be a dozen of different AWS services, all bound together by Copilot.
If you want to integrate your cluster and control end to end your pipeline with AWS tools like ECR and Code Pipeline your best option is ECS using a EC2 instance. There are pros and cons but it's easier to integrate using cloud formation templates and visual UI for approvals, etc. ECS is free, you need to pay only for the EC2 instance but unfortunately, it is not standard then you cannot use standard tools to see and manage your Kubernetes. EKS in the other hand uses standard Kubernates definitions but you need to pay for the service and also for the EC2 instance(s) you have in your cluster.
Because Pulumi uses real programming languages, you can actually write abstractions for your infrastructure code, which is incredibly empowering. You still 'describe' your desired state, but by having a programming language at your fingers, you can factor out patterns, and package it up for easier consumption.
We use Terraform to manage AWS cloud environment for the project. It is pretty complex, largely static, security-focused, and constantly evolving.
Terraform provides descriptive (declarative) way of defining the target configuration, where it can work out the dependencies between configuration elements and apply differences without re-provisioning the entire cloud stack.
AdvantagesTerraform is vendor-neutral in a way that it is using a common configuration language (HCL) with plugins (providers) for multiple cloud and service providers.
Terraform keeps track of the previous state of the deployment and applies incremental changes, resulting in faster deployment times.
Terraform allows us to share reusable modules between projects. We have built an impressive library of modules internally, which makes it very easy to assemble a new project from pre-fabricated building blocks.
DisadvantagesSoftware is imperfect, and Terraform is no exception. Occasionally we hit annoying bugs that we have to work around. The interaction with any underlying APIs is encapsulated inside 3rd party Terraform providers, and any bug fixes or new features require a provider release. Some providers have very poor coverage of the underlying APIs.
Terraform is not great for managing highly dynamic parts of cloud environments. That part is better delegated to other tools or scripts.
Terraform state may go out of sync with the target environment or with the source configuration, which often results in painful reconciliation.
I personally am not a huge fan of vendor lock in for multiple reasons:
- I've seen cost saving moves to the cloud end up costing a fortune and trapping companies due to over utilization of cloud specific features.
- I've seen S3 failures nearly take down half the internet.
- I've seen companies get stuck in the cloud because they aren't built cloud agnostic.
I choose to use terraform for my cloud provisioning for these reasons:
- It's cloud agnostic so I can use it no matter where I am.
- It isn't difficult to use and uses a relatively easy to read language.
- It tests infrastructure before running it, and enables me to see and keep changes up to date.
- It runs from the same CLI I do most of my CM work from.
Pros of Amazon EC2 Container Service
- Backed by amazon100
- Familiar to ec272
- Cluster based53
- Simple API42
- Iam roles26
- Scheduler7
- Cluster management7
- Programmatic Control7
- Container-enabled applications4
- Socker support4
- No additional cost2
- Easy to use and cheap1
Pros of AWS CloudFormation
- Automates infrastructure deployments43
- Declarative infrastructure and deployment21
- No more clicking around13
- Any Operative System you want3
- Atomic3
- Infrastructure as code3
- CDK makes it truly infrastructure-as-code1
- Automates Infrastructure Deployment1
- K8s0
Sign up to add or upvote prosMake informed product decisions
Cons of Amazon EC2 Container Service
Cons of AWS CloudFormation
- Brittle4
- No RBAC and policies in templates2