1

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?

2

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.