Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated resource_arm_app_service_plan Validation to Allow Underscore #1351

Merged
merged 3 commits into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions azurerm/resource_arm_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ func flattenAzureRmAppServiceMachineIdentity(identity *web.ManagedServiceIdentit
func validateAppServiceName(v interface{}, k string) (ws []string, es []error) {
value := v.(string)

if matched := regexp.MustCompile(`^[0-9a-zA-Z-]+$`).Match([]byte(value)); !matched {
es = append(es, fmt.Errorf("%q may only contain alphanumeric characters and dashes", k))
if matched := regexp.MustCompile(`^[0-9a-zA-Z-]{1,60}$`).Match([]byte(value)); !matched {
es = append(es, fmt.Errorf("%q may only contain alphanumeric characters and dashes and up to 60 characters in length", k))
}

return
Expand Down
4 changes: 2 additions & 2 deletions azurerm/resource_arm_app_service_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ func flattenAppServiceProperties(props *web.AppServicePlanProperties) []interfac
func validateAppServicePlanName(v interface{}, k string) (ws []string, es []error) {
value := v.(string)

if matched := regexp.MustCompile(`^[0-9a-zA-Z-]+$`).Match([]byte(value)); !matched {
es = append(es, fmt.Errorf("%q may only contain alphanumeric characters and dashes", k))
if matched := regexp.MustCompile(`^[0-9a-zA-Z-_]{1,60}$`).Match([]byte(value)); !matched {
es = append(es, fmt.Errorf("%q may only contain alphanumeric characters, dashes and underscores up to 60 characters in length", k))
}

return
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_app_service_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestAzureRMAppServicePlanName_validation(t *testing.T) {
},
{
Value: "hello_world",
ErrCount: 1,
ErrCount: 0,
},
{
Value: "helloworld21!",
Expand Down
11 changes: 9 additions & 2 deletions examples/app-service/app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ resource "azurerm_resource_group" "default" {
location = "${var.location}"
}


resource "random_integer" "ri" {
min = 10000
max = 99999
}


resource "azurerm_app_service_plan" "default" {
name = "${var.app_service_name}-plan"
name = "tfex-appservice-${random_integer.ri.result}-plan"
location = "${azurerm_resource_group.default.location}"
resource_group_name = "${azurerm_resource_group.default.name}"

Expand All @@ -20,7 +27,7 @@ resource "azurerm_app_service_plan" "default" {
}

resource "azurerm_app_service" "default" {
name = "${var.app_service_name}"
name = "tfex-appservice-${random_integer.ri.result}"
location = "${azurerm_resource_group.default.location}"
resource_group_name = "${azurerm_resource_group.default.name}"
app_service_plan_id = "${azurerm_app_service_plan.default.id}"
Expand Down
21 changes: 12 additions & 9 deletions examples/app-service/variables.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
variable "resource_group_name" {
type = "string"
type = "string"
description = "Name of the azure resource group."
default = "tfex-appserviceplan"
}

variable "location" {
type = "string"
type = "string"
description = "Location of the azure resource group."
default = "westus"
}

variable "app_service_name" {
type = "string"
}

variable "app_service_plan_sku_tier" {
type = "string"
default = "Basic" # Basic | Standard | ...
type = "string"
description = "SKU tier of the App Service Plan"
default = "Basic" # Basic | Standard | ...
}

variable "app_service_plan_sku_size" {
type = "string"
default = "B1" # B1 | S1 | ...
type = "string"
description = "SKU size of the App Service Plan"
default = "B1" # B1 | S1 | ...
}