Skip to content

Commit

Permalink
[4.0] azurerm_application_gateway - upgrade API version to `2023-11…
Browse files Browse the repository at this point in the history
…-01` (#26776)

* upgrade app gateway 2023-11-01

* go mod vendor

* update tests
  • Loading branch information
teowa authored Aug 19, 2024
1 parent 77cdaf1 commit 1221ed0
Show file tree
Hide file tree
Showing 192 changed files with 31 additions and 5,914 deletions.
6 changes: 3 additions & 3 deletions internal/services/network/application_gateway_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-helpers/resourcemanager/zones"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2022-07-01/applicationgateways"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/webapplicationfirewallpolicies"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/applicationgateways"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/webapplicationfirewallpolicies"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down Expand Up @@ -1319,7 +1319,7 @@ func dataSourceApplicationGateway() *pluginsdk.Resource {
}

func dataSourceApplicationGatewayRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Network.ApplicationGatewaysClient
client := meta.(*clients.Client).Network.ApplicationGateways
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand Down
12 changes: 6 additions & 6 deletions internal/services/network/application_gateway_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-helpers/resourcemanager/zones"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2022-07-01/applicationgateways"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/webapplicationfirewallpolicies"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/applicationgateways"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/webapplicationfirewallpolicies"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
Expand Down Expand Up @@ -1546,7 +1546,7 @@ func resourceApplicationGateway() *pluginsdk.Resource {
}

func resourceApplicationGatewayCreate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Network.ApplicationGatewaysClient
client := meta.(*clients.Client).Network.ApplicationGateways
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d)
defer cancel()
Expand Down Expand Up @@ -1723,7 +1723,7 @@ func resourceApplicationGatewayCreate(d *pluginsdk.ResourceData, meta interface{
}

func resourceApplicationGatewayUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Network.ApplicationGatewaysClient
client := meta.(*clients.Client).Network.ApplicationGateways
ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -1982,7 +1982,7 @@ func resourceApplicationGatewayUpdate(d *pluginsdk.ResourceData, meta interface{
}

func resourceApplicationGatewayRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Network.ApplicationGatewaysClient
client := meta.(*clients.Client).Network.ApplicationGateways
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -2163,7 +2163,7 @@ func resourceApplicationGatewayRead(d *pluginsdk.ResourceData, meta interface{})
}

func resourceApplicationGatewayDelete(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Network.ApplicationGatewaysClient
client := meta.(*clients.Client).Network.ApplicationGateways
ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down
34 changes: 22 additions & 12 deletions internal/services/network/application_gateway_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2022-07-01/applicationgateways"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/applicationgateways"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -878,7 +878,7 @@ func TestAccApplicationGateway_sslPolicy_policyType_predefined(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("ssl_policy.0.policy_type").HasValue("Predefined"),
check.That(data.ResourceName).Key("ssl_policy.0.policy_name").HasValue("AppGwSslPolicy20170401S"),
check.That(data.ResourceName).Key("ssl_policy.0.policy_name").HasValue("AppGwSslPolicy20220101S"),
),
},
})
Expand Down Expand Up @@ -1058,7 +1058,7 @@ func TestAccApplicationGateway_sslProfile(t *testing.T) {
check.That(data.ResourceName).Key("ssl_profile.0.trusted_client_certificate_names.0").DoesNotExist(),
check.That(data.ResourceName).Key("http_listener.0.ssl_profile_name").Exists(),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.policy_type").HasValue("Predefined"),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.policy_name").HasValue("AppGwSslPolicy20150501"),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.policy_name").HasValue("AppGwSslPolicy20220101"),
),
},
// since these are read from the existing state
Expand All @@ -1074,7 +1074,7 @@ func TestAccApplicationGateway_sslProfile(t *testing.T) {
check.That(data.ResourceName).Key("ssl_profile.0.trusted_client_certificate_names.0").DoesNotExist(),
check.That(data.ResourceName).Key("http_listener.0.ssl_profile_name").Exists(),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.policy_type").HasValue("Predefined"),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.policy_name").HasValue("AppGwSslPolicy20170401"),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.policy_name").HasValue("AppGwSslPolicy20220101S"),
),
},
// since these are read from the existing state
Expand All @@ -1098,7 +1098,7 @@ func TestAccApplicationGateway_sslProfileWithClientCertificateVerification(t *te
check.That(data.ResourceName).Key("ssl_profile.0.trusted_client_certificate_names.0").Exists(),
check.That(data.ResourceName).Key("http_listener.0.ssl_profile_name").Exists(),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.policy_type").HasValue("Custom"),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.min_protocol_version").HasValue("TLSv1_1"),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.min_protocol_version").HasValue("TLSv1_2"),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.cipher_suites.0").HasValue("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.cipher_suites.1").HasValue("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"),
check.That(data.ResourceName).Key("ssl_profile.0.ssl_policy.0.cipher_suites.2").HasValue("TLS_RSA_WITH_AES_128_GCM_SHA256"),
Expand Down Expand Up @@ -1326,7 +1326,7 @@ func (t ApplicationGatewayResource) Exists(ctx context.Context, clients *clients
return nil, err
}

resp, err := clients.Network.ApplicationGatewaysClient.Get(ctx, *id)
resp, err := clients.Network.ApplicationGateways.Get(ctx, *id)
if err != nil {
return nil, fmt.Errorf("retrieving %s: %+v", id, err)
}
Expand Down Expand Up @@ -5098,7 +5098,7 @@ func (ApplicationGatewayResource) changeCert(certificateName string) acceptance.
return err
}

agw, err := clients.Network.ApplicationGatewaysClient.Get(ctx, *id)
agw, err := clients.Network.ApplicationGateways.Get(ctx, *id)
if err != nil {
return fmt.Errorf("retrieving %s: %+v", id, err)
}
Expand Down Expand Up @@ -5129,7 +5129,7 @@ func (ApplicationGatewayResource) changeCert(certificateName string) acceptance.

agw.Model.Properties.SslCertificates = &newSslCertificates

if err := clients.Network.ApplicationGatewaysClient.CreateOrUpdateThenPoll(ctx, *id, *agw.Model); err != nil {
if err := clients.Network.ApplicationGateways.CreateOrUpdateThenPoll(ctx, *id, *agw.Model); err != nil {
return fmt.Errorf("updating %s: %+v", id, err)
}

Expand Down Expand Up @@ -5905,7 +5905,7 @@ resource "azurerm_application_gateway" "test" {
}
ssl_policy {
policy_name = "AppGwSslPolicy20170401S"
policy_name = "AppGwSslPolicy20220101S"
policy_type = "Predefined"
}
Expand Down Expand Up @@ -7465,7 +7465,7 @@ resource "azurerm_application_gateway" "test" {
name = local.ssl_profile_name
ssl_policy {
policy_type = "Predefined"
policy_name = "AppGwSslPolicy20150501"
policy_name = "AppGwSslPolicy20220101"
}
}
Expand Down Expand Up @@ -7564,7 +7564,7 @@ resource "azurerm_application_gateway" "test" {
verify_client_certificate_revocation = "OCSP"
ssl_policy {
policy_type = "Predefined"
policy_name = "AppGwSslPolicy20170401"
policy_name = "AppGwSslPolicy20220101S"
}
}
Expand Down Expand Up @@ -7658,12 +7658,18 @@ resource "azurerm_application_gateway" "test" {
priority = 10
}
ssl_policy {
policy_type = "Custom"
min_protocol_version = "TLSv1_2"
cipher_suites = ["TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_RSA_WITH_AES_128_GCM_SHA256"]
}
ssl_profile {
name = local.ssl_profile_name
trusted_client_certificate_names = [local.trusted_client_cert_name]
ssl_policy {
policy_type = "Custom"
min_protocol_version = "TLSv1_1"
min_protocol_version = "TLSv1_2"
cipher_suites = ["TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_RSA_WITH_AES_128_GCM_SHA256"]
}
}
Expand Down Expand Up @@ -7763,6 +7769,10 @@ resource "azurerm_application_gateway" "test" {
priority = 10
}
ssl_policy {
disabled_protocols = ["TLSv1_0", "TLSv1_1"]
}
ssl_profile {
name = local.ssl_profile_name
trusted_client_certificate_names = [local.trusted_client_cert_name]
Expand Down
10 changes: 0 additions & 10 deletions internal/services/network/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package client
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/network/2022-07-01/applicationgateways"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/networkinterfaces"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/vmsspublicipaddresses"
network_2023_11_01 "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01"
Expand All @@ -17,20 +16,12 @@ import (
type Client struct {
*network_2023_11_01.Client

// TODO 4.0 application gateways should be updated to use 2023-09-01 just prior to releasing 4.0
ApplicationGatewaysClient *applicationgateways.ApplicationGatewaysClient
// VMSS Data Source requires the Network Interfaces and VMSSPublicIpAddresses client from `2023-09-01` for the `ListVirtualMachineScaleSetVMNetworkInterfacesComplete` method
NetworkInterfacesClient *networkinterfaces.NetworkInterfacesClient
VMSSPublicIPAddressesClient *vmsspublicipaddresses.VMSSPublicIPAddressesClient
}

func NewClient(o *common.ClientOptions) (*Client, error) {
ApplicationGatewaysClient, err := applicationgateways.NewApplicationGatewaysClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Application Gateways Client: %+v", err)
}
o.Configure(ApplicationGatewaysClient.Client, o.Authorizers.ResourceManager)

NetworkInterfacesClient, err := networkinterfaces.NewNetworkInterfacesClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Network Interfaces Client: %+v", err)
Expand All @@ -51,7 +42,6 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
}

return &Client{
ApplicationGatewaysClient: ApplicationGatewaysClient,
NetworkInterfacesClient: NetworkInterfacesClient,
VMSSPublicIPAddressesClient: VMSSPublicIPAddressesClient,
Client: client,
Expand Down
Loading

0 comments on commit 1221ed0

Please sign in to comment.