0
Follow
2
View

Does Terraform support CloudFormation Templates with minor manipulations

cymx2012 注册会员
2023-01-25 10:59

This is far from being true.

Although, both Terraform and CloudFormation have support for JSON files, this does not means that the syntax of those JSON files are understood by both of them. They are entirely different products developed by different maintainers. They have different ways of defining and managing resources which you would want to provision.

Terraform's AWS provider has support for creating CloudFormation stacks, more info in the documentation. If you really want to, you might be able to provision resources from CFN files, but certainly this is not accomplished just by renaming a test.json to test.tf.

w13811551210 注册会员
2023-01-25 10:59

It seems that you have misunderstood some things:

  • Both CloudFormation JSON or YML files and Terraform TF (or JSON) are in a declarative language. This is true for JSON and YML in general. You can't debug or run these files, as they are only describing an infrastructure (or an object in general) and don't implement any logic.
  • For Terraform you need to install the HashiCorp.terraform extension. This will give you syntax highlighting.
  • For Cloudformation I recommend cf-lint extension.

Both in CloudFormation and in Terraform you edit the files (JSON, YML, TF) and use a CLI to deploy your code. Terraform works in a much higher-level than CloudFormation. CloudFormation can only be used to deploy stacks, i.e. a set of resources. If you also need to deploy application code, you must have done that beforehand in a S3 bucket and reference it from there. Also in many situations you need to create a stack and then update it. Or you need to combine two or more stacks in a Stack Set.

Terraform manages all this complexity for you and offers a lot of features on top of CloudFormation. As already said, the JSON file formats isn't the same and can't be used interchangeably. You can provision a CloudFormation stack with Terraform though.

About the Author

Question Info

Publish Time
2023-01-25 10:59
Update Time
2023-01-25 10:59