Skip to content

Commit 420cde7

Browse files
fix: added validation to ensure the provider region and module input region are the same (#1089)
1 parent e4564f6 commit 420cde7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ resource "ibm_is_vpc" "vpc" {
4040
access_tags = var.access_tags
4141
no_sg_acl_rules = var.clean_default_sg_acl
4242

43+
# Ensures the VPC CRN region matches var.region; fails early if there is a mismatch.
44+
lifecycle {
45+
postcondition {
46+
condition = regex("^crn(\\:\\w+\\:\\w+\\:\\w+\\:\\w+)\\:([\\w-\\.]+)\\:\\w\\/([\\w-\\.]*\\:[\\w-\\.]*\\:[\\w-\\.]*\\:)[\\w-\\.]*$", self.crn)[1] == var.region
47+
error_message = "The region in the VPC CRN and the region specified in `var.region` must be the same and are not. The mismatch might be caused by different regions in the provider region and in the`var.region` input variable. Check the region values and try again"
48+
}
49+
}
50+
4351
dns {
4452
enable_hub = var.enable_hub
4553

0 commit comments

Comments
 (0)