NEW: aws-region-short module

This commit is contained in:
xpk 2022-08-17 17:11:52 +08:00
parent 914c6661fe
commit d359982fb5
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86
4 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,13 @@
# aws-region-short module
Module which returns a map of aws regions and their short code.
## Example root module
```terraform
module region-short {
source = "git::https://xpk.headdesk.me/git/xpk/terraform.aws-baseline-infra//modules/util/aws-region-short"
}
output region-short-code {
value = lookup(module.region-short.region-map, var.aws-region)
}
```

View File

@ -0,0 +1,7 @@
module region-short {
source = "git::https://xpk.headdesk.me/git/xpk/terraform.aws-baseline-infra//modules/util/aws-region-short"
}
output region-short-code {
value = lookup(module.region-short.region-map, "ap-northeast-2")
}

View File

@ -0,0 +1,25 @@
output "region-map" {
value = local.region-map
}
locals {
region-map = {
ap-northeast-1 = "apne1"
ap-northeast-2 = "apne2"
ap-northeast-3 = "apne3"
ap-south-1 = "aps1"
ap-southeast-1 = "apse1"
ap-southeast-2 = "apse2"
ca-central-1 = "cac1"
eu-central-1 = "euc1"
eu-north-1 = "eun1"
eu-west-1 = "euw1"
eu-west-2 = "euw2"
eu-west-3 = "euw3"
sa-east-1 = "sae1"
us-east-1 = "use1"
us-east-2 = "use2"
us-west-1 = "usw1"
us-west-2 = "usw2"
}
}

View File

@ -0,0 +1,9 @@
terraform {
required_version = "~> 1.2.5"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.75.2"
}
}
}