Skip to content

Commit

Permalink
Merge pull request #4814 from aqche/bastion_host_ip_config_name_valid…
Browse files Browse the repository at this point in the history
…ation

Update bastion host ip config name validation to allow for hyphens
  • Loading branch information
tombuildsstuff authored Nov 6, 2019
2 parents e4b9b38 + edf9713 commit a2679c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions azurerm/resource_arm_bastion_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,16 @@ func validateAzureRMBastionHostName(v interface{}, k string) (warnings []string,

func validateAzureRMBastionIPConfigName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)
if !regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString(value) {
errors = append(errors, fmt.Errorf("lowercase letters, highercase letters numbers only are allowed in %q: %q", k, value))
if !regexp.MustCompile(`^[A-Za-z0-9][a-zA-Z0-9_.-]+[a-zA-Z0-9_]$`).MatchString(value) {
errors = append(errors, fmt.Errorf("The name must begin with a letter or number, end with a letter, number or underscore, and may contain only letters, numbers, underscores, periods, or hyphens. %q: %q", k, value))
}

if 1 > len(value) {
errors = append(errors, fmt.Errorf("%q cannot be less than 1 characters: %q", k, value))
}

if len(value) > 32 {
errors = append(errors, fmt.Errorf("%q cannot be longer than 32 characters: %q %d", k, value, len(value)))
if len(value) > 80 {
errors = append(errors, fmt.Errorf("%q cannot be longer than 80 characters: %q %d", k, value, len(value)))
}

return warnings, errors
Expand Down
6 changes: 3 additions & 3 deletions azurerm/resource_arm_bastion_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ resource "azurerm_bastion_host" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
name = "configuration"
name = "ip-configuration"
subnet_id = "${azurerm_subnet.test.id}"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
Expand Down Expand Up @@ -170,7 +170,7 @@ resource "azurerm_bastion_host" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
name = "configuration"
name = "ip-configuration"
subnet_id = "${azurerm_subnet.test.id}"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
Expand All @@ -192,7 +192,7 @@ resource "azurerm_bastion_host" "import" {
location = "${azurerm_bastion_host.test.location}"
ip_configuration {
name = "configuration"
name = "ip-configuration"
subnet_id = "${azurerm_subnet.test.id}"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
Expand Down

0 comments on commit a2679c5

Please sign in to comment.