Convert AWS CloudFormation to Terraform template

Gleb picture Gleb · Jun 17, 2018 · Viewed 16k times · Source

I want to convert the existing AWS CloudFormation templates (yaml) to Terraform templates(hcl) automatically.

Can anyone please suggest some tools, approaches, etc?

Answer

Marc He picture Marc He · Jun 18, 2018

From a conceptual point of view, CFT and TF are not feature equivalent. You won't be able to express all things that CFT is able to deploy in TF.

From a practical perspective, it is somehow possible but you need to write a grammar converter ; and that is going very complex (almost impossible) if your CFT is using intrinsic functions https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html

In my opinion, you should use terraform aws_cloudformation_stack to deploy your existing CFT instead of trying to convert it (https://www.terraform.io/docs/providers/aws/r/cloudformation_stack.html).