cf2tf
cf2tf copied to clipboard
!Importvalue function conversation to Relevant terraform code
I am trying to use this source code ato convert cfn template to tf . issue am facing is while converting !Import value fun which is intrinsic to Cfn and No parallel in Terraform.. is this issue resolved or we are still following up please suggest way out.
@shadycuz can you please suggets on this
@dezzertfox Can you post the exact error you are getting?
I don't think we ever implemented the logic to handle !Import
function, because as you mentioned, there is no equivalent in Terraform.
I think we could fix this in a couple different ways:
-
Instead of throwing an error, we could replace
foo: !ImportValue bar
with some value. Maybefoo = !importValue bar
, which will cause an error in Terraform and remind you that you need to replace it with something. Maybe a Terraform variable or a Terraform datasource block. -
We could replace
foo: !ImportValue bar
with a variable like:foo = var.bar
. This would be similar to #1 but a much better user experience. When you first go to deploy your template it will ask you for the value offoo
variable. We wont know any of the typing information but we can add a description about where this variable came from.
For now you can do a find and replace on your templates to turn !ImportValue
into ImportValue
. This should turn it into a string (at least in YAML). Which would allow the conversion to continue, but would still need to be changed manually before your cloudformation is able to be deployed.
@xentripetal your input was very valuable last time, can you think of a better way to handle the Cloudformation !ImportValue
intrinsic function?
relevant code here... in case someone wants to take a crack at it. I wont be able to look at it until friday? or so.
https://github.com/DontShaveTheYak/cf2tf/blob/5ab3137563c6287b7e7c334225afa84bd17dfeba/src/cf2tf/conversion/expressions.py#L483-L491
This was completed in #132