CloudFormation vs Terraform – 30 Interview Q&A

CloudFormation vs Terraform – 30 Interview Q&A

1. What is Infrastructure as Code (IaC)?

IaC is the practice of managing infrastructure using code instead of manual processes. It ensures consistency, automation, and version control in deployments.

2. What is AWS CloudFormation?

CloudFormation is an AWS-native service used to define and provision infrastructure. It uses templates (JSON/YAML) to automate resource creation.

3. What is Terraform?

Terraform is an open-source IaC tool that works across multiple cloud providers. It uses HashiCorp Configuration Language (HCL) for defining resources.

4. Key difference between CloudFormation and Terraform?

CloudFormation is AWS-specific, while Terraform is multi-cloud. Terraform supports broader integrations beyond AWS.

5. What language does CloudFormation use?

CloudFormation uses JSON or YAML templates. YAML is preferred for readability and ease of writing.

6. What language does Terraform use?

Terraform uses HCL (HashiCorp Configuration Language). It is designed to be human-readable and easy to learn.

7. What is a stack in CloudFormation?

A stack is a collection of AWS resources created and managed together. It simplifies deployment and lifecycle management.

8. What is a Terraform state file?

The state file stores the current infrastructure state. It helps Terraform track changes and manage updates.

9. Why is state management important in Terraform?

It ensures Terraform knows what resources exist. Without it, Terraform cannot detect changes accurately.

10. What is drift detection?

Drift occurs when actual infrastructure differs from code. CloudFormation provides built-in drift detection; Terraform requires manual checks.

11. How does CloudFormation handle dependencies?

Dependencies are managed automatically based on resource references. You can also define explicit dependencies using DependsOn.

12. How does Terraform handle dependencies?

Terraform builds a dependency graph automatically. It determines resource creation order based on references.

13. What is modularity in Terraform?

Modules allow reusable infrastructure components. They improve maintainability and reduce duplication.

14. What are nested stacks in CloudFormation?

Nested stacks allow splitting large templates into smaller parts. They improve readability and reuse.

15. Which tool is better for multi-cloud?

Terraform is better suited for multi-cloud environments. CloudFormation works only within AWS.

16. What is rollback in CloudFormation?

If deployment fails, CloudFormation automatically rolls back changes. This ensures infrastructure consistency.

17. Does Terraform support rollback?

Terraform does not have automatic rollback. You must manually fix and reapply configurations.

18. What is Terraform plan?

It shows what changes Terraform will make before applying. This helps review and prevent unintended modifications.

19. What is CloudFormation change set?

It previews changes before execution. Similar to Terraform plan but specific to AWS.

20. How do you manage secrets in IaC?

Avoid hardcoding sensitive data in templates. Use secure services like AWS Secrets Manager or environment variables.

21. What is idempotency in IaC?

Running the same code multiple times produces the same result. Both Terraform and CloudFormation support idempotent operations.

22. How does version control help IaC?

IaC files can be stored in Git repositories. This enables tracking, collaboration, and rollback.

23. What is remote state in Terraform?

Remote state stores the state file in a shared location like S3. It allows team collaboration and prevents conflicts.

24. What is locking in Terraform?

State locking prevents multiple users from modifying infrastructure simultaneously. It avoids corruption and race conditions.

25. What are parameters in CloudFormation?

Parameters allow dynamic input values in templates. They make templates reusable and flexible.

26. What are variables in Terraform?

Variables allow customization of configurations. They improve reusability and maintainability.

27. What is output in Terraform?

Outputs display useful information after deployment. They can be used in other modules or scripts.

28. What are outputs in CloudFormation?

Outputs export values from a stack. They can be referenced by other stacks.

29. Which is easier to learn?

CloudFormation is easier for AWS-only users. Terraform is easier for multi-cloud but requires learning HCL.

30. When should you choose CloudFormation over Terraform?

Choose CloudFormation for deep AWS integration and managed service benefits. It is ideal for organizations fully invested in AWS ecosystem.

Final Insight

Both AWS CloudFormation and Terraform are powerful IaC tools your choice depends on whether you prioritize AWS-native simplicity or multi-cloud flexibility.

shamitha
shamitha
Leave Comment
Share This Blog
Recent Posts
Get The Latest Updates

Subscribe To Our Newsletter

No spam, notifications only about our New Course updates.

Enroll Now
Enroll Now
Enquire Now