Code Monkey home page Code Monkey logo

terraform-azurerm-regions's Introduction

Azure regions module

Changelog Notice Apache V2 License TF Registry

This Terraform module is designed to help in using the AzureRM terraform provider.

It provides for an Azure region given in standard format, CLI format or slug format (used by Claranet tfwrapper) the Azure standard format, a short format used for resource naming, the CLI format and a slug format.

It also provides the paired region associated to the current one.

Please refer to the regions.tf file for available regions. Complete regions mapping is also available in REGIONS.md documentation.

Global versioning rule for Claranet Azure modules

Module version Terraform version AzureRM version
>= 7.x.x 1.3.x >= 3.0
>= 6.x.x 1.x >= 3.0
>= 5.x.x 0.15.x >= 2.0
>= 4.x.x 0.13.x / 0.14.x >= 2.0
>= 3.x.x 0.12.x >= 2.0
>= 2.x.x 0.12.x < 2.0
< 2.x.x 0.11.x < 2.0

Contributing

If you want to contribute to this repository, feel free to use our pre-commit git hook configuration which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.

More details are available in the CONTRIBUTING.md file.

Usage

This module is optimized to work with the Claranet terraform-wrapper tool which set some terraform variables in the environment needed by this module. More details about variables set by the terraform-wrapper available in the documentation.

module "azure_region" {
  source  = "claranet/regions/azurerm"
  version = "x.x.x"

  azure_region = "eu-west"
}

Providers

No providers.

Modules

No modules.

Resources

No resources.

Inputs

Name Description Type Default Required
azure_region Azure Region standard name, CLI name or slug format string n/a yes

Outputs

Name Description
location Azure region in standard format
location_cli Azure region in Azure CLI name format
location_short Azure region in short format for resource naming purpose
location_slug Azure region in slug format
paired_location Azure paired region with the current one. All formats available as attributes.
object({
location (string): Azure paired region in standard format
location_short (string): Azure paired region in short format for resource naming purpose
location_cli (string): Azure paired region in CLI name format
location_slug (string): Azure paired region in slug format
})

Related documentation

Azure regions: azure.microsoft.com/en-us/global-infrastructure/regions/

terraform-azurerm-regions's People

Contributors

abrefort avatar bzspi avatar jmapro avatar leonardolage avatar rossifumax avatar sergiydivnych avatar shr3ps avatar sysa avatar yohanhounsounou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-azurerm-regions's Issues

[BUG] logic behind .location_short region names

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Hello there,
First of all thank you for this module and contributions to it.
It is not really a bug but was discovered during usage of the module and caused some problems. So this bug report will contain an explanation of the case, question and possible workarounds. Might be the place to bring up a discussion about possible solutions too.

Default azure sdk/cli does not contain a short region notation (like 3-4 chars) for its locations.

This command gives a brief view on what it has under the hood:
az account list-locations -o table

DisplayName               Name                 RegionalDisplayName
------------------------  -------------------  -------------------------------------
East US                   eastus               (US) East US
East US 2                 eastus2              (US) East US 2
South Central US          southcentralus       (US) South Central US
West US 2                 westus2              (US) West US 2
West US 3                 westus3              (US) West US 3
Australia East            australiaeast        (Asia Pacific) Australia East
Southeast Asia            southeastasia        (Asia Pacific) Southeast Asia
North Europe              northeurope          (Europe) North Europe
Sweden Central            swedencentral        (Europe) Sweden Central
UK South                  uksouth              (Europe) UK South
West Europe               westeurope           (Europe) West Europe
Central US                centralus            (US) Central US

The name field is kind of short name notation but not really short. At this point everyone is up to use their own logic of combination of country+region to make a short name for a location. I believe it is where this terraform module was born initially, to cover such gap in implementation.

According to the list of mapping azure regions in this module: https://github.com/claranet/terraform-azurerm-regions/blob/master/REGIONS.md#azure-regions-mapping-list - there is a "Short notation" and it feels all right for most of the popular regions until you start using more regions.

There is also a comprehensive (and boring) list of country codes which can be used as an international reference: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes

What is the issue then? Let me pick few regions to highlight my concerns:

List below is from this terraform module ("azure-regions-mapping-list"):

Region name Short notation Internal terraform notation my comment
North Europe eun eu-north feels ok
West Europe euw eu-west feels ok
Central US uc us-central why it is just 'uc' and not usc? god thanks it is not 'cu' and leading to Cuba
UAE North uaen uae-north feels ok but with the logic out of 'uc' it may be just 'ae'
North Central US unc us-north-central why it is 'unc' not 'usnc'? Why Europe regions then has two letters represents 'eu' not just 'e'?
Canada East cae can-east hmm.. all right
East Asia ae asia-east why it is 'ae' not 'ase'? oh, because we have 'ase' as Southeast Asia already. moreover 'ae' is leading more for UAE not the East Asia tbh (see ISO 3166 and domain name for UAE is .ae)

My question is what is the logic behind such naming notation for short region names? I don't see any, please point me to it. I thought it might be something like "at least 3 chars" should represent the region to improve unambiguously of short naming.

I started using this module from EU regions and then spread more to others and found such a misleading logic (in my opinion) which does not give any consistency to what I usually see in different projects/companies. But I might be biased and make only assumptions which also can be wrong. But what I certain know is that I never see the US shortcut as just "U" (except for US Gov-specific regions which usually a 'UG' but in this module for US Gov I see just 'gov' - what?! Because plain 'u' is already in use to reflect regular US regions...)

I don't see any neat solution to that because it will either break already existing naming notations people have (who have been using this module from day 0) or just have another mapping field like .location_short2. but what if a person would need a mix of those? I don't know but would like to hear your opinion or suggestion.

So far I have dumb workarounds like that to have your own re-mapping in particular places/regions where you need it:

locals {
  location_short_map = {
    unc : "usnc"
    euw : "euw"
    eun : "eun"
  }
}

module "redis_regions" {
  for_each     = toset(var.regions_to_deploy[local.env])
  source       = "claranet/regions/azurerm"
  version      = "6.1.0"
  azure_region = each.key
}

resource "whatever_azure_resource" "resource_name" {
  for_each = module.redis_regions
  name                          = "bla-bla-${local.location_short_map[each.value.location_short]}-bla-bla"
  location                      = each.value.location

Thank you for your time and again, thank you for this module and contributions to it!
Sincerely,
Alex

Terraform Version

v1.5.6

AzureRM Provider Version

6.1.0

Affected Resource(s)/Data Source(s)

azurerm_*

Terraform Configuration Files

N/A

Debug Output/Panic Output

N/A

Expected Behaviour

I expect some straightforward logic for naming convention or written explanation why certain names for regions were picked up.

Actual Behaviour

Misleading short names for regions

Steps to Reproduce

No response

Important Factoids

No response

References

No response

[FEAT] Support of qatarcentral region on Azure

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Hello,
I'm trying to use your module to deploy on qatarcentral region on Azure.
Do you have a plan to support it ?
Thanks

New or Affected Resource(s)/Data Source(s)

azurerm_6.1.0

Potential Terraform Configuration

No response

References

No response

[BUG] Japan paired regions are incorrect

Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

According to Azure documentation, the paired region for Japan East is Japan West and vice versa.
https://learn.microsoft.com/en-us/azure/reliability/cross-region-replication-azure

On your map for paired region, you are referencing the same region as the pair.

paired = {
...
jap-east = "jap-east"
jap-west = "jap-west"

Terraform Version

1.7.4

AzureRM Provider Version

3.91.0

Affected Resource(s)/Data Source(s)

azurerm_*

Terraform Configuration Files

N/A

Debug Output/Panic Output

N/A

Expected Behaviour

The paired region should return the right one:

jap-east = "jap-west"
jap-west = "jap-east"

Actual Behaviour

No response

Steps to Reproduce

No response

Important Factoids

No response

References

No response

Suggestion: Paired Regions

I found this module while trying to find an automated way to select paired regions for DR redundancy while doing Terraform Azure deployments.

I've started using the module mainly for resource naming using the region short codes, but it seems to me this module would be an excellent candidate for mapping region pairs, also.

azurerm provider could be removed

Why this module has declared azurerm provider? It doesn't need it at all.
This redundant dependency makes this module slower, because terraform needs to download it during init process.

invalid index error on output "paired_location"

I have included this module in my infrastructure deployment however there appears to be an issue with the provider returning paired regions for version 5.0.0, shown below is the configuration and error from my terraform template.

module "azure_region" {
  source  = "claranet/regions/azurerm"
  version = "=5.0.0"

  azure_region = var.location
}

var.location is set to "australiaeast"

The error output is:

โ”‚ Error: Invalid index
โ”‚ 
โ”‚   on .terraform/modules/azure_region/outputs.tf line 35, in output "paired_location":
โ”‚   35:     location_short = local.short_names[local.paired_region]
โ”‚     โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
โ”‚     โ”‚ local.paired_region is "aus-south-east"
โ”‚     โ”‚ local.short_names is object with 60 attributes
โ”‚ 
โ”‚ The given key does not identify an element in this collection value.

Changing the version back to 4.2.1 resolves this issue for me.

The issue appears to be that the short_names local does not contain a key for aus-south-east. Could this please be rectified?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.