Skip to content

Commit

Permalink
Updated validation to allow underscore in app service plan name and u…
Browse files Browse the repository at this point in the history
…pdated example.
  • Loading branch information
shanepoint committed Jun 6, 2018
1 parent 3e835ee commit a53ec9c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions azurerm/resource_arm_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,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", 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", k))
}

return
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 | ...
}

0 comments on commit a53ec9c

Please sign in to comment.