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

azurerm_application_gateway - support for the Basic SKU #27440

37 changes: 36 additions & 1 deletion internal/services/network/application_gateway_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ func resourceApplicationGateway() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
string(applicationgateways.ApplicationGatewaySkuNameBasic),
string(applicationgateways.ApplicationGatewaySkuNameStandardSmall),
string(applicationgateways.ApplicationGatewaySkuNameStandardMedium),
string(applicationgateways.ApplicationGatewaySkuNameStandardLarge),
Expand All @@ -825,6 +826,7 @@ func resourceApplicationGateway() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
string(applicationgateways.ApplicationGatewayTierBasic),
string(applicationgateways.ApplicationGatewayTierStandard),
string(applicationgateways.ApplicationGatewayTierStandardVTwo),
string(applicationgateways.ApplicationGatewayTierWAF),
Expand Down Expand Up @@ -4709,12 +4711,45 @@ func checkSslPolicy(sslPolicy []interface{}) error {
return nil
}

func checkBasicSkuFeatures(d *pluginsdk.ResourceDiff) error {
_, hasAutoscaleConfig := d.GetOk("autoscale_configuration.0")
if hasAutoscaleConfig {
return fmt.Errorf("The Application Gateway does not support `autoscale_configuration` blocks for the selected SKU tier %q", applicationgateways.ApplicationGatewaySkuNameBasic)
}

capacity, hasCapacityConfig := d.GetOk("sku.0.capacity")
if hasCapacityConfig {
if capacity.(int) > 2 || capacity.(int) < 1 {
return fmt.Errorf("`capacity` value %q for the selected SKU tier %q is invalid. Value must be between [1-2]", capacity, applicationgateways.ApplicationGatewaySkuNameBasic)
}
} else {
return fmt.Errorf("The Application Gateway must specify a `capacity` value between [1-2] for the selected SKU tier %q", applicationgateways.ApplicationGatewaySkuNameBasic)
}

_, hasMtlsConfig := d.GetOk("trusted_client_certificate")
if hasMtlsConfig {
return fmt.Errorf("The Application Gateway does not support `trusted_client_certificate` blocks for the selected SKU tier %q", applicationgateways.ApplicationGatewaySkuNameBasic)
}

_, hasRewriteRuleSetConfig := d.GetOk("rewrite_rule_set")
if hasRewriteRuleSetConfig {
return fmt.Errorf("The Application Gateway does not support `rewrite_rule_set` blocks for the selected SKU tier %q", applicationgateways.ApplicationGatewaySkuNameBasic)
}

return nil
}

func applicationGatewayCustomizeDiff(ctx context.Context, d *pluginsdk.ResourceDiff, _ interface{}) error {
_, hasAutoscaleConfig := d.GetOk("autoscale_configuration.0")
capacity, hasCapacity := d.GetOk("sku.0.capacity")
tier := d.Get("sku.0.tier").(string)

if !hasAutoscaleConfig && !hasCapacity {
if tier == string(applicationgateways.ApplicationGatewaySkuNameBasic) {
err := checkBasicSkuFeatures(d)
if err != nil {
return err
}
} else if !hasAutoscaleConfig && !hasCapacity {
return fmt.Errorf("The Application Gateway must specify either `capacity` or `autoscale_configuration` for the selected SKU tier %q", tier)
}

Expand Down
Loading
Loading