Skip to content

Commit

Permalink
setting a max length for the name (#24)
Browse files Browse the repository at this point in the history
* setting a max length for the name

* truncate at 25

* Update src/vpc_connector.tf

Co-authored-by: Christopher Hill <[email protected]>

Co-authored-by: Christopher Hill <[email protected]>
  • Loading branch information
WillBeebe and chrisghill authored Oct 20, 2022
1 parent ab953af commit 7f0d685
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/vpc_connector.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@ locals {
us-west3 = "10.252.0.16/28"
us-west4 = "10.252.0.32/28"
}

name_max_length = 25
safe_name = trimsuffix(substr(var.md_metadata.name_prefix, 0, local.name_max_length), "-")
}

# cost per month
# f1-micro | e2-micro
# min $13.29 | $14.69
resource "google_vpc_access_connector" "shared" {
provider = google-beta
name = var.md_metadata.name_prefix
provider = google-beta
# max 25 characters
name = local.safe_name
region = var.gcp_region
ip_cidr_range = local.ranges[var.gcp_region]
# in Mbps
Expand Down

0 comments on commit 7f0d685

Please sign in to comment.