patternterraformMinor
Calling a Terraform object in seperate folder
Viewed 0 times
seperateobjectfoldercallingterraform
Problem
I need to reference my VNET Gateway residing in an infrastructure folder, in a VPN folder in order to connect a VPN utilising a Local Network Gateway, but these could be any object in Azure for the sake of argument. These folders both use seperate state files hosted in Azure blob storage.
What would be the best way to go about calling this VNET Gateway's ID in another folder? The usual methods of using e.g "module.vnet_gateway.id" or e.g "data.azurerm_vnet_gateway.id" won't work in this scenario.
I've considered some way of referencing it by name, which I know, and pulling the id as an output, but I'm not certain this is the best method.
I've read about using remote-state, which I assume as per the guides on Google would involve creating a data-source pointed to my specific state file for "inf", and then pulling the data back, but I've yet to find a good example on Azure of how to achieve this.
Any pointers or examples StackExchange could provide to get me in the right direction?
What would be the best way to go about calling this VNET Gateway's ID in another folder? The usual methods of using e.g "module.vnet_gateway.id" or e.g "data.azurerm_vnet_gateway.id" won't work in this scenario.
I've considered some way of referencing it by name, which I know, and pulling the id as an output, but I'm not certain this is the best method.
I've read about using remote-state, which I assume as per the guides on Google would involve creating a data-source pointed to my specific state file for "inf", and then pulling the data back, but I've yet to find a good example on Azure of how to achieve this.
Any pointers or examples StackExchange could provide to get me in the right direction?
Solution
Using a remote state file and referencing the state from a different state template would be the way I would go. Would need to add an output to resource that needs to be shared as well as configuring remote state storage, access controls, and security.
This URL has example of setting up the remote backend in azureRM.
https://www.terraform.io/docs/backends/types/azurerm.html
This URL has example of setting up the remote backend in azureRM.
https://www.terraform.io/docs/backends/types/azurerm.html
Context
StackExchange DevOps Q#10477, answer score: 2
Revisions (0)
No revisions yet.