Closed glovecchi0 closed 4 months ago
LGTM and tested with valid and invalid values for regions.
Is it possible to programmatically retrieve the region names instead of hard coding them?
Is it possible to consolidate the region validation for each cloud provider in a single place instead of one place for rke, one place for k3s, and another for rke2?
If so, let's get new issues open to make these changes.
Hey @dnoland1, Automatically collecting regions can be done, although it might be complex... I imagine it is necessary to have the CLI tool of all providers installed locally, export all credentials and create/run a script.
For the second question, I open an issue to investigate.
@glovecchi0 How about using this to get the list of all regions in Google Cloud:
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "4.75.0"
}
}
}
provider "google" {
project = "rancher-support-01"
region = "us-west-1"
}
data "google_compute_regions" "regions" {
}
output "regions" {
value = data.google_compute_regions.regions.names
}
When I run this, I get:
Outputs:
regions = tolist([
"africa-south1",
"asia-east1",
"asia-east2",
"asia-northeast1",
"asia-northeast2",
"asia-northeast3",
"asia-south1",
"asia-south2",
"asia-southeast1",
"asia-southeast2",
"australia-southeast1",
"australia-southeast2",
"europe-central2",
"europe-north1",
"europe-southwest1",
"europe-west1",
"europe-west10",
"europe-west12",
"europe-west2",
"europe-west3",
"europe-west4",
"europe-west6",
"europe-west8",
"europe-west9",
"me-central1",
"me-central2",
"me-west1",
"northamerica-northeast1",
"northamerica-northeast2",
"southamerica-east1",
"southamerica-west1",
"us-central1",
"us-east1",
"us-east4",
"us-east5",
"us-south1",
"us-west1",
"us-west2",
"us-west3",
"us-west4",
])
AWS has a similar data source: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/regions DigitalOcean: https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/data-sources/regions
@dnoland1, good idea! Do you know how to put the output value inside the variable validation?
I'll mark the point to check.
Issue #82 - Added validation for the selected Region for AWS and Digital Ocean; Azure and Google Cloud are already OK
Issue: https://github.com/rancherlabs/tf-rancher-up/issues/82
DO Regions: https://docs.digitalocean.com/products/platform/availability-matrix/ AWS Regions: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html