Skip to content

Commit

Permalink
azurerm_application_gateway - support for the Basic SKU (hashicorp#27440
Browse files Browse the repository at this point in the history
)

* feat: hashicorp#25973 azurerm_application_gateway basic sku support

* feat: hashicorp#25973 additional checks for application gateway Basic SKU supported features

* tests: hashicorp#25973 add tests for application gateway basic sku

* fix: hashicorp#2597 revert erroneous markdown lint changes

* docs: hashicorp#2597 add Basic SKU docs

* tests(application_gateway): hashicorp#25973 update tests to use v2 SKUs as V1 is now deprecated

See https://learn.microsoft.com/en-us/azure/application-gateway/v1-retirement#retirement-timelines

* tests(application_gateway): hashicorp#25973 update all agw tests to include priority on request_routing_rule as required with agw v2 sku

* tests(application_gateway): hashicorp#25973 update test public ip resource to be standard sku for compatibility with agw v2
  • Loading branch information
tedsmitt authored and djryanj committed Oct 26, 2024
1 parent 8be3dd1 commit c387f2e
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 83 deletions.
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

0 comments on commit c387f2e

Please sign in to comment.