selectel / terraform-examples

Terraform manifests examples for different Selectel services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add the input variable region to the module nat

ahkhystrix opened this issue · comments

The region that is specified by the provider is used, which does not allow creating resources in different regions. The solution is to add the variable region to this file main.tf to call all the data and resources. This allows you not to specify the region in the provider, to indicate when calling the module nat.

Unfortunately, I can not offer PR, because failed to provide backward compatibility (take the region from the provider, unless explicitly specified when calling the module region).
Alternatively, add the module nat_with_region.

I understand that I can create a module for creating resources in each individual region and call a provider in it. I do not know if this is correct; I have met recommendations not to include the provider call in the module.

Examples use OpenStack provider and region is a provider level parameter that can't be omitted.
Yes there is an option when provider is specified in module, but such implementation adds unnecessary complexity and code duplication to examples. Please note that this repository contains examples and we are trying to keep them as simple as possible.

Also in my book tf manifests that contain resources from different regions are hard to maintain. It is better to use separate directories for different regions like this:

terraform_manifests/
├- ru-1/
│  ├- main.tf (contains provider definition and other global things)
│  ├- network.tf 
│  ├- hosts.tf
│  └- ...
├- ru-2/
│  ├- main.tf (contains provider definition and other global things)
│  ├- network.tf 
│  ├- hosts.tf
│  └- ...
└- ...