One team has already written a cloud information template as an .yml file that contains a resource stack.
.yml
Can I use this file by executing it from Terraform? Or should it be rewritten?
I am new to terraform and just getting started.
If I used AWS CLI, I would execute such a command,
aws cloudformation create-stack --stack-name my-new-stack -template-body file: //mystack.yml -parameters ParameterKey = AmiId
I would like to include the equivalent of this command in the terraform configuration.
If possible, and you can point me to an example, I would really appreciate it.
Thanks!
The aws_cloudformation_stack resource serves as a bridge from Terraform to CloudFormation, which can be used either as an aid to move from CloudFormation to Terraform (as you obviously are here), or use some CloudFormation features that Terraform does not currently handle, for example, deployment Deploy new instances in ASG.
aws_cloudformation_stack
resource "aws_cloudformation_stack" "example" { name = "example" parameters = { VpcId = "${var.vpc_id}" } template_body = "${file("${path.module}/example.yml")}" }
The parameters argument allows you to transfer data from Terraform to the Cloudformation stack. It is also possible to use the outputs attribute to use the results of the CloudFormation stack elsewhere in Terraform for two-way integration:
parameters
outputs
resource "aws_route_53_record" "example" { name = "service.example.com" type = "CNAME" ttl = 300 records = ["${aws_cloudformation_stack.example.outputs["ElbHostname"]}"] }
If you have an existing CloudFormation stack that is not controlled by Terraform, you can still use its outputs using the aws_cloudformation_stack source data :
data "aws_cloudformation_stack" "example" { name = "example" } resource "aws_route_53_record" "example" { name = "service.example.com" type = "CNAME" ttl = 300 records = ["${data.aws_cloudformation_stack.example.outputs["ElbHostname"]}"] }
Together, these features allow you to efficiently mix CloudFormation and Terraform in the same system in different combinations, whether itβs a temporary measure during migration or on an ongoing basis in situations where a hybrid solution is required.
I can confirm that template_body has a file link for the cloudformation template. I assume template_url also works fine. Example
resource "aws_cloudformation_stack" "my-new-stack" { name = "my-new-stack" parameters { Name="my-new-stack" Port="22" VpcId = "${var.vpc_id}" } template_body = "${file("${path.module}/mystack.yml")}" }
Source: https://habr.com/ru/post/1266446/More articles:The returned derived type from a base class method - genericsAssigning Azure Blob to SSIS - sql-serverReassign https://example.com to https://www.example.com: Namecheap and Heroku - redirectSSIS: dynamic search query - sql-serverhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1266445/how-to-map-filter-options-from-odataqueryoptions-to-restrequest&usg=ALkJrhju7zXv1lvQ1PPI85iONkKxs3Dz6QRecurring payments through Paypal Express Check REST API - javascriptroutines: EVP_DecryptFinal_ex: wrong end block length in android - androidIs it possible to determine if the SKStore Review Controller has been submitted. - iosProcess terminated by exit code 137 in PyCharm - pythonMoving axis labels between section and facet - rAll Articles