# Terraform vs CloudFormation

## Terraform vs. CloudFormation

<figure><img src="/files/zMHKdch8jrwKNFpu1RuW" alt=""><figcaption></figcaption></figure>

### CloudFormation

* **Vendor Lock-In**: AWS CloudFormation is tightly integrated with AWS services, making it the natural choice for AWS-centric environments.
* **Native Integration**: Seamlessly integrates with other AWS services, providing direct resource references and a unified management experience.
* **Service Coverage**: Provides comprehensive coverage of AWS services, often including support for new services shortly after release.
* **Learning Curve**: Learning CloudFormation may be easier for those familiar with AWS services.

### Terraform

* **Cloud-Agnostic**: Terraform is cloud-agnostic, supporting multiple cloud providers, including AWS, Azure, Google Cloud, and more. This makes it a versatile choice for hybrid or multi-cloud deployments.
* **Community and Modules**: This has a large and active community, and using modules allows for reusable and shareable code.
* **State Management**: Terraform uses a state file to track the current state of infrastructure, providing a clear view of the deployed resources.
* **Language Flexibility**: The HashiCorp Configuration Language (HCL) used by Terraform is designed for readability and is more flexible than JSON or YAML.

## Use Cases

### Terraform Use Cases

#### 1. Multi-Cloud Environments

***Scenario*****:** A company utilises its infrastructure with multiple cloud providers such as AWS, Azure, and GCP.

Reason for Terraform:

* Terraform has providers for various cloud platforms, making it easier to manage multi-cloud environments.
* A single Terraform configuration can span different cloud providers, allowing consistent infrastructure as code (IaC) across the entire infrastructure landscape.

#### 2. Community Modules and Providers:

***Scenario***: An organisation heavily relies on community-contributed modules and providers to enhance infrastructure provisioning.

Reason for Terraform:

* Terraform has a vibrant community that contributes reusable modules and providers for a wide range of services and platforms.
* Leveraging community-driven content can significantly speed up the development process and provide best practices adopted by a broader audience.

### AWS CloudFormation Use Cases

#### 1. Deep AWS Integration

***Scenario***: An enterprise's infrastructure is predominantly AWS-centric, and the team is deeply invested in AWS-specific services and features.

Reason for CloudFormation:

* AWS CloudFormation provides native integration with AWS services, making it well-suited for managing AWS-specific resources.
* Features like CloudFormation StackSets and Change Sets enhance the management of AWS-specific resources and deployments.

#### 2. Managed Service Integration:

***Scenario***: An organisation heavily utilises AWS-managed services, such as AWS Elastic Beanstalk or AWS OpsWorks.

Reason for CloudFormation:

* AWS CloudFormation integrates seamlessly with AWS-managed services, offering simplified provisioning and management of these services.
* CloudFormation provides specific resource types for many AWS-managed services, allowing for a higher level of abstraction in the templates.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://davidjosearaujo.gitbook.io/online-courses/infrastructure-as-code/cloud-based-iac/terraform-vs-cloudformation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
