From cecd502c4aa38a81e9384b0c375c7bb9b2b7ae84 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 16 Mar 2026 10:35:37 -0600 Subject: [PATCH 01/18] deprecate web resources for 5.0, rename track 1 clients --- ...pp_service_environment_v3_resource_test.go | 2 +- .../logic/logic_app_standard_data_source.go | 2 +- .../logic/logic_app_standard_resource_test.go | 2 +- .../web/app_service_active_slot_resource.go | 6 +- .../app_service_active_slot_resource_test.go | 9 +- ...pp_service_certificate_binding_resource.go | 8 +- ...rvice_certificate_binding_resource_test.go | 4 +- .../app_service_certificate_data_source.go | 2 +- ...p_service_certificate_order_data_source.go | 2 +- .../app_service_certificate_order_resource.go | 6 +- ...service_certificate_order_resource_test.go | 2 +- .../web/app_service_certificate_resource.go | 6 +- .../app_service_certificate_resource_test.go | 2 +- ...ervice_custom_hostname_binding_resource.go | 6 +- ...e_custom_hostname_binding_resource_test.go | 2 +- .../services/web/app_service_data_source.go | 4 +- .../web/app_service_data_source_test.go | 43 +++ .../app_service_hybrid_connection_resource.go | 8 +- ...service_hybrid_connection_resource_test.go | 18 +- ...pp_service_managed_certificate_resource.go | 8 +- ...rvice_managed_certificate_resource_test.go | 2 +- .../web/app_service_plan_data_source.go | 4 +- .../web/app_service_plan_data_source_test.go | 13 + .../services/web/app_service_plan_resource.go | 8 +- .../web/app_service_plan_resource_test.go | 39 ++- internal/services/web/app_service_resource.go | 12 +- .../services/web/app_service_resource_test.go | 282 +++++++++++++++++- ...e_slot_custom_hostname_binding_resource.go | 6 +- ...t_custom_hostname_binding_resource_test.go | 2 +- .../services/web/app_service_slot_resource.go | 10 +- .../web/app_service_slot_resource_test.go | 201 ++++++++++++- ...rtual_network_swift_connection_resource.go | 6 +- ..._network_swift_connection_resource_test.go | 4 +- ...p_service_source_control_token_resource.go | 8 +- ...vice_source_control_token_resource_test.go | 7 +- ...rtual_network_swift_connection_resource.go | 6 +- ..._network_swift_connection_resource_test.go | 4 +- internal/services/web/client/client.go | 28 +- internal/services/web/function_app.go | 2 +- .../services/web/function_app_data_source.go | 4 +- .../web/function_app_data_source_test.go | 22 ++ .../web/function_app_host_keys_data_source.go | 2 +- .../services/web/function_app_resource.go | 10 +- .../web/function_app_resource_test.go | 170 ++++++++++- .../web/function_app_slot_resource.go | 12 +- .../web/function_app_slot_resource_test.go | 111 ++++++- internal/services/web/registration.go | 34 ++- .../web/static_site_custom_domain_resource.go | 8 +- internal/services/web/static_site_resource.go | 8 +- ...static_site_resource_custom_domain_test.go | 11 +- .../services/web/static_site_resource_test.go | 35 ++- website/docs/5.0-upgrade-guide.html.markdown | 60 +++- website/docs/d/app_service.html.markdown | 2 +- website/docs/d/app_service_plan.html.markdown | 2 +- website/docs/d/function_app.html.markdown | 2 +- website/docs/r/app_service.html.markdown | 2 +- .../r/app_service_active_slot.html.markdown | 2 +- ...pp_service_hybrid_connection.html.markdown | 2 +- website/docs/r/app_service_plan.html.markdown | 2 +- website/docs/r/app_service_slot.html.markdown | 2 +- ...service_source_control_token.html.markdown | 2 +- website/docs/r/function_app.html.markdown | 2 +- .../docs/r/function_app_slot.html.markdown | 2 +- website/docs/r/static_site.html.markdown | 2 +- .../r/static_site_custom_domain.html.markdown | 4 +- 65 files changed, 1146 insertions(+), 155 deletions(-) diff --git a/internal/services/appservice/app_service_environment_v3_resource_test.go b/internal/services/appservice/app_service_environment_v3_resource_test.go index 79affa614730..5a622e40d3ac 100644 --- a/internal/services/appservice/app_service_environment_v3_resource_test.go +++ b/internal/services/appservice/app_service_environment_v3_resource_test.go @@ -175,7 +175,7 @@ func (AppServiceEnvironmentV3Resource) Exists(ctx context.Context, client *clien return nil, err } - resp, err := client.Web.AppServiceEnvironmentsClient.Get(ctx, id.ResourceGroup, id.HostingEnvironmentName) + resp, err := client.Web.AppServiceEnvironmentsClientV1.Get(ctx, id.ResourceGroup, id.HostingEnvironmentName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/logic/logic_app_standard_data_source.go b/internal/services/logic/logic_app_standard_data_source.go index ff7231d95fdb..a803d390bc24 100644 --- a/internal/services/logic/logic_app_standard_data_source.go +++ b/internal/services/logic/logic_app_standard_data_source.go @@ -206,7 +206,7 @@ func dataSourceLogicAppStandard() *pluginsdk.Resource { func dataSourceLogicAppStandardRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).AppService.WebAppsClient - subscriptionId := meta.(*clients.Client).Web.AppServicesClient.SubscriptionID + subscriptionId := meta.(*clients.Client).Web.AppServicesClientV1.SubscriptionID ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/logic/logic_app_standard_resource_test.go b/internal/services/logic/logic_app_standard_resource_test.go index 0e4ee973c85d..bffcde3422a6 100644 --- a/internal/services/logic/logic_app_standard_resource_test.go +++ b/internal/services/logic/logic_app_standard_resource_test.go @@ -1132,7 +1132,7 @@ func (r LogicAppStandardResource) hasExtensionBundleAppSetting(shouldExist bool) return err } - appSettingsResp, err := clients.Web.AppServicesClient.ListApplicationSettings(ctx, id.ResourceGroup, id.SiteName) + appSettingsResp, err := clients.Web.AppServicesClientV1.ListApplicationSettings(ctx, id.ResourceGroup, id.SiteName) if err != nil { return fmt.Errorf("listing AppSettings: %+v", err) } diff --git a/internal/services/web/app_service_active_slot_resource.go b/internal/services/web/app_service_active_slot_resource.go index fe0629a7361d..4d6752c9c4e8 100644 --- a/internal/services/web/app_service_active_slot_resource.go +++ b/internal/services/web/app_service_active_slot_resource.go @@ -28,7 +28,7 @@ func resourceAppServiceActiveSlot() *pluginsdk.Resource { return err }), - DeprecationMessage: "The `azurerm_app_service_active_slot` resource has been superseded by the `azurerm_web_app_active_slot` and `azurerm_function_app_active_slot` resources. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_app_service_active_slot` resource has been superseded by the `azurerm_web_app_active_slot` and `azurerm_function_app_active_slot` resources. This resource will be removed in v5.0 of the AzureRM provider.", Timeouts: &pluginsdk.ResourceTimeout{ Create: pluginsdk.DefaultTimeout(30 * time.Minute), @@ -55,7 +55,7 @@ func resourceAppServiceActiveSlot() *pluginsdk.Resource { } func resourceAppServiceActiveSlotCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -96,7 +96,7 @@ func resourceAppServiceActiveSlotCreateUpdate(d *pluginsdk.ResourceData, meta in } func resourceAppServiceActiveSlotRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_active_slot_resource_test.go b/internal/services/web/app_service_active_slot_resource_test.go index 8110e4a5c7da..d146c73595df 100644 --- a/internal/services/web/app_service_active_slot_resource_test.go +++ b/internal/services/web/app_service_active_slot_resource_test.go @@ -12,6 +12,7 @@ import ( "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -20,6 +21,9 @@ import ( type AppServiceActiveSlotResource struct{} func TestAccAppServiceActiveSlot_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_active_slot", "test") r := AppServiceActiveSlotResource{} @@ -35,6 +39,9 @@ func TestAccAppServiceActiveSlot_basic(t *testing.T) { } func TestAccAppServiceActiveSlot_update(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_active_slot", "test") r := AppServiceActiveSlotResource{} @@ -61,7 +68,7 @@ func (r AppServiceActiveSlotResource) Exists(ctx context.Context, clients *clien return nil, err } - resp, err := clients.Web.AppServicesClient.Get(ctx, id.ResourceGroup, id.SiteName) + resp, err := clients.Web.AppServicesClientV1.Get(ctx, id.ResourceGroup, id.SiteName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_certificate_binding_resource.go b/internal/services/web/app_service_certificate_binding_resource.go index 6959a5a725bf..883a5793f159 100644 --- a/internal/services/web/app_service_certificate_binding_resource.go +++ b/internal/services/web/app_service_certificate_binding_resource.go @@ -83,8 +83,8 @@ func resourceAppServiceCertificateBinding() *pluginsdk.Resource { } func resourceAppServiceCertificateBindingCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient - certClient := meta.(*clients.Client).Web.CertificatesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 + certClient := meta.(*clients.Client).Web.CertificatesClientV1 ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -146,7 +146,7 @@ func resourceAppServiceCertificateBindingCreate(d *pluginsdk.ResourceData, meta } func resourceAppServiceCertificateBindingRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -183,7 +183,7 @@ func resourceAppServiceCertificateBindingRead(d *pluginsdk.ResourceData, meta in } func resourceAppServiceCertificateBindingDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_certificate_binding_resource_test.go b/internal/services/web/app_service_certificate_binding_resource_test.go index f628a2f4c532..41cec65f2a90 100644 --- a/internal/services/web/app_service_certificate_binding_resource_test.go +++ b/internal/services/web/app_service_certificate_binding_resource_test.go @@ -85,14 +85,14 @@ func (t AppServiceCertificateBindingResource) Exists(ctx context.Context, client return nil, err } - binding, err := clients.Web.AppServicesClient.GetHostNameBinding(ctx, id.HostnameBindingId.ResourceGroup, id.SiteName, id.HostnameBindingId.Name) + binding, err := clients.Web.AppServicesClientV1.GetHostNameBinding(ctx, id.HostnameBindingId.ResourceGroup, id.SiteName, id.HostnameBindingId.Name) if err != nil { if utils.ResponseWasNotFound(binding.Response) { return pointer.To(false), nil } return nil, fmt.Errorf("retrieving App Service Hostname Binding %q (resource group %q) to check for Certificate Binding %q: %+v", id.HostnameBindingId.Name, id.HostnameBindingId.ResourceGroup, id.HostnameBindingId.Name, err) } - certificate, err := clients.Web.CertificatesClient.Get(ctx, id.CertificateId.ResourceGroup, id.CertificateId.Name) + certificate, err := clients.Web.CertificatesClientV1.Get(ctx, id.CertificateId.ResourceGroup, id.CertificateId.Name) if err != nil { if utils.ResponseWasNotFound(certificate.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_certificate_data_source.go b/internal/services/web/app_service_certificate_data_source.go index c1b51b993626..b87d474bdc8c 100644 --- a/internal/services/web/app_service_certificate_data_source.go +++ b/internal/services/web/app_service_certificate_data_source.go @@ -81,7 +81,7 @@ func dataSourceAppServiceCertificate() *pluginsdk.Resource { } func dataSourceAppServiceCertificateRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClient + client := meta.(*clients.Client).Web.CertificatesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_certificate_order_data_source.go b/internal/services/web/app_service_certificate_order_data_source.go index 56a6e06e1b5c..3048fe1bb430 100644 --- a/internal/services/web/app_service_certificate_order_data_source.go +++ b/internal/services/web/app_service_certificate_order_data_source.go @@ -143,7 +143,7 @@ func dataSourceAppServiceCertificateOrder() *pluginsdk.Resource { } func dataSourceAppServiceCertificateOrderRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesOrderClient + client := meta.(*clients.Client).Web.CertificatesOrderClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_certificate_order_resource.go b/internal/services/web/app_service_certificate_order_resource.go index 2c6bce84d2f2..1c00cc8a64a7 100644 --- a/internal/services/web/app_service_certificate_order_resource.go +++ b/internal/services/web/app_service_certificate_order_resource.go @@ -179,7 +179,7 @@ func resourceAppServiceCertificateOrder() *pluginsdk.Resource { } func resourceAppServiceCertificateOrderCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesOrderClient + client := meta.(*clients.Client).Web.CertificatesOrderClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -247,7 +247,7 @@ func resourceAppServiceCertificateOrderCreateUpdate(d *pluginsdk.ResourceData, m } func resourceAppServiceCertificateOrderRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesOrderClient + client := meta.(*clients.Client).Web.CertificatesOrderClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -313,7 +313,7 @@ func resourceAppServiceCertificateOrderRead(d *pluginsdk.ResourceData, meta inte } func resourceAppServiceCertificateOrderDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesOrderClient + client := meta.(*clients.Client).Web.CertificatesOrderClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_certificate_order_resource_test.go b/internal/services/web/app_service_certificate_order_resource_test.go index b649e63a5198..8a80d20ca745 100644 --- a/internal/services/web/app_service_certificate_order_resource_test.go +++ b/internal/services/web/app_service_certificate_order_resource_test.go @@ -162,7 +162,7 @@ func (r AppServiceCertificateOrderResource) Exists(ctx context.Context, clients return nil, err } - resp, err := clients.Web.CertificatesOrderClient.Get(ctx, id.ResourceGroup, id.Name) + resp, err := clients.Web.CertificatesOrderClientV1.Get(ctx, id.ResourceGroup, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_certificate_resource.go b/internal/services/web/app_service_certificate_resource.go index 06a9d8365715..d66499d34997 100644 --- a/internal/services/web/app_service_certificate_resource.go +++ b/internal/services/web/app_service_certificate_resource.go @@ -146,7 +146,7 @@ func resourceAppServiceCertificate() *pluginsdk.Resource { func resourceAppServiceCertificateCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { keyVaultsClient := meta.(*clients.Client).KeyVault - client := meta.(*clients.Client).Web.CertificatesClient + client := meta.(*clients.Client).Web.CertificatesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -224,7 +224,7 @@ func resourceAppServiceCertificateCreateUpdate(d *pluginsdk.ResourceData, meta i } func resourceAppServiceCertificateRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClient + client := meta.(*clients.Client).Web.CertificatesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -283,7 +283,7 @@ func resourceAppServiceCertificateRead(d *pluginsdk.ResourceData, meta interface } func resourceAppServiceCertificateDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClient + client := meta.(*clients.Client).Web.CertificatesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_certificate_resource_test.go b/internal/services/web/app_service_certificate_resource_test.go index 5c6d8e618e12..caf6dd07b2a1 100644 --- a/internal/services/web/app_service_certificate_resource_test.go +++ b/internal/services/web/app_service_certificate_resource_test.go @@ -101,7 +101,7 @@ func (r AppServiceCertificateResource) Exists(ctx context.Context, clients *clie return nil, err } - resp, err := clients.Web.CertificatesClient.Get(ctx, id.ResourceGroup, id.Name) + resp, err := clients.Web.CertificatesClientV1.Get(ctx, id.ResourceGroup, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_custom_hostname_binding_resource.go b/internal/services/web/app_service_custom_hostname_binding_resource.go index 10ad445aa464..ba2535e024cd 100644 --- a/internal/services/web/app_service_custom_hostname_binding_resource.go +++ b/internal/services/web/app_service_custom_hostname_binding_resource.go @@ -82,7 +82,7 @@ func resourceAppServiceCustomHostnameBinding() *pluginsdk.Resource { } func resourceAppServiceCustomHostnameBindingCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -150,7 +150,7 @@ func resourceAppServiceCustomHostnameBindingCreate(d *pluginsdk.ResourceData, me } func resourceAppServiceCustomHostnameBindingRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -183,7 +183,7 @@ func resourceAppServiceCustomHostnameBindingRead(d *pluginsdk.ResourceData, meta } func resourceAppServiceCustomHostnameBindingDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_custom_hostname_binding_resource_test.go b/internal/services/web/app_service_custom_hostname_binding_resource_test.go index 5ffd9621ee3f..fe59a716ac7f 100644 --- a/internal/services/web/app_service_custom_hostname_binding_resource_test.go +++ b/internal/services/web/app_service_custom_hostname_binding_resource_test.go @@ -130,7 +130,7 @@ func (r ServiceCustomHostnameBindingResource) Exists(ctx context.Context, client return nil, err } - resp, err := clients.Web.AppServicesClient.GetHostNameBinding(ctx, id.ResourceGroup, id.AppServiceName, id.Name) + resp, err := clients.Web.AppServicesClientV1.GetHostNameBinding(ctx, id.ResourceGroup, id.AppServiceName, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_data_source.go b/internal/services/web/app_service_data_source.go index c8b8fe4a4068..a44450c87627 100644 --- a/internal/services/web/app_service_data_source.go +++ b/internal/services/web/app_service_data_source.go @@ -28,7 +28,7 @@ func dataSourceAppService() *pluginsdk.Resource { Read: pluginsdk.DefaultTimeout(5 * time.Minute), }, - DeprecationMessage: "The `azurerm_app_service` data source has been superseded by the `azurerm_linux_function_app` and `azurerm_windows_web_app` data sources. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_app_service` data source has been superseded by the `azurerm_linux_web_app` and `azurerm_windows_web_app` data sources. This data source will be removed in v5.0 of the AzureRM Provider.", Schema: map[string]*pluginsdk.Schema{ "name": { @@ -159,7 +159,7 @@ func dataSourceAppService() *pluginsdk.Resource { } func dataSourceAppServiceRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_data_source_test.go b/internal/services/web/app_service_data_source_test.go index 278b0950f56b..6efffd1e9412 100644 --- a/internal/services/web/app_service_data_source_test.go +++ b/internal/services/web/app_service_data_source_test.go @@ -9,11 +9,15 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" ) type AppServiceDataSource struct{} func TestAccDataSourceAppService_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -33,6 +37,9 @@ func TestAccDataSourceAppService_basic(t *testing.T) { } func TestAccDataSourceAppService_tags(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -47,6 +54,9 @@ func TestAccDataSourceAppService_tags(t *testing.T) { } func TestAccDataSourceAppService_clientAppAffinityDisabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -60,6 +70,9 @@ func TestAccDataSourceAppService_clientAppAffinityDisabled(t *testing.T) { } func TestAccDataSourceAppService_32Bit(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -73,6 +86,9 @@ func TestAccDataSourceAppService_32Bit(t *testing.T) { } func TestAccDataSourceAppService_appSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -86,6 +102,9 @@ func TestAccDataSourceAppService_appSettings(t *testing.T) { } func TestAccDataSourceAppService_connectionString(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -99,6 +118,9 @@ func TestAccDataSourceAppService_connectionString(t *testing.T) { } func TestAccDataSourceAppService_ipRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -115,6 +137,9 @@ func TestAccDataSourceAppService_ipRestriction(t *testing.T) { } func TestAccDataSourceAppService_oneVNetSubnetIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -128,6 +153,9 @@ func TestAccDataSourceAppService_oneVNetSubnetIpRestriction(t *testing.T) { } func TestAccDataSourceAppService_scmUseMainIPRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -141,6 +169,9 @@ func TestAccDataSourceAppService_scmUseMainIPRestriction(t *testing.T) { } func TestAccDataSourceAppService_scmIPRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -157,6 +188,9 @@ func TestAccDataSourceAppService_scmIPRestriction(t *testing.T) { } func TestAccDataSourceAppService_withSourceControl(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -170,6 +204,9 @@ func TestAccDataSourceAppService_withSourceControl(t *testing.T) { } func TestAccDataSourceAppService_http2Enabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -183,6 +220,9 @@ func TestAccDataSourceAppService_http2Enabled(t *testing.T) { } func TestAccDataSourceAppService_minTls(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -196,6 +236,9 @@ func TestAccDataSourceAppService_minTls(t *testing.T) { } func TestAccDataSourceAppService_basicWindowsContainer(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service", "test") data.DataSourceTest(t, []acceptance.TestStep{ diff --git a/internal/services/web/app_service_hybrid_connection_resource.go b/internal/services/web/app_service_hybrid_connection_resource.go index 19808d25e6b2..5f50aa56ec09 100644 --- a/internal/services/web/app_service_hybrid_connection_resource.go +++ b/internal/services/web/app_service_hybrid_connection_resource.go @@ -39,7 +39,7 @@ func resourceAppServiceHybridConnection() *pluginsdk.Resource { return err }), - DeprecationMessage: "The `azurerm_app_service_hybrid_connection` resource has been superseded by the `azurerm_function_app_hybrid_connection` and `azurerm_web_app_hybrid_connection` resources. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_app_service_hybrid_connection` resource has been superseded by the `azurerm_function_app_hybrid_connection` and `azurerm_web_app_hybrid_connection` resources. This resource will be removed in v5.0 of the AzureRM Provider.", Timeouts: &pluginsdk.ResourceTimeout{ Create: pluginsdk.DefaultTimeout(30 * time.Minute), @@ -114,7 +114,7 @@ func resourceAppServiceHybridConnection() *pluginsdk.Resource { } func resourceAppServiceHybridConnectionCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -161,7 +161,7 @@ func resourceAppServiceHybridConnectionCreateUpdate(d *pluginsdk.ResourceData, m } func resourceAppServiceHybridConnectionRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 relayClient := meta.(*clients.Client).Relay.HybridConnectionsClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -222,7 +222,7 @@ func resourceAppServiceHybridConnectionRead(d *pluginsdk.ResourceData, meta inte } func resourceAppServiceHybridConnectionDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_hybrid_connection_resource_test.go b/internal/services/web/app_service_hybrid_connection_resource_test.go index 8ff687c0a461..08f850d9df8a 100644 --- a/internal/services/web/app_service_hybrid_connection_resource_test.go +++ b/internal/services/web/app_service_hybrid_connection_resource_test.go @@ -12,6 +12,7 @@ import ( "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -20,6 +21,9 @@ import ( type AppServiceHybridConnectionResource struct{} func TestAccAppServiceHybridConnection_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_hybrid_connection", "test") r := AppServiceHybridConnectionResource{} @@ -35,6 +39,9 @@ func TestAccAppServiceHybridConnection_basic(t *testing.T) { } func TestAccAppServiceHybridConnection_update(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_hybrid_connection", "test") r := AppServiceHybridConnectionResource{} @@ -57,6 +64,9 @@ func TestAccAppServiceHybridConnection_update(t *testing.T) { } func TestAccAppServiceHybridConnection_requiresImport(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_hybrid_connection", "test") r := AppServiceHybridConnectionResource{} @@ -72,6 +82,9 @@ func TestAccAppServiceHybridConnection_requiresImport(t *testing.T) { } func TestAccAppServiceHybridConnection_differentResourceGroup(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_hybrid_connection", "test") r := AppServiceHybridConnectionResource{} @@ -87,6 +100,9 @@ func TestAccAppServiceHybridConnection_differentResourceGroup(t *testing.T) { } func TestAccAppServiceHybridConnection_useSendKeyDeclaredOnHybridConnection(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_hybrid_connection", "test") r := AppServiceHybridConnectionResource{} @@ -107,7 +123,7 @@ func (r AppServiceHybridConnectionResource) Exists(ctx context.Context, clients return nil, err } - resp, err := clients.Web.AppServicesClient.GetHybridConnection(ctx, id.ResourceGroup, id.SiteName, id.HybridConnectionNamespaceName, id.RelayName) + resp, err := clients.Web.AppServicesClientV1.GetHybridConnection(ctx, id.ResourceGroup, id.SiteName, id.HybridConnectionNamespaceName, id.RelayName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_managed_certificate_resource.go b/internal/services/web/app_service_managed_certificate_resource.go index 268ead8aae99..ba82257f9329 100644 --- a/internal/services/web/app_service_managed_certificate_resource.go +++ b/internal/services/web/app_service_managed_certificate_resource.go @@ -98,8 +98,8 @@ func resourceAppServiceManagedCertificate() *pluginsdk.Resource { } func resourceAppServiceManagedCertificateCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClient - appServiceClient := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.CertificatesClientV1 + appServiceClient := meta.(*clients.Client).Web.AppServicesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -199,7 +199,7 @@ func resourceAppServiceManagedCertificateCreateUpdate(d *pluginsdk.ResourceData, } func resourceAppServiceManagedCertificateRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClient + client := meta.(*clients.Client).Web.CertificatesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -241,7 +241,7 @@ func resourceAppServiceManagedCertificateRead(d *pluginsdk.ResourceData, meta in } func resourceAppServiceManagedCertificateDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClient + client := meta.(*clients.Client).Web.CertificatesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_managed_certificate_resource_test.go b/internal/services/web/app_service_managed_certificate_resource_test.go index 7e6bda354e72..7e17a783b5be 100644 --- a/internal/services/web/app_service_managed_certificate_resource_test.go +++ b/internal/services/web/app_service_managed_certificate_resource_test.go @@ -84,7 +84,7 @@ func (t AppServiceManagedCertificateResource) Exists(ctx context.Context, client return nil, err } - resp, err := clients.Web.CertificatesClient.Get(ctx, id.ResourceGroup, id.CertificateName) + resp, err := clients.Web.CertificatesClientV1.Get(ctx, id.ResourceGroup, id.CertificateName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_plan_data_source.go b/internal/services/web/app_service_plan_data_source.go index ab675ebd439b..b800622faed3 100644 --- a/internal/services/web/app_service_plan_data_source.go +++ b/internal/services/web/app_service_plan_data_source.go @@ -21,7 +21,7 @@ func dataSourceAppServicePlan() *pluginsdk.Resource { return &pluginsdk.Resource{ Read: AppServicePlanDataSourceRead, - DeprecationMessage: "The `azurerm_app_service_plan` data source has been superseded by the `azurerm_service_plan` data source. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_app_service_plan` data source has been superseded by the `azurerm_service_plan` data source. This data source will be removed in v5.0 of the AzureRM Provider.", Timeouts: &pluginsdk.ResourceTimeout{ Read: pluginsdk.DefaultTimeout(5 * time.Minute), @@ -104,7 +104,7 @@ func dataSourceAppServicePlan() *pluginsdk.Resource { } func AppServicePlanDataSourceRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicePlansClient + client := meta.(*clients.Client).Web.AppServicePlansClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_plan_data_source_test.go b/internal/services/web/app_service_plan_data_source_test.go index d473704c03e1..e2961016d05d 100644 --- a/internal/services/web/app_service_plan_data_source_test.go +++ b/internal/services/web/app_service_plan_data_source_test.go @@ -8,11 +8,15 @@ import ( "testing" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" ) type AppServicePlanDataSource struct{} func TestAccAppServicePlanDataSource_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service_plan", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -30,6 +34,9 @@ func TestAccAppServicePlanDataSource_basic(t *testing.T) { } func TestAccAppServicePlanDataSource_complete(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service_plan", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -48,6 +55,9 @@ func TestAccAppServicePlanDataSource_complete(t *testing.T) { } func TestAccAppServicePlanDataSource_premiumSKU(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service_plan", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -65,6 +75,9 @@ func TestAccAppServicePlanDataSource_premiumSKU(t *testing.T) { } func TestAccAppServicePlanDataSource_basicWindowsContainer(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_app_service_plan", "test") data.DataSourceTest(t, []acceptance.TestStep{ diff --git a/internal/services/web/app_service_plan_resource.go b/internal/services/web/app_service_plan_resource.go index 330a51a63192..71680683796a 100644 --- a/internal/services/web/app_service_plan_resource.go +++ b/internal/services/web/app_service_plan_resource.go @@ -37,7 +37,7 @@ func resourceAppServicePlan() *pluginsdk.Resource { return err }), - DeprecationMessage: "The `azurerm_app_service_plan` resource has been superseded by the `azurerm_service_plan` resource. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_app_service_plan` resource has been superseded by the `azurerm_service_plan` resource. This resource will be removed in v5.0 of the AzureRM Provider.", Timeouts: &pluginsdk.ResourceTimeout{ Create: pluginsdk.DefaultTimeout(60 * time.Minute), @@ -153,7 +153,7 @@ func resourceAppServicePlan() *pluginsdk.Resource { } func resourceAppServicePlanCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicePlansClient + client := meta.(*clients.Client).Web.AppServicePlansClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -243,7 +243,7 @@ func resourceAppServicePlanCreateUpdate(d *pluginsdk.ResourceData, meta interfac } func resourceAppServicePlanRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicePlansClient + client := meta.(*clients.Client).Web.AppServicePlansClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -311,7 +311,7 @@ func resourceAppServicePlanRead(d *pluginsdk.ResourceData, meta interface{}) err } func resourceAppServicePlanDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicePlansClient + client := meta.(*clients.Client).Web.AppServicePlansClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_plan_resource_test.go b/internal/services/web/app_service_plan_resource_test.go index ff4f680a5ee2..98fc630f0299 100644 --- a/internal/services/web/app_service_plan_resource_test.go +++ b/internal/services/web/app_service_plan_resource_test.go @@ -12,6 +12,7 @@ import ( "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -20,6 +21,9 @@ import ( type AppServicePlanResource struct{} func TestAccAppServicePlan_basicWindows(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -37,6 +41,9 @@ func TestAccAppServicePlan_basicWindows(t *testing.T) { } func TestAccAppServicePlan_basicLinux(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -60,6 +67,9 @@ func TestAccAppServicePlan_basicLinux(t *testing.T) { } func TestAccAppServicePlan_requiresImport(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -75,6 +85,9 @@ func TestAccAppServicePlan_requiresImport(t *testing.T) { } func TestAccAppServicePlan_standardWindows(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -90,6 +103,9 @@ func TestAccAppServicePlan_standardWindows(t *testing.T) { } func TestAccAppServicePlan_premiumWindows(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -105,6 +121,9 @@ func TestAccAppServicePlan_premiumWindows(t *testing.T) { } func TestAccAppServicePlan_premiumWindowsUpdated(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -128,6 +147,9 @@ func TestAccAppServicePlan_premiumWindowsUpdated(t *testing.T) { } func TestAccAppServicePlan_completeWindows(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -153,6 +175,9 @@ func TestAccAppServicePlan_completeWindows(t *testing.T) { } func TestAccAppServicePlan_consumptionPlan(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -169,6 +194,9 @@ func TestAccAppServicePlan_consumptionPlan(t *testing.T) { } func TestAccAppServicePlan_linuxConsumptionPlan(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -184,6 +212,9 @@ func TestAccAppServicePlan_linuxConsumptionPlan(t *testing.T) { } func TestAccAppServicePlan_premiumConsumptionPlan(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -201,6 +232,9 @@ func TestAccAppServicePlan_premiumConsumptionPlan(t *testing.T) { } func TestAccAppServicePlan_basicWindowsContainer(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -220,6 +254,9 @@ func TestAccAppServicePlan_basicWindowsContainer(t *testing.T) { } func TestAccAppServicePlan_zoneRedundant(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test") r := AppServicePlanResource{} @@ -244,7 +281,7 @@ func (r AppServicePlanResource) Exists(ctx context.Context, clients *clients.Cli return nil, err } - resp, err := clients.Web.AppServicePlansClient.Get(ctx, id.ResourceGroup, id.ServerFarmName) + resp, err := clients.Web.AppServicePlansClientV1.Get(ctx, id.ResourceGroup, id.ServerFarmName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_resource.go b/internal/services/web/app_service_resource.go index 0386669fe39b..d4177db43889 100644 --- a/internal/services/web/app_service_resource.go +++ b/internal/services/web/app_service_resource.go @@ -33,7 +33,7 @@ func resourceAppService() *pluginsdk.Resource { Update: resourceAppServiceUpdate, Delete: resourceAppServiceDelete, - DeprecationMessage: "The `azurerm_app_service` resource has been superseded by the `azurerm_linux_web_app` and `azurerm_windows_web_app` resources. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_app_service` resource has been superseded by the `azurerm_linux_web_app` and `azurerm_windows_web_app` resources. This resource will be removed in v5.0 of the AzureRM Provider.", Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { _, err := parse.AppServiceID(id) @@ -228,8 +228,8 @@ func resourceAppService() *pluginsdk.Resource { } func resourceAppServiceCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient - aspClient := meta.(*clients.Client).Web.AppServicePlansClient + client := meta.(*clients.Client).Web.AppServicesClientV1 + aspClient := meta.(*clients.Client).Web.AppServicePlansClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -385,7 +385,7 @@ func resourceAppServiceCreate(d *pluginsdk.ResourceData, meta interface{}) error } func resourceAppServiceUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -617,7 +617,7 @@ func resourceAppServiceUpdate(d *pluginsdk.ResourceData, meta interface{}) error } func resourceAppServiceRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -795,7 +795,7 @@ func resourceAppServiceRead(d *pluginsdk.ResourceData, meta interface{}) error { } func resourceAppServiceDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_resource_test.go b/internal/services/web/app_service_resource_test.go index 140aa98447a2..dbc493eb7eaf 100644 --- a/internal/services/web/app_service_resource_test.go +++ b/internal/services/web/app_service_resource_test.go @@ -14,6 +14,7 @@ import ( "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -22,6 +23,9 @@ import ( type AppServiceResource struct{} func TestAccAppService_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -42,6 +46,9 @@ func TestAccAppService_basic(t *testing.T) { } func TestAccAppService_requiresImport(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -57,6 +64,9 @@ func TestAccAppService_requiresImport(t *testing.T) { } func TestAccAppService_movingAppService(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -77,6 +87,9 @@ func TestAccAppService_movingAppService(t *testing.T) { } func TestAccAppService_freeTier(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -92,6 +105,9 @@ func TestAccAppService_freeTier(t *testing.T) { } func TestAccAppService_sharedTier(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -107,6 +123,9 @@ func TestAccAppService_sharedTier(t *testing.T) { } func TestAccAppService_32Bit(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -123,6 +142,9 @@ func TestAccAppService_32Bit(t *testing.T) { } func TestAccAppService_backup(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -167,6 +189,9 @@ func TestAccAppService_backup(t *testing.T) { } func TestAccAppService_http2Enabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -183,6 +208,9 @@ func TestAccAppService_http2Enabled(t *testing.T) { } func TestAccAppService_alwaysOn(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -199,6 +227,9 @@ func TestAccAppService_alwaysOn(t *testing.T) { } func TestAccAppService_appCommandLine(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -215,6 +246,9 @@ func TestAccAppService_appCommandLine(t *testing.T) { } func TestAccAppService_httpsOnly(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -231,6 +265,9 @@ func TestAccAppService_httpsOnly(t *testing.T) { } func TestAccAppService_clientCertEnabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -254,6 +291,9 @@ func TestAccAppService_clientCertEnabled(t *testing.T) { } func TestAccAppService_clientCertEnabledWithMode(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -271,6 +311,9 @@ func TestAccAppService_clientCertEnabledWithMode(t *testing.T) { } func TestAccAppService_appSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -287,6 +330,9 @@ func TestAccAppService_appSettings(t *testing.T) { } func TestAccAppService_appSettingsVnetRouteAll(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -304,6 +350,9 @@ func TestAccAppService_appSettingsVnetRouteAll(t *testing.T) { } func TestAccAppService_siteConfigVnetRouteAll(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -320,6 +369,9 @@ func TestAccAppService_siteConfigVnetRouteAll(t *testing.T) { } func TestAccAppService_clientAffinityEnabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -336,6 +388,9 @@ func TestAccAppService_clientAffinityEnabled(t *testing.T) { } func TestAccAppService_clientAffinityDisabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -352,6 +407,9 @@ func TestAccAppService_clientAffinityDisabled(t *testing.T) { } func TestAccAppService_enableManageServiceIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -369,6 +427,9 @@ func TestAccAppService_enableManageServiceIdentity(t *testing.T) { } func TestAccAppService_updateResourceByEnablingManageServiceIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -393,6 +454,9 @@ func TestAccAppService_updateResourceByEnablingManageServiceIdentity(t *testing. } func TestAccAppService_userAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -411,6 +475,9 @@ func TestAccAppService_userAssignedIdentity(t *testing.T) { } func TestAccAppService_clientAffinityUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -435,6 +502,9 @@ func TestAccAppService_clientAffinityUpdate(t *testing.T) { } func TestAccAppService_connectionStrings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -457,6 +527,9 @@ func TestAccAppService_connectionStrings(t *testing.T) { } func TestAccAppService_storageAccounts(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -480,6 +553,9 @@ func TestAccAppService_storageAccounts(t *testing.T) { } func TestAccAppService_oneIpv4Restriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -497,6 +573,9 @@ func TestAccAppService_oneIpv4Restriction(t *testing.T) { } func TestAccAppService_oneIpv6Restriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -514,6 +593,9 @@ func TestAccAppService_oneIpv6Restriction(t *testing.T) { } func TestAccAppService_completeIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -579,6 +661,9 @@ func TestAccAppService_completeIpRestriction(t *testing.T) { } func TestAccAppService_oneVNetSubnetIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -594,6 +679,9 @@ func TestAccAppService_oneVNetSubnetIpRestriction(t *testing.T) { } func TestAccAppService_multipleVNetSubnetIpRestrictionUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -626,6 +714,9 @@ func TestAccAppService_multipleVNetSubnetIpRestrictionUpdate(t *testing.T) { } func TestAccAppService_mixedIpRestrictionUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -658,6 +749,9 @@ func TestAccAppService_mixedIpRestrictionUpdate(t *testing.T) { } func TestAccAppService_zeroedIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -690,6 +784,9 @@ func TestAccAppService_zeroedIpRestriction(t *testing.T) { } func TestAccAppService_zeroedIpRestrictionHeaders(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -759,6 +856,9 @@ func TestAccAppService_zeroedIpRestrictionHeaders(t *testing.T) { } func TestAccAppService_manyIpRestrictions(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -778,6 +878,9 @@ func TestAccAppService_manyIpRestrictions(t *testing.T) { } func TestAccAppService_scmUseMainIPRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -793,6 +896,9 @@ func TestAccAppService_scmUseMainIPRestriction(t *testing.T) { } func TestAccAppService_scmOneIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -808,6 +914,9 @@ func TestAccAppService_scmOneIpRestriction(t *testing.T) { } func TestAccAppService_completeScmIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -837,6 +946,9 @@ func TestAccAppService_completeScmIpRestriction(t *testing.T) { } func TestAccAppService_oneVNetSubnetScmIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -852,6 +964,9 @@ func TestAccAppService_oneVNetSubnetScmIpRestriction(t *testing.T) { } func TestAccAppService_zeroedScmIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -884,6 +999,9 @@ func TestAccAppService_zeroedScmIpRestriction(t *testing.T) { } func TestAccAppService_manyScmIpRestrictions(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -899,6 +1017,9 @@ func TestAccAppService_manyScmIpRestrictions(t *testing.T) { } func TestAccAppService_defaultDocuments(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -917,6 +1038,9 @@ func TestAccAppService_defaultDocuments(t *testing.T) { } func TestAccAppService_enabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -933,6 +1057,9 @@ func TestAccAppService_enabled(t *testing.T) { } func TestAccAppService_localMySql(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -949,6 +1076,9 @@ func TestAccAppService_localMySql(t *testing.T) { } func TestAccAppService_applicationBlobStorageLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -979,6 +1109,9 @@ func TestAccAppService_applicationBlobStorageLogs(t *testing.T) { } func TestAccAppService_httpFileSystemLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1001,6 +1134,9 @@ func TestAccAppService_httpFileSystemLogs(t *testing.T) { } func TestAccAppService_httpBlobStorageLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1023,6 +1159,9 @@ func TestAccAppService_httpBlobStorageLogs(t *testing.T) { } func TestAccAppService_httpFileSystemAndStorageBlobLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1038,6 +1177,9 @@ func TestAccAppService_httpFileSystemAndStorageBlobLogs(t *testing.T) { } func TestAccAppService_managedPipelineMode(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1054,6 +1196,9 @@ func TestAccAppService_managedPipelineMode(t *testing.T) { } func TestAccAppService_detailedErrorMessagesLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1077,6 +1222,9 @@ func TestAccAppService_detailedErrorMessagesLogs(t *testing.T) { } func TestAccAzureRMAppService_failedRequestTracingLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1100,6 +1248,9 @@ func TestAccAzureRMAppService_failedRequestTracingLogs(t *testing.T) { } func TestAccAppService_tagsUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1125,6 +1276,9 @@ func TestAccAppService_tagsUpdate(t *testing.T) { } func TestAccAppService_remoteDebugging(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1142,6 +1296,9 @@ func TestAccAppService_remoteDebugging(t *testing.T) { } func TestAccAppService_windowsDotNet2(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1158,6 +1315,9 @@ func TestAccAppService_windowsDotNet2(t *testing.T) { } func TestAccAppService_windowsDotNet4(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1174,6 +1334,9 @@ func TestAccAppService_windowsDotNet4(t *testing.T) { } func TestAccAppService_windowsDotNet5(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1190,6 +1353,9 @@ func TestAccAppService_windowsDotNet5(t *testing.T) { } func TestAccAppService_windowsDotNet6(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1206,6 +1372,9 @@ func TestAccAppService_windowsDotNet6(t *testing.T) { } func TestAccAppService_windowsDotNetUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1242,6 +1411,9 @@ func TestAccAppService_windowsDotNetUpdate(t *testing.T) { } func TestAccAppService_windowsJava7Java(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1260,6 +1432,9 @@ func TestAccAppService_windowsJava7Java(t *testing.T) { } func TestAccAppService_windowsJava8Java(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1278,6 +1453,9 @@ func TestAccAppService_windowsJava8Java(t *testing.T) { } func TestAccAppService_windowsJava11Java(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1296,6 +1474,9 @@ func TestAccAppService_windowsJava11Java(t *testing.T) { } func TestAccAppService_windowsJava7Jetty(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1314,6 +1495,9 @@ func TestAccAppService_windowsJava7Jetty(t *testing.T) { } func TestAccAppService_windowsJava8Jetty(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1332,6 +1516,9 @@ func TestAccAppService_windowsJava8Jetty(t *testing.T) { } func TestAccAppService_windowsJava11Jetty(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1350,6 +1537,9 @@ func TestAccAppService_windowsJava11Jetty(t *testing.T) { } func TestAccAppService_windowsJava7Tomcat(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1368,6 +1558,9 @@ func TestAccAppService_windowsJava7Tomcat(t *testing.T) { } func TestAccAppService_windowsJava8Tomcat(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1386,6 +1579,9 @@ func TestAccAppService_windowsJava8Tomcat(t *testing.T) { } func TestAccAppService_windowsJava11Tomcat(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1404,6 +1600,9 @@ func TestAccAppService_windowsJava11Tomcat(t *testing.T) { } func TestAccAppService_windowsPHP7(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1420,6 +1619,9 @@ func TestAccAppService_windowsPHP7(t *testing.T) { } func TestAccAppService_windowsPython(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1436,6 +1638,9 @@ func TestAccAppService_windowsPython(t *testing.T) { } func TestAccAppService_webSockets(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1452,6 +1657,9 @@ func TestAccAppService_webSockets(t *testing.T) { } func TestAccAppService_scmType(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1470,6 +1678,9 @@ func TestAccAppService_scmType(t *testing.T) { } func TestAccAppService_withSourceControl(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1485,6 +1696,9 @@ func TestAccAppService_withSourceControl(t *testing.T) { } func TestAccAppService_withSourceControlUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1507,6 +1721,9 @@ func TestAccAppService_withSourceControlUpdate(t *testing.T) { } func TestAccAppService_ftpsState(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1523,6 +1740,9 @@ func TestAccAppService_ftpsState(t *testing.T) { } func TestAccAppService_healthCheckPath(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1539,6 +1759,9 @@ func TestAccAppService_healthCheckPath(t *testing.T) { } func TestAccAppService_numberOfWorkers(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1556,6 +1779,9 @@ func TestAccAppService_numberOfWorkers(t *testing.T) { // Note: to specify `linux_fx_version` the App Service Plan must be of `kind = "Linux"`, and `reserved = true` func TestAccAppService_linuxFxVersion(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1571,6 +1797,9 @@ func TestAccAppService_linuxFxVersion(t *testing.T) { } func TestAccAppService_minTls(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1595,6 +1824,9 @@ func TestAccAppService_minTls(t *testing.T) { } func TestAccAppService_corsSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1613,6 +1845,9 @@ func TestAccAppService_corsSettings(t *testing.T) { } func TestAccAppService_authSettingsAdditionalLoginParams(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } tenantID := os.Getenv("ARM_TENANT_ID") data := acceptance.BuildTestData(t, "azurerm_app_service", "test") @@ -1636,6 +1871,9 @@ func TestAccAppService_authSettingsAdditionalLoginParams(t *testing.T) { } func TestAccAppService_authSettingsAdditionalAllowedExternalRedirectUrls(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } tenantID := os.Getenv("ARM_TENANT_ID") data := acceptance.BuildTestData(t, "azurerm_app_service", "test") @@ -1660,6 +1898,9 @@ func TestAccAppService_authSettingsAdditionalAllowedExternalRedirectUrls(t *test } func TestAccAppService_authSettingsRuntimeVersion(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } tenantID := os.Getenv("ARM_TENANT_ID") data := acceptance.BuildTestData(t, "azurerm_app_service", "test") @@ -1683,6 +1924,9 @@ func TestAccAppService_authSettingsRuntimeVersion(t *testing.T) { } func TestAccAppService_authSettingsTokenRefreshExtensionHours(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } tenantID := os.Getenv("ARM_TENANT_ID") data := acceptance.BuildTestData(t, "azurerm_app_service", "test") @@ -1706,6 +1950,9 @@ func TestAccAppService_authSettingsTokenRefreshExtensionHours(t *testing.T) { } func TestAccAppService_authSettingsUnauthenticatedClientAction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } tenantID := os.Getenv("ARM_TENANT_ID") data := acceptance.BuildTestData(t, "azurerm_app_service", "test") @@ -1729,6 +1976,9 @@ func TestAccAppService_authSettingsUnauthenticatedClientAction(t *testing.T) { } func TestAccAppService_authSettingsTokenStoreEnabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } tenantID := os.Getenv("ARM_TENANT_ID") data := acceptance.BuildTestData(t, "azurerm_app_service", "test") @@ -1752,6 +2002,9 @@ func TestAccAppService_authSettingsTokenStoreEnabled(t *testing.T) { } func TestAccAppService_aadAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } tenantID := os.Getenv("ARM_TENANT_ID") data := acceptance.BuildTestData(t, "azurerm_app_service", "test") @@ -1774,6 +2027,9 @@ func TestAccAppService_aadAuthSettings(t *testing.T) { } func TestAccAppService_facebookAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1793,6 +2049,9 @@ func TestAccAppService_facebookAuthSettings(t *testing.T) { } func TestAccAppService_googleAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1812,6 +2071,9 @@ func TestAccAppService_googleAuthSettings(t *testing.T) { } func TestAccAppService_microsoftAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1831,6 +2093,9 @@ func TestAccAppService_microsoftAuthSettings(t *testing.T) { } func TestAccAppService_twitterAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1849,6 +2114,9 @@ func TestAccAppService_twitterAuthSettings(t *testing.T) { } func TestAccAppService_multiAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } tenantID := os.Getenv("ARM_TENANT_ID") data := acceptance.BuildTestData(t, "azurerm_app_service", "test") @@ -1886,6 +2154,9 @@ func TestAccAppService_multiAuthSettings(t *testing.T) { } func TestAccAppService_basicWindowsContainer(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1903,6 +2174,9 @@ func TestAccAppService_basicWindowsContainer(t *testing.T) { } func TestAccAppService_AcrManageIdentityCredentials(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1918,6 +2192,9 @@ func TestAccAppService_AcrManageIdentityCredentials(t *testing.T) { } func TestAccAppService_AcrUserAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1933,6 +2210,9 @@ func TestAccAppService_AcrUserAssignedIdentity(t *testing.T) { } func TestAccAppService_keyVaultUserAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service", "test") r := AppServiceResource{} @@ -1953,7 +2233,7 @@ func (r AppServiceResource) Exists(ctx context.Context, clients *clients.Client, return nil, err } - resp, err := clients.Web.AppServicesClient.Get(ctx, id.ResourceGroup, id.SiteName) + resp, err := clients.Web.AppServicesClientV1.Get(ctx, id.ResourceGroup, id.SiteName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_slot_custom_hostname_binding_resource.go b/internal/services/web/app_service_slot_custom_hostname_binding_resource.go index 2729db88e8b6..506534c00f7d 100644 --- a/internal/services/web/app_service_slot_custom_hostname_binding_resource.go +++ b/internal/services/web/app_service_slot_custom_hostname_binding_resource.go @@ -81,7 +81,7 @@ func resourceAppServiceSlotCustomHostnameBinding() *pluginsdk.Resource { } func resourceAppServiceSlotCustomHostnameBindingCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -136,7 +136,7 @@ func resourceAppServiceSlotCustomHostnameBindingCreate(d *pluginsdk.ResourceData } func resourceAppServiceSlotCustomHostnameBindingRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -169,7 +169,7 @@ func resourceAppServiceSlotCustomHostnameBindingRead(d *pluginsdk.ResourceData, } func resourceAppServiceSlotCustomHostnameBindingDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_slot_custom_hostname_binding_resource_test.go b/internal/services/web/app_service_slot_custom_hostname_binding_resource_test.go index 7dd763b91268..715f2cbb45ea 100644 --- a/internal/services/web/app_service_slot_custom_hostname_binding_resource_test.go +++ b/internal/services/web/app_service_slot_custom_hostname_binding_resource_test.go @@ -83,7 +83,7 @@ func (r AppServiceSlotCustomHostnameBindingResource) Exists(ctx context.Context, return nil, err } - resp, err := clients.Web.AppServicesClient.GetHostNameBindingSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName, id.HostNameBindingName) + resp, err := clients.Web.AppServicesClientV1.GetHostNameBindingSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName, id.HostNameBindingName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_slot_resource.go b/internal/services/web/app_service_slot_resource.go index 5c1b34f6a543..46943ebb6993 100644 --- a/internal/services/web/app_service_slot_resource.go +++ b/internal/services/web/app_service_slot_resource.go @@ -32,7 +32,7 @@ func resourceAppServiceSlot() *pluginsdk.Resource { Update: resourceAppServiceSlotCreateUpdate, Delete: resourceAppServiceSlotDelete, - DeprecationMessage: "The `azurerm_app_service_slot` resource has been superseded by the `azurerm_linux_web_app_slot` and `azurerm_windows_web_app_slot` resources. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_app_service_slot` resource has been superseded by the `azurerm_linux_web_app_slot` and `azurerm_windows_web_app_slot` resources. This resource will be removed in v5.0 of the AzureRM Provider.", Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { _, err := parse.AppServiceSlotID(id) @@ -181,7 +181,7 @@ func resourceAppServiceSlot() *pluginsdk.Resource { } func resourceAppServiceSlotCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -252,7 +252,7 @@ func resourceAppServiceSlotCreateUpdate(d *pluginsdk.ResourceData, meta interfac } func resourceAppServiceSlotUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -399,7 +399,7 @@ func resourceAppServiceSlotUpdate(d *pluginsdk.ResourceData, meta interface{}) e } func resourceAppServiceSlotRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -549,7 +549,7 @@ func resourceAppServiceSlotRead(d *pluginsdk.ResourceData, meta interface{}) err } func resourceAppServiceSlotDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_slot_resource_test.go b/internal/services/web/app_service_slot_resource_test.go index ee3c7e1dfa2e..5c81955a92b9 100644 --- a/internal/services/web/app_service_slot_resource_test.go +++ b/internal/services/web/app_service_slot_resource_test.go @@ -14,6 +14,7 @@ import ( "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -22,6 +23,9 @@ import ( type AppServiceSlotResource struct{} func TestAccAppServiceSlot_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -37,6 +41,9 @@ func TestAccAppServiceSlot_basic(t *testing.T) { } func TestAccAppServiceSlot_requiresImport(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -52,6 +59,9 @@ func TestAccAppServiceSlot_requiresImport(t *testing.T) { } func TestAccAppServiceSlot_32Bit(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -68,6 +78,9 @@ func TestAccAppServiceSlot_32Bit(t *testing.T) { } func TestAccAppServiceSlot_alwaysOn(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -84,6 +97,9 @@ func TestAccAppServiceSlot_alwaysOn(t *testing.T) { } func TestAccAppServiceSlot_appCommandLine(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -100,6 +116,9 @@ func TestAccAppServiceSlot_appCommandLine(t *testing.T) { } func TestAccAppServiceSlot_appSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -116,6 +135,9 @@ func TestAccAppServiceSlot_appSettings(t *testing.T) { } func TestAccAppServiceSlot_clientAffinityEnabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -131,6 +153,9 @@ func TestAccAppServiceSlot_clientAffinityEnabled(t *testing.T) { } func TestAccAppServiceSlot_clientAffinityEnabledUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -153,6 +178,9 @@ func TestAccAppServiceSlot_clientAffinityEnabledUpdate(t *testing.T) { } func TestAccAppServiceSlot_connectionStrings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -175,6 +203,9 @@ func TestAccAppServiceSlot_connectionStrings(t *testing.T) { } func TestAccAppServiceSlot_storageAccounts(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -198,6 +229,9 @@ func TestAccAppServiceSlot_storageAccounts(t *testing.T) { } func TestAccAppServiceSlot_ipRestrictionHeaders(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -213,6 +247,9 @@ func TestAccAppServiceSlot_ipRestrictionHeaders(t *testing.T) { } func TestAccAppServiceSlot_corsSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -228,6 +265,9 @@ func TestAccAppServiceSlot_corsSettings(t *testing.T) { } func TestAccAppServiceSlot_authSettingsAdditionalLoginParams(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") tenantID := os.Getenv("ARM_TENANT_ID") r := AppServiceSlotResource{} @@ -250,6 +290,9 @@ func TestAccAppServiceSlot_authSettingsAdditionalLoginParams(t *testing.T) { } func TestAccAppServiceSlot_authSettingsAdditionalAllowedExternalRedirectUrls(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") tenantID := os.Getenv("ARM_TENANT_ID") r := AppServiceSlotResource{} @@ -273,6 +316,9 @@ func TestAccAppServiceSlot_authSettingsAdditionalAllowedExternalRedirectUrls(t * } func TestAccAppServiceSlot_authSettingsRuntimeVersion(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") tenantID := os.Getenv("ARM_TENANT_ID") r := AppServiceSlotResource{} @@ -295,6 +341,9 @@ func TestAccAppServiceSlot_authSettingsRuntimeVersion(t *testing.T) { } func TestAccAppServiceSlot_authSettingsTokenRefreshExtensionHours(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") tenantID := os.Getenv("ARM_TENANT_ID") r := AppServiceSlotResource{} @@ -317,6 +366,9 @@ func TestAccAppServiceSlot_authSettingsTokenRefreshExtensionHours(t *testing.T) } func TestAccAppServiceSlot_authSettingsUnauthenticatedClientAction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") tenantID := os.Getenv("ARM_TENANT_ID") r := AppServiceSlotResource{} @@ -339,6 +391,9 @@ func TestAccAppServiceSlot_authSettingsUnauthenticatedClientAction(t *testing.T) } func TestAccAppServiceSlot_authSettingsTokenStoreEnabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") tenantID := os.Getenv("ARM_TENANT_ID") r := AppServiceSlotResource{} @@ -361,6 +416,9 @@ func TestAccAppServiceSlot_authSettingsTokenStoreEnabled(t *testing.T) { } func TestAccAppServiceSlot_aadAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") tenantID := os.Getenv("ARM_TENANT_ID") r := AppServiceSlotResource{} @@ -382,6 +440,9 @@ func TestAccAppServiceSlot_aadAuthSettings(t *testing.T) { } func TestAccAppServiceSlot_facebookAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -401,6 +462,9 @@ func TestAccAppServiceSlot_facebookAuthSettings(t *testing.T) { } func TestAccAppServiceSlot_googleAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -419,6 +483,9 @@ func TestAccAppServiceSlot_googleAuthSettings(t *testing.T) { } func TestAccAppServiceSlot_microsoftAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -438,6 +505,9 @@ func TestAccAppServiceSlot_microsoftAuthSettings(t *testing.T) { } func TestAccAppServiceSlot_twitterAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -456,6 +526,9 @@ func TestAccAppServiceSlot_twitterAuthSettings(t *testing.T) { } func TestAccAppServiceSlot_multiAuthSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") tenantID := os.Getenv("ARM_TENANT_ID") r := AppServiceSlotResource{} @@ -492,6 +565,9 @@ func TestAccAppServiceSlot_multiAuthSettings(t *testing.T) { } func TestAccAppServiceSlot_defaultDocuments(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -509,6 +585,9 @@ func TestAccAppServiceSlot_defaultDocuments(t *testing.T) { } func TestAccAppServiceSlot_enabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -524,6 +603,9 @@ func TestAccAppServiceSlot_enabled(t *testing.T) { } func TestAccAppServiceSlot_enabledUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -546,6 +628,9 @@ func TestAccAppServiceSlot_enabledUpdate(t *testing.T) { } func TestAccAppServiceSlot_httpsOnly(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -561,6 +646,9 @@ func TestAccAppServiceSlot_httpsOnly(t *testing.T) { } func TestAccAppServiceSlot_httpsOnlyUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -583,6 +671,9 @@ func TestAccAppServiceSlot_httpsOnlyUpdate(t *testing.T) { } func TestAccAppServiceSlot_http2Enabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -598,6 +689,9 @@ func TestAccAppServiceSlot_http2Enabled(t *testing.T) { } func TestAccAppServiceSlot_oneIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -613,6 +707,9 @@ func TestAccAppServiceSlot_oneIpRestriction(t *testing.T) { } func TestAccAppServiceSlot_oneVNetSubnetIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -628,6 +725,9 @@ func TestAccAppServiceSlot_oneVNetSubnetIpRestriction(t *testing.T) { } func TestAccAppServiceSlot_zeroedIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -660,6 +760,9 @@ func TestAccAppServiceSlot_zeroedIpRestriction(t *testing.T) { } func TestAccAppServiceSlot_manyIpRestrictions(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -675,6 +778,9 @@ func TestAccAppServiceSlot_manyIpRestrictions(t *testing.T) { } func TestAccAppServiceSlot_scmUseMainIPRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -690,6 +796,9 @@ func TestAccAppServiceSlot_scmUseMainIPRestriction(t *testing.T) { } func TestAccAppServiceSlot_scmOneIPRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -705,6 +814,9 @@ func TestAccAppServiceSlot_scmOneIPRestriction(t *testing.T) { } func TestAccAppServiceSlot_localMySql(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -720,6 +832,9 @@ func TestAccAppServiceSlot_localMySql(t *testing.T) { } func TestAccAppServiceSlot_managedPipelineMode(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -735,6 +850,9 @@ func TestAccAppServiceSlot_managedPipelineMode(t *testing.T) { } func TestAccAppServiceSlot_tagsUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -760,6 +878,9 @@ func TestAccAppServiceSlot_tagsUpdate(t *testing.T) { } func TestAccAppServiceSlot_remoteDebugging(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -776,6 +897,9 @@ func TestAccAppServiceSlot_remoteDebugging(t *testing.T) { } func TestAccAppServiceSlot_windowsDotNet2(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -791,6 +915,9 @@ func TestAccAppServiceSlot_windowsDotNet2(t *testing.T) { } func TestAccAppServiceSlot_updateManageServiceIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -814,6 +941,9 @@ func TestAccAppServiceSlot_updateManageServiceIdentity(t *testing.T) { } func TestAccAppServiceSlot_windowsDotNet4(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -829,6 +959,9 @@ func TestAccAppServiceSlot_windowsDotNet4(t *testing.T) { } func TestAccAppServiceSlot_windowsDotNet5(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -844,6 +977,9 @@ func TestAccAppServiceSlot_windowsDotNet5(t *testing.T) { } func TestAccAppServiceSlot_windowsDotNet6(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -859,6 +995,9 @@ func TestAccAppServiceSlot_windowsDotNet6(t *testing.T) { } func TestAccAppServiceSlot_keyVaultUserAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -873,6 +1012,9 @@ func TestAccAppServiceSlot_keyVaultUserAssignedIdentity(t *testing.T) { } func TestAccAppServiceSlot_userAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -891,6 +1033,9 @@ func TestAccAppServiceSlot_userAssignedIdentity(t *testing.T) { } func TestAccAppServiceSlot_windowsDotNetUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -927,6 +1072,9 @@ func TestAccAppServiceSlot_windowsDotNetUpdate(t *testing.T) { } func TestAccAppServiceSlot_windowsJava7Jetty(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -944,6 +1092,9 @@ func TestAccAppServiceSlot_windowsJava7Jetty(t *testing.T) { } func TestAccAppServiceSlot_windowsJava8Jetty(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -961,6 +1112,9 @@ func TestAccAppServiceSlot_windowsJava8Jetty(t *testing.T) { } func TestAccAppServiceSlot_windowsJava11Jetty(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -978,6 +1132,9 @@ func TestAccAppServiceSlot_windowsJava11Jetty(t *testing.T) { } func TestAccAppServiceSlot_windowsJava7Tomcat(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -995,6 +1152,9 @@ func TestAccAppServiceSlot_windowsJava7Tomcat(t *testing.T) { } func TestAccAppServiceSlot_windowsJava8Tomcat(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1012,6 +1172,9 @@ func TestAccAppServiceSlot_windowsJava8Tomcat(t *testing.T) { } func TestAccAppServiceSlot_windowsJava11Tomcat(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1029,6 +1192,9 @@ func TestAccAppServiceSlot_windowsJava11Tomcat(t *testing.T) { } func TestAccAppServiceSlot_windowsPHP7(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1044,6 +1210,9 @@ func TestAccAppServiceSlot_windowsPHP7(t *testing.T) { } func TestAccAppServiceSlot_windowsPython(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1059,6 +1228,9 @@ func TestAccAppServiceSlot_windowsPython(t *testing.T) { } func TestAccAppServiceSlot_webSockets(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1074,6 +1246,9 @@ func TestAccAppServiceSlot_webSockets(t *testing.T) { } func TestAccAppServiceSlot_enableManageServiceIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1091,6 +1266,9 @@ func TestAccAppServiceSlot_enableManageServiceIdentity(t *testing.T) { } func TestAccAppServiceSlot_minTls(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1114,6 +1292,9 @@ func TestAccAppServiceSlot_minTls(t *testing.T) { } func TestAccAppServiceSlot_applicationBlobStorageLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1133,6 +1314,9 @@ func TestAccAppServiceSlot_applicationBlobStorageLogs(t *testing.T) { } func TestAccAppServiceSlot_emptyApplicationLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1150,6 +1334,9 @@ func TestAccAppServiceSlot_emptyApplicationLogs(t *testing.T) { } func TestAccAppServiceSlot_httpFileSystemLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1167,6 +1354,9 @@ func TestAccAppServiceSlot_httpFileSystemLogs(t *testing.T) { } func TestAccAppServiceSlot_httpBlobStorageLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1184,6 +1374,9 @@ func TestAccAppServiceSlot_httpBlobStorageLogs(t *testing.T) { } func TestAccAppServiceSlot_detailedErrorMessagesLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} data.ResourceTest(t, r, []acceptance.TestStep{ @@ -1205,6 +1398,9 @@ func TestAccAppServiceSlot_detailedErrorMessagesLogs(t *testing.T) { } func TestAccAppServiceSlot_failedRequestTracingLogs(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1227,6 +1423,9 @@ func TestAccAppServiceSlot_failedRequestTracingLogs(t *testing.T) { } func TestAccAppServiceSlot_autoSwap(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_app_service_slot", "test") r := AppServiceSlotResource{} @@ -1248,7 +1447,7 @@ func (r AppServiceSlotResource) Exists(ctx context.Context, clients *clients.Cli return nil, err } - resp, err := clients.Web.AppServicesClient.GetSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) + resp, err := clients.Web.AppServicesClientV1.GetSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go b/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go index 8fb85464f47b..b4cc0b4b072e 100644 --- a/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go +++ b/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go @@ -64,7 +64,7 @@ func resourceAppServiceSlotVirtualNetworkSwiftConnection() *pluginsdk.Resource { } func resourceAppServiceSlotVirtualNetworkSwiftConnectionCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 subnetClient := meta.(*clients.Client).Network.Subnets vnetClient := meta.(*clients.Client).Network.VirtualNetworks ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) @@ -170,7 +170,7 @@ func resourceAppServiceSlotVirtualNetworkSwiftConnectionCreateUpdate(d *pluginsd } func resourceAppServiceSlotVirtualNetworkSwiftConnectionRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -220,7 +220,7 @@ func resourceAppServiceSlotVirtualNetworkSwiftConnectionRead(d *pluginsdk.Resour } func resourceAppServiceSlotVirtualNetworkSwiftConnectionDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_slot_virtual_network_swift_connection_resource_test.go b/internal/services/web/app_service_slot_virtual_network_swift_connection_resource_test.go index 387b76ca3017..dc1a1361bbad 100644 --- a/internal/services/web/app_service_slot_virtual_network_swift_connection_resource_test.go +++ b/internal/services/web/app_service_slot_virtual_network_swift_connection_resource_test.go @@ -161,7 +161,7 @@ func (r AppServiceSlotVirtualNetworkSwiftConnectionResource) Exists(ctx context. return nil, err } - resp, err := clients.Web.AppServicesClient.GetSwiftVirtualNetworkConnectionSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) + resp, err := clients.Web.AppServicesClientV1.GetSwiftVirtualNetworkConnectionSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil @@ -178,7 +178,7 @@ func (t AppServiceSlotVirtualNetworkSwiftConnectionResource) disappears(ctx cont return err } - resp, err := clients.Web.AppServicesClient.DeleteSwiftVirtualNetworkSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) + resp, err := clients.Web.AppServicesClientV1.DeleteSwiftVirtualNetworkSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) if err != nil { if !utils.ResponseWasNotFound(resp) { return fmt.Errorf("deleting %s: %+v", id.String(), err) diff --git a/internal/services/web/app_service_source_control_token_resource.go b/internal/services/web/app_service_source_control_token_resource.go index 7796258e0876..4d3e4b15e62b 100644 --- a/internal/services/web/app_service_source_control_token_resource.go +++ b/internal/services/web/app_service_source_control_token_resource.go @@ -37,7 +37,7 @@ func resourceAppServiceSourceControlToken() *pluginsdk.Resource { return nil }), - DeprecationMessage: "The `azurerm_app_service_source_control_token` resource has been superseded by the `azurerm_source_control_token` resource. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_app_service_source_control_token` resource has been superseded by the `azurerm_source_control_token` resource. This resource will be removed in v5.0 of the AzureRM provider.", Timeouts: &pluginsdk.ResourceTimeout{ Create: pluginsdk.DefaultTimeout(30 * time.Minute), @@ -71,7 +71,7 @@ func resourceAppServiceSourceControlToken() *pluginsdk.Resource { } func resourceAppServiceSourceControlTokenCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.BaseClient + client := meta.(*clients.Client).Web.BaseClientV1 ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -101,7 +101,7 @@ func resourceAppServiceSourceControlTokenCreateUpdate(d *pluginsdk.ResourceData, } func resourceAppServiceSourceControlTokenRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.BaseClient + client := meta.(*clients.Client).Web.BaseClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() scmType := d.Id() @@ -127,7 +127,7 @@ func resourceAppServiceSourceControlTokenRead(d *pluginsdk.ResourceData, meta in } func resourceAppServiceSourceControlTokenDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.BaseClient + client := meta.(*clients.Client).Web.BaseClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_source_control_token_resource_test.go b/internal/services/web/app_service_source_control_token_resource_test.go index 4c3ba51530f6..4086215defe4 100644 --- a/internal/services/web/app_service_source_control_token_resource_test.go +++ b/internal/services/web/app_service_source_control_token_resource_test.go @@ -13,6 +13,7 @@ import ( "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -20,6 +21,10 @@ import ( type AppServiceSourceControlTokenResource struct{} func TestAccAppServiceSourceControlToken(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_app_service_source_control_token", "test") r := AppServiceSourceControlTokenResource{} token := strings.ToLower(acceptance.RandString(41)) @@ -39,7 +44,7 @@ func TestAccAppServiceSourceControlToken(t *testing.T) { } func (r AppServiceSourceControlTokenResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - resp, err := client.Web.BaseClient.GetSourceControl(ctx, state.ID) + resp, err := client.Web.BaseClientV1.GetSourceControl(ctx, state.ID) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/app_service_virtual_network_swift_connection_resource.go b/internal/services/web/app_service_virtual_network_swift_connection_resource.go index f551920bfa18..4d0c0afc32c9 100644 --- a/internal/services/web/app_service_virtual_network_swift_connection_resource.go +++ b/internal/services/web/app_service_virtual_network_swift_connection_resource.go @@ -58,7 +58,7 @@ func resourceAppServiceVirtualNetworkSwiftConnection() *pluginsdk.Resource { } func resourceAppServiceVirtualNetworkSwiftConnectionCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 subnetClient := meta.(*clients.Client).Network.Subnets vnetClient := meta.(*clients.Client).Network.VirtualNetworks ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) @@ -154,7 +154,7 @@ func resourceAppServiceVirtualNetworkSwiftConnectionCreateUpdate(d *pluginsdk.Re } func resourceAppServiceVirtualNetworkSwiftConnectionRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -195,7 +195,7 @@ func resourceAppServiceVirtualNetworkSwiftConnectionRead(d *pluginsdk.ResourceDa } func resourceAppServiceVirtualNetworkSwiftConnectionDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/app_service_virtual_network_swift_connection_resource_test.go b/internal/services/web/app_service_virtual_network_swift_connection_resource_test.go index f565551f37a0..da4b703dcfcf 100644 --- a/internal/services/web/app_service_virtual_network_swift_connection_resource_test.go +++ b/internal/services/web/app_service_virtual_network_swift_connection_resource_test.go @@ -95,7 +95,7 @@ func (r AppServiceVirtualNetworkSwiftConnectionResource) Exists(ctx context.Cont return nil, err } - resp, err := clients.Web.AppServicesClient.GetSwiftVirtualNetworkConnection(ctx, id.ResourceGroup, id.SiteName) + resp, err := clients.Web.AppServicesClientV1.GetSwiftVirtualNetworkConnection(ctx, id.ResourceGroup, id.SiteName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil @@ -112,7 +112,7 @@ func (t AppServiceVirtualNetworkSwiftConnectionResource) disappears(ctx context. return err } - resp, err := clients.Web.AppServicesClient.DeleteSwiftVirtualNetwork(ctx, id.ResourceGroup, id.SiteName) + resp, err := clients.Web.AppServicesClientV1.DeleteSwiftVirtualNetwork(ctx, id.ResourceGroup, id.SiteName) if err != nil { if !utils.ResponseWasNotFound(resp) { return fmt.Errorf("deleting %s: %+v", id.String(), err) diff --git a/internal/services/web/client/client.go b/internal/services/web/client/client.go index c5faf7549823..c23f1ecb31d7 100644 --- a/internal/services/web/client/client.go +++ b/internal/services/web/client/client.go @@ -9,13 +9,13 @@ import ( ) type Client struct { - AppServiceEnvironmentsClient *web.AppServiceEnvironmentsClient - AppServicePlansClient *web.AppServicePlansClient - AppServicesClient *web.AppsClient - BaseClient *web.BaseClient - CertificatesClient *web.CertificatesClient - CertificatesOrderClient *web.AppServiceCertificateOrdersClient - StaticSitesClient *web.StaticSitesClient + AppServiceEnvironmentsClientV1 *web.AppServiceEnvironmentsClient + AppServicePlansClientV1 *web.AppServicePlansClient + AppServicesClientV1 *web.AppsClient + BaseClientV1 *web.BaseClient + CertificatesClientV1 *web.CertificatesClient + CertificatesOrderClientV1 *web.AppServiceCertificateOrdersClient + StaticSitesClientV1 *web.StaticSitesClient } func NewClient(o *common.ClientOptions) *Client { @@ -41,12 +41,12 @@ func NewClient(o *common.ClientOptions) *Client { o.ConfigureClient(&staticSitesClient.Client, o.ResourceManagerAuthorizer) return &Client{ - AppServiceEnvironmentsClient: &appServiceEnvironmentsClient, - AppServicePlansClient: &appServicePlansClient, - AppServicesClient: &appServicesClient, - BaseClient: &baseClient, - CertificatesClient: &certificatesClient, - CertificatesOrderClient: &certificatesOrderClient, - StaticSitesClient: &staticSitesClient, + AppServiceEnvironmentsClientV1: &appServiceEnvironmentsClient, + AppServicePlansClientV1: &appServicePlansClient, + AppServicesClientV1: &appServicesClient, + BaseClientV1: &baseClient, + CertificatesClientV1: &certificatesClient, + CertificatesOrderClientV1: &certificatesOrderClient, + StaticSitesClientV1: &staticSitesClient, } } diff --git a/internal/services/web/function_app.go b/internal/services/web/function_app.go index 1cb1c0157eda..b746c38a2196 100644 --- a/internal/services/web/function_app.go +++ b/internal/services/web/function_app.go @@ -371,7 +371,7 @@ func getFunctionAppServiceTier(ctx context.Context, appServicePlanId string, met log.Printf("[DEBUG] Retrieving App Service Plan %q (Resource Group %q)", id.ServerFarmName, id.ResourceGroup) - appServicePlansClient := meta.(*clients.Client).Web.AppServicePlansClient + appServicePlansClient := meta.(*clients.Client).Web.AppServicePlansClientV1 appServicePlan, err := appServicePlansClient.Get(ctx, id.ResourceGroup, id.ServerFarmName) if err != nil { return "", fmt.Errorf("[ERROR] Could not retrieve App Service Plan ID %q: %+v", appServicePlanId, err) diff --git a/internal/services/web/function_app_data_source.go b/internal/services/web/function_app_data_source.go index f6c0461846ab..535c87c11d03 100644 --- a/internal/services/web/function_app_data_source.go +++ b/internal/services/web/function_app_data_source.go @@ -27,7 +27,7 @@ func dataSourceFunctionApp() *pluginsdk.Resource { return &pluginsdk.Resource{ Read: dataSourceFunctionAppRead, - DeprecationMessage: "The `azurerm_function_app` data source has been superseded by the `azurerm_linux_function_app` and `azurerm_windows_function_app` data sources. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_function_app` data source has been superseded by the `azurerm_linux_function_app` and `azurerm_windows_function_app` data sources. This data source will be removed in v5.0 of the AzureRM Provider.", Timeouts: &pluginsdk.ResourceTimeout{ Read: pluginsdk.DefaultTimeout(5 * time.Minute), @@ -144,7 +144,7 @@ func dataSourceFunctionApp() *pluginsdk.Resource { } func dataSourceFunctionAppRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/function_app_data_source_test.go b/internal/services/web/function_app_data_source_test.go index 8900de501514..60e25f7020ab 100644 --- a/internal/services/web/function_app_data_source_test.go +++ b/internal/services/web/function_app_data_source_test.go @@ -9,11 +9,15 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" ) type FunctionAppDataSource struct{} func TestAccFunctionAppDataSource_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_function_app", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -29,6 +33,9 @@ func TestAccFunctionAppDataSource_basic(t *testing.T) { } func TestAccFunctionAppDataSource_appSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_function_app", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -42,6 +49,9 @@ func TestAccFunctionAppDataSource_appSettings(t *testing.T) { } func TestAccFunctionAppDataSource_connectionStrings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_function_app", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -57,6 +67,9 @@ func TestAccFunctionAppDataSource_connectionStrings(t *testing.T) { } func TestAccFunctionAppDataSource_withSourceControl(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_function_app", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -70,6 +83,9 @@ func TestAccFunctionAppDataSource_withSourceControl(t *testing.T) { } func TestAccFunctionAppDataSource_siteConfig(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -86,6 +102,9 @@ func TestAccFunctionAppDataSource_siteConfig(t *testing.T) { } func TestAccFunctionAppDataSource_clientCertMode(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_function_app", "test") data.DataSourceTest(t, []acceptance.TestStep{ @@ -111,6 +130,9 @@ func TestAccFunctionAppDataSource_clientCertMode(t *testing.T) { } func TestAccFunctionAppDataSource_siteConfigVnetRouteAllEnabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this data source was removed in 5.0") + } data := acceptance.BuildTestData(t, "data.azurerm_function_app", "test") data.DataSourceTest(t, []acceptance.TestStep{ diff --git a/internal/services/web/function_app_host_keys_data_source.go b/internal/services/web/function_app_host_keys_data_source.go index f26e2ba403d6..3e511279bddf 100644 --- a/internal/services/web/function_app_host_keys_data_source.go +++ b/internal/services/web/function_app_host_keys_data_source.go @@ -83,7 +83,7 @@ func dataSourceFunctionAppHostKeys() *pluginsdk.Resource { } func dataSourceFunctionAppHostKeysRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/function_app_resource.go b/internal/services/web/function_app_resource.go index cf0b01d6ab76..70c5bf942e2f 100644 --- a/internal/services/web/function_app_resource.go +++ b/internal/services/web/function_app_resource.go @@ -41,7 +41,7 @@ func resourceFunctionApp() *pluginsdk.Resource { return err }), - DeprecationMessage: "The `azurerm_function_app` resource has been superseded by the `azurerm_linux_function_app` and `azurerm_windows_function_app` resources. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_function_app` resource has been superseded by the `azurerm_linux_function_app` and `azurerm_windows_function_app` resources. This resource will be removed in v5.0 of the AzureRM Provider.", Timeouts: &pluginsdk.ResourceTimeout{ Create: pluginsdk.DefaultTimeout(30 * time.Minute), @@ -244,7 +244,7 @@ func resourceFunctionApp() *pluginsdk.Resource { } func resourceFunctionAppCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -392,7 +392,7 @@ func resourceFunctionAppCreate(d *pluginsdk.ResourceData, meta interface{}) erro } func resourceFunctionAppUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -580,7 +580,7 @@ func resourceFunctionAppUpdate(d *pluginsdk.ResourceData, meta interface{}) erro } func resourceFunctionAppRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -768,7 +768,7 @@ func resourceFunctionAppRead(d *pluginsdk.ResourceData, meta interface{}) error } func resourceFunctionAppDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/function_app_resource_test.go b/internal/services/web/function_app_resource_test.go index 070203650a04..6b1b529eb822 100644 --- a/internal/services/web/function_app_resource_test.go +++ b/internal/services/web/function_app_resource_test.go @@ -14,6 +14,7 @@ import ( "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -22,6 +23,9 @@ import ( type FunctionAppResource struct{} func TestAccFunctionApp_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -42,6 +46,9 @@ func TestAccFunctionApp_basic(t *testing.T) { } func TestAccFunctionApp_requiresImport(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -58,6 +65,9 @@ func TestAccFunctionApp_requiresImport(t *testing.T) { } func TestAccFunctionApp_tags(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -75,6 +85,9 @@ func TestAccFunctionApp_tags(t *testing.T) { } func TestAccFunctionApp_tagsUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -100,6 +113,9 @@ func TestAccFunctionApp_tagsUpdate(t *testing.T) { } func TestAccFunctionApp_appSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -115,6 +131,9 @@ func TestAccFunctionApp_appSettings(t *testing.T) { } func TestAccFunctionApp_appSettingsUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -151,6 +170,9 @@ func TestAccFunctionApp_appSettingsUpdate(t *testing.T) { } func TestAccFunctionApp_siteConfig(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -167,6 +189,9 @@ func TestAccFunctionApp_siteConfig(t *testing.T) { } func TestAccFunctionApp_scmIPRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -182,6 +207,9 @@ func TestAccFunctionApp_scmIPRestriction(t *testing.T) { } func TestAccFunctionApp_scmIPRestrictionSubnet(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -197,6 +225,9 @@ func TestAccFunctionApp_scmIPRestrictionSubnet(t *testing.T) { } func TestAccFunctionApp_healthCheck(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -213,6 +244,9 @@ func TestAccFunctionApp_healthCheck(t *testing.T) { } func TestAccFunctionApp_linuxFxVersion(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -230,6 +264,9 @@ func TestAccFunctionApp_linuxFxVersion(t *testing.T) { } func TestAccFunctionApp_elasticPremiumPlanLinux(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -246,6 +283,9 @@ func TestAccFunctionApp_elasticPremiumPlanLinux(t *testing.T) { } func TestAccFunctionApp_siteConfigVnetRouteAllEnabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -262,6 +302,9 @@ func TestAccFunctionApp_siteConfigVnetRouteAllEnabled(t *testing.T) { } func TestAccFunctionApp_appSettingsVnetRouteAllEnabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -279,6 +322,9 @@ func TestAccFunctionApp_appSettingsVnetRouteAllEnabled(t *testing.T) { } func TestAccFunctionApp_connectionStrings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -295,6 +341,9 @@ func TestAccFunctionApp_connectionStrings(t *testing.T) { } func TestAccFunctionApp_siteConfigMulti(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -354,6 +403,9 @@ func TestAccFunctionApp_siteConfigMulti(t *testing.T) { } func TestAccFunctionApp_updateVersion(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -376,6 +428,9 @@ func TestAccFunctionApp_updateVersion(t *testing.T) { } func TestAccFunctionApp_3264bit(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -398,6 +453,9 @@ func TestAccFunctionApp_3264bit(t *testing.T) { } func TestAccFunctionApp_httpsOnly(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -413,6 +471,9 @@ func TestAccFunctionApp_httpsOnly(t *testing.T) { } func TestAccFunctionApp_dailyMemoryTimeQuota(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -437,6 +498,9 @@ func TestAccFunctionApp_dailyMemoryTimeQuota(t *testing.T) { } func TestAccFunctionApp_consumptionPlan(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -453,6 +517,9 @@ func TestAccFunctionApp_consumptionPlan(t *testing.T) { } func TestAccFunctionApp_keyVaultUserAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -468,6 +535,9 @@ func TestAccFunctionApp_keyVaultUserAssignedIdentity(t *testing.T) { } func TestAccFunctionApp_consumptionPlanUppercaseName(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -485,6 +555,9 @@ func TestAccFunctionApp_consumptionPlanUppercaseName(t *testing.T) { } func TestAccFunctionApp_createIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -503,6 +576,9 @@ func TestAccFunctionApp_createIdentity(t *testing.T) { } func TestAccFunctionApp_updateIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -528,6 +604,9 @@ func TestAccFunctionApp_updateIdentity(t *testing.T) { } func TestAccFunctionApp_userAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -558,6 +637,9 @@ func TestAccFunctionApp_userAssignedIdentity(t *testing.T) { } func TestAccFunctionApp_loggingDisabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -575,6 +657,9 @@ func TestAccFunctionApp_loggingDisabled(t *testing.T) { } func TestAccFunctionApp_updateLogging(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -604,6 +689,9 @@ func TestAccFunctionApp_updateLogging(t *testing.T) { } func TestAccFunctionApp_authSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") tenantID := os.Getenv("ARM_TENANT_ID") r := FunctionAppResource{} @@ -632,6 +720,9 @@ func TestAccFunctionApp_authSettings(t *testing.T) { } func TestAccFunctionApp_corsSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -650,6 +741,9 @@ func TestAccFunctionApp_corsSettings(t *testing.T) { } func TestAccFunctionApp_enableHttp2(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -666,6 +760,9 @@ func TestAccFunctionApp_enableHttp2(t *testing.T) { } func TestAccFunctionApp_minTlsVersion(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -682,6 +779,9 @@ func TestAccFunctionApp_minTlsVersion(t *testing.T) { } func TestAccFunctionApp_ftpsState(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -698,6 +798,9 @@ func TestAccFunctionApp_ftpsState(t *testing.T) { } func TestAccFunctionApp_javaVersion(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -713,6 +816,9 @@ func TestAccFunctionApp_javaVersion(t *testing.T) { } func TestAccFunctionApp_preWarmedInstanceCount(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -729,6 +835,9 @@ func TestAccFunctionApp_preWarmedInstanceCount(t *testing.T) { } func TestAccAzureRMFunctionApp_computedPreWarmedInstanceCount(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -745,6 +854,9 @@ func TestAccAzureRMFunctionApp_computedPreWarmedInstanceCount(t *testing.T) { } func TestAccFunctionApp_oneIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -761,6 +873,9 @@ func TestAccFunctionApp_oneIpRestriction(t *testing.T) { } func TestAccFunctionApp_oneServiceTagIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -777,6 +892,9 @@ func TestAccFunctionApp_oneServiceTagIpRestriction(t *testing.T) { } func TestAccFunctionApp_changeIpToServiceTagIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -806,6 +924,9 @@ func TestAccFunctionApp_changeIpToServiceTagIpRestriction(t *testing.T) { } func TestAccFunctionApp_oneVNetSubnetIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -821,6 +942,9 @@ func TestAccFunctionApp_oneVNetSubnetIpRestriction(t *testing.T) { } func TestAccFunctionApp_ipRestrictionRemoved(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -853,6 +977,9 @@ func TestAccFunctionApp_ipRestrictionRemoved(t *testing.T) { } func TestAccFunctionApp_manyIpRestrictions(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -868,6 +995,9 @@ func TestAccFunctionApp_manyIpRestrictions(t *testing.T) { } func TestAccFunctionApp_scmUseMainIPRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -883,6 +1013,9 @@ func TestAccFunctionApp_scmUseMainIPRestriction(t *testing.T) { } func TestAccFunctionApp_scmOneIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -898,6 +1031,9 @@ func TestAccFunctionApp_scmOneIpRestriction(t *testing.T) { } func TestAccFunctionApp_updateStorageAccountKey(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -927,6 +1063,9 @@ func TestAccFunctionApp_updateStorageAccountKey(t *testing.T) { } func TestAccFunctionApp_withSourceControl(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -942,6 +1081,9 @@ func TestAccFunctionApp_withSourceControl(t *testing.T) { } func TestAccFunctionApp_sourceControlUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -964,6 +1106,9 @@ func TestAccFunctionApp_sourceControlUpdate(t *testing.T) { } func TestAccFunctionApp_scm(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -979,6 +1124,9 @@ func TestAccFunctionApp_scm(t *testing.T) { } func TestAccFunctionApp_clientCertMode(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -1016,6 +1164,9 @@ func TestAccFunctionApp_clientCertMode(t *testing.T) { } func TestAccFunctionApp_elasticInstanceMinimum(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -1032,6 +1183,9 @@ func TestAccFunctionApp_elasticInstanceMinimum(t *testing.T) { } func TestAccFunctionApp_appScaleLimit(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -1048,6 +1202,9 @@ func TestAccFunctionApp_appScaleLimit(t *testing.T) { } func TestAccFunctionApp_runtimeScaleMonitoringEnabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -1064,6 +1221,9 @@ func TestAccFunctionApp_runtimeScaleMonitoringEnabled(t *testing.T) { } func TestAccFunctionApp_dotnetVersion4(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -1080,6 +1240,9 @@ func TestAccFunctionApp_dotnetVersion4(t *testing.T) { } func TestAccFunctionApp_dotnetVersion5(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -1096,6 +1259,9 @@ func TestAccFunctionApp_dotnetVersion5(t *testing.T) { } func TestAccFunctionApp_dotnetVersion6(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app", "test") r := FunctionAppResource{} @@ -1117,7 +1283,7 @@ func (r FunctionAppResource) Exists(ctx context.Context, clients *clients.Client return nil, err } - resp, err := clients.Web.AppServicesClient.Get(ctx, id.ResourceGroup, id.SiteName) + resp, err := clients.Web.AppServicesClientV1.Get(ctx, id.ResourceGroup, id.SiteName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil @@ -1140,7 +1306,7 @@ func (r FunctionAppResource) hasContentShareAppSetting(shouldExist bool) func(ct return err } - appSettingsResp, err := clients.Web.AppServicesClient.ListApplicationSettings(ctx, id.ResourceGroup, id.SiteName) + appSettingsResp, err := clients.Web.AppServicesClientV1.ListApplicationSettings(ctx, id.ResourceGroup, id.SiteName) if err != nil { return fmt.Errorf("listing AppSettings: %+v", err) } diff --git a/internal/services/web/function_app_slot_resource.go b/internal/services/web/function_app_slot_resource.go index 12065926a455..4814ad2e5f4e 100644 --- a/internal/services/web/function_app_slot_resource.go +++ b/internal/services/web/function_app_slot_resource.go @@ -40,7 +40,7 @@ func resourceFunctionAppSlot() *pluginsdk.Resource { return err }), - DeprecationMessage: "The `azurerm_function_app_slot` resource has been superseded by the `azurerm_linux_function_app_slot` and `azurerm_windows_function_app_slot` resources. Whilst this resource will continue to be available in the 2.x and 3.x releases it is feature-frozen for compatibility purposes, will no longer receive any updates and will be removed in a future major release of the Azure Provider.", + DeprecationMessage: "The `azurerm_function_app_slot` resource has been superseded by the `azurerm_linux_function_app_slot` and `azurerm_windows_function_app_slot` resources. This resource will be removed in v5.0 of the AzureRM Provider.", Timeouts: &pluginsdk.ResourceTimeout{ Create: pluginsdk.DefaultTimeout(30 * time.Minute), @@ -221,7 +221,7 @@ func resourceFunctionAppSlot() *pluginsdk.Resource { } func resourceFunctionAppSlotCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -325,7 +325,7 @@ func resourceFunctionAppSlotCreate(d *pluginsdk.ResourceData, meta interface{}) } func resourceFunctionAppSlotUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -458,7 +458,7 @@ func resourceFunctionAppSlotUpdate(d *pluginsdk.ResourceData, meta interface{}) } func resourceFunctionAppSlotRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -608,7 +608,7 @@ func resourceFunctionAppSlotRead(d *pluginsdk.ResourceData, meta interface{}) er } func resourceFunctionAppSlotDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClient + client := meta.(*clients.Client).Web.AppServicesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() @@ -696,7 +696,7 @@ func getFunctionAppSlotServiceTier(ctx context.Context, appServicePlanID string, log.Printf("[DEBUG] Retrieving App Service Plan %q (Resource Group %q)", id.ServerFarmName, id.ResourceGroup) - appServicePlansClient := meta.(*clients.Client).Web.AppServicePlansClient + appServicePlansClient := meta.(*clients.Client).Web.AppServicePlansClientV1 appServicePlan, err := appServicePlansClient.Get(ctx, id.ResourceGroup, id.ServerFarmName) if err != nil { return "", fmt.Errorf("[ERROR] Could not retrieve App Service Plan ID %q: %+v", appServicePlanID, err) diff --git a/internal/services/web/function_app_slot_resource_test.go b/internal/services/web/function_app_slot_resource_test.go index 44e4d37698ed..f0625413bda9 100644 --- a/internal/services/web/function_app_slot_resource_test.go +++ b/internal/services/web/function_app_slot_resource_test.go @@ -13,6 +13,7 @@ import ( "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -21,6 +22,9 @@ import ( type FunctionAppSlotResource struct{} func TestAccFunctionAppSlot_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -36,6 +40,9 @@ func TestAccFunctionAppSlot_basic(t *testing.T) { } func TestAccFunctionAppSlot_requiresImport(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -51,6 +58,9 @@ func TestAccFunctionAppSlot_requiresImport(t *testing.T) { } func TestAccFunctionAppSlot_32Bit(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -67,6 +77,9 @@ func TestAccFunctionAppSlot_32Bit(t *testing.T) { } func TestAccFunctionAppSlot_alwaysOn(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -83,6 +96,9 @@ func TestAccFunctionAppSlot_alwaysOn(t *testing.T) { } func TestAccFunctionAppSlot_appSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -99,6 +115,9 @@ func TestAccFunctionAppSlot_appSettings(t *testing.T) { } func TestAccFunctionAppSlot_connectionStrings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -120,6 +139,9 @@ func TestAccFunctionAppSlot_connectionStrings(t *testing.T) { } func TestAccFunctionAppSlot_corsSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -135,6 +157,9 @@ func TestAccFunctionAppSlot_corsSettings(t *testing.T) { } func TestAccFunctionAppSlot_autoSwap(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -151,6 +176,9 @@ func TestAccFunctionAppSlot_autoSwap(t *testing.T) { } func TestAccFunctionAppSlot_authSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") tenantID := os.Getenv("ARM_TENANT_ID") r := FunctionAppSlotResource{} @@ -179,6 +207,9 @@ func TestAccFunctionAppSlot_authSettings(t *testing.T) { } func TestAccFunctionAppSlot_enabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -194,6 +225,9 @@ func TestAccFunctionAppSlot_enabled(t *testing.T) { } func TestAccFunctionAppSlot_enabledUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -216,6 +250,9 @@ func TestAccFunctionAppSlot_enabledUpdate(t *testing.T) { } func TestAccFunctionAppSlot_httpsOnly(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -231,6 +268,9 @@ func TestAccFunctionAppSlot_httpsOnly(t *testing.T) { } func TestAccFunctionAppSlot_httpsOnlyUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -253,6 +293,9 @@ func TestAccFunctionAppSlot_httpsOnlyUpdate(t *testing.T) { } func TestAccFunctionAppSlot_http2Enabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -268,6 +311,9 @@ func TestAccFunctionAppSlot_http2Enabled(t *testing.T) { } func TestAccFunctionAppSlot_oneIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -283,6 +329,9 @@ func TestAccFunctionAppSlot_oneIpRestriction(t *testing.T) { } func TestAccFunctionAppSlot_oneVNetSubnetIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -298,6 +347,9 @@ func TestAccFunctionAppSlot_oneVNetSubnetIpRestriction(t *testing.T) { } func TestAccFunctionAppSlot_zeroedIpRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -330,6 +382,9 @@ func TestAccFunctionAppSlot_zeroedIpRestriction(t *testing.T) { } func TestAccFunctionAppSlot_manyIpRestrictions(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -345,6 +400,9 @@ func TestAccFunctionAppSlot_manyIpRestrictions(t *testing.T) { } func TestAccFunctionAppSlot_scmUseMainIPRestriction(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -360,6 +418,9 @@ func TestAccFunctionAppSlot_scmUseMainIPRestriction(t *testing.T) { } func TestAccFunctionAppSlot_scmIPRestrictionComplete(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -375,6 +436,9 @@ func TestAccFunctionAppSlot_scmIPRestrictionComplete(t *testing.T) { } func TestAccFunctionAppSlot_scmIPRestrictionServiceTag(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -390,6 +454,9 @@ func TestAccFunctionAppSlot_scmIPRestrictionServiceTag(t *testing.T) { } func TestAccFunctionAppSlot_scmIPRestrictionSubnet(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -405,6 +472,9 @@ func TestAccFunctionAppSlot_scmIPRestrictionSubnet(t *testing.T) { } func TestAccFunctionAppSlot_tagsUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -430,6 +500,9 @@ func TestAccFunctionAppSlot_tagsUpdate(t *testing.T) { } func TestAccFunctionAppSlot_updateManageServiceIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -453,6 +526,9 @@ func TestAccFunctionAppSlot_updateManageServiceIdentity(t *testing.T) { } func TestAccFunctionAppSlot_updateVersion(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -475,6 +551,9 @@ func TestAccFunctionAppSlot_updateVersion(t *testing.T) { } func TestAccFunctionAppSlot_userAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -493,6 +572,9 @@ func TestAccFunctionAppSlot_userAssignedIdentity(t *testing.T) { } func TestAccFunctionAppSlot_webSockets(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -508,6 +590,9 @@ func TestAccFunctionAppSlot_webSockets(t *testing.T) { } func TestAccFunctionAppSlot_enableManageServiceIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -525,6 +610,9 @@ func TestAccFunctionAppSlot_enableManageServiceIdentity(t *testing.T) { } func TestAccFunctionAppSlot_minTls(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -548,6 +636,9 @@ func TestAccFunctionAppSlot_minTls(t *testing.T) { } func TestAccFunctionAppSlot_preWarmedInstanceCount(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -564,6 +655,9 @@ func TestAccFunctionAppSlot_preWarmedInstanceCount(t *testing.T) { } func TestAccFunctionAppSlot_elasticInstanceMinimum(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -580,6 +674,9 @@ func TestAccFunctionAppSlot_elasticInstanceMinimum(t *testing.T) { } func TestAccFunctionAppSlot_appScaleLimit(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -596,6 +693,9 @@ func TestAccFunctionAppSlot_appScaleLimit(t *testing.T) { } func TestAccFunctionAppSlot_runtimeScaleMonitoringEnabled(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -612,6 +712,9 @@ func TestAccFunctionAppSlot_runtimeScaleMonitoringEnabled(t *testing.T) { } func TestAccFunctionAppSlot_dotnetVersion4(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -628,6 +731,9 @@ func TestAccFunctionAppSlot_dotnetVersion4(t *testing.T) { } func TestAccFunctionAppSlot_dotnetVersion5(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -644,6 +750,9 @@ func TestAccFunctionAppSlot_dotnetVersion5(t *testing.T) { } func TestAccFunctionAppSlot_dotnetVersion6(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } data := acceptance.BuildTestData(t, "azurerm_function_app_slot", "test") r := FunctionAppSlotResource{} @@ -665,7 +774,7 @@ func (r FunctionAppSlotResource) Exists(ctx context.Context, clients *clients.Cl return nil, err } - resp, err := clients.Web.AppServicesClient.GetSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) + resp, err := clients.Web.AppServicesClientV1.GetSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/registration.go b/internal/services/web/registration.go index 86efb045c85d..62c1fa3dafa7 100644 --- a/internal/services/web/registration.go +++ b/internal/services/web/registration.go @@ -6,6 +6,7 @@ package web import ( "github.com/hashicorp/terraform-plugin-framework/action" "github.com/hashicorp/terraform-plugin-framework/ephemeral" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -33,38 +34,45 @@ func (r Registration) WebsiteCategories() []string { // SupportedDataSources returns the supported Data Sources supported by this Service func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource { datasources := map[string]*pluginsdk.Resource{ - "azurerm_app_service": dataSourceAppService(), "azurerm_app_service_certificate_order": dataSourceAppServiceCertificateOrder(), "azurerm_app_service_certificate": dataSourceAppServiceCertificate(), - "azurerm_app_service_plan": dataSourceAppServicePlan(), - "azurerm_function_app": dataSourceFunctionApp(), "azurerm_function_app_host_keys": dataSourceFunctionAppHostKeys(), } + + if !features.FivePointOh() { + datasources["azurerm_app_service"] = dataSourceAppService() + datasources["azurerm_app_service_plan"] = dataSourceAppServicePlan() + datasources["azurerm_function_app"] = dataSourceFunctionApp() + } + return datasources } // SupportedResources returns the supported Resources supported by this Service func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { resources := map[string]*pluginsdk.Resource{ - "azurerm_app_service_active_slot": resourceAppServiceActiveSlot(), "azurerm_app_service_certificate": resourceAppServiceCertificate(), "azurerm_app_service_certificate_order": resourceAppServiceCertificateOrder(), "azurerm_app_service_custom_hostname_binding": resourceAppServiceCustomHostnameBinding(), "azurerm_app_service_certificate_binding": resourceAppServiceCertificateBinding(), - "azurerm_app_service_hybrid_connection": resourceAppServiceHybridConnection(), "azurerm_app_service_managed_certificate": resourceAppServiceManagedCertificate(), - "azurerm_app_service_plan": resourceAppServicePlan(), "azurerm_app_service_public_certificate": resourceAppServicePublicCertificate(), - "azurerm_app_service_slot": resourceAppServiceSlot(), "azurerm_app_service_slot_custom_hostname_binding": resourceAppServiceSlotCustomHostnameBinding(), "azurerm_app_service_slot_virtual_network_swift_connection": resourceAppServiceSlotVirtualNetworkSwiftConnection(), - "azurerm_app_service_source_control_token": resourceAppServiceSourceControlToken(), "azurerm_app_service_virtual_network_swift_connection": resourceAppServiceVirtualNetworkSwiftConnection(), - "azurerm_app_service": resourceAppService(), - "azurerm_function_app": resourceFunctionApp(), - "azurerm_function_app_slot": resourceFunctionAppSlot(), - "azurerm_static_site": resourceStaticSite(), - "azurerm_static_site_custom_domain": resourceStaticSiteCustomDomain(), + } + + if !features.FivePointOh() { + resources["azurerm_app_service_active_slot"] = resourceAppServiceActiveSlot() + resources["azurerm_app_service_hybrid_connection"] = resourceAppServiceHybridConnection() + resources["azurerm_app_service_plan"] = resourceAppServicePlan() + resources["azurerm_app_service_slot"] = resourceAppServiceSlot() + resources["azurerm_app_service_source_control_token"] = resourceAppServiceSourceControlToken() + resources["azurerm_app_service"] = resourceAppService() + resources["azurerm_function_app"] = resourceFunctionApp() + resources["azurerm_function_app_slot"] = resourceFunctionAppSlot() + resources["azurerm_static_site"] = resourceStaticSite() + resources["azurerm_static_site_custom_domain"] = resourceStaticSiteCustomDomain() } return resources diff --git a/internal/services/web/static_site_custom_domain_resource.go b/internal/services/web/static_site_custom_domain_resource.go index 380d979ad985..fd57f1d6e3b3 100644 --- a/internal/services/web/static_site_custom_domain_resource.go +++ b/internal/services/web/static_site_custom_domain_resource.go @@ -27,7 +27,7 @@ const ( func resourceStaticSiteCustomDomain() *pluginsdk.Resource { return &pluginsdk.Resource{ - DeprecationMessage: "This resource has been deprecated in favour of `azurerm_static_web_app_custom_domain` and will be removed in a future release.", + DeprecationMessage: "This resource has been deprecated in favour of `azurerm_static_web_app_custom_domain` and will be removed v5.0 of the AzureRM provider.", Create: resourceStaticSiteCustomDomainCreate, Read: resourceStaticSiteCustomDomainRead, Delete: resourceStaticSiteCustomDomainDelete, @@ -77,7 +77,7 @@ func resourceStaticSiteCustomDomain() *pluginsdk.Resource { } func resourceStaticSiteCustomDomainCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.StaticSitesClient + client := meta.(*clients.Client).Web.StaticSitesClientV1 ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -176,7 +176,7 @@ func resourceStaticSiteCustomDomainCreate(d *pluginsdk.ResourceData, meta interf } func resourceStaticSiteCustomDomainRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.StaticSitesClient + client := meta.(*clients.Client).Web.StaticSitesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -201,7 +201,7 @@ func resourceStaticSiteCustomDomainRead(d *pluginsdk.ResourceData, meta interfac } func resourceStaticSiteCustomDomainDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.StaticSitesClient + client := meta.(*clients.Client).Web.StaticSitesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/static_site_resource.go b/internal/services/web/static_site_resource.go index a0f127b0f53e..ecd1a1dd2ca4 100644 --- a/internal/services/web/static_site_resource.go +++ b/internal/services/web/static_site_resource.go @@ -27,7 +27,7 @@ import ( func resourceStaticSite() *pluginsdk.Resource { return &pluginsdk.Resource{ - DeprecationMessage: "This resource has been deprecated in favour of `azurerm_static_web_app` and will be removed in a future release.", + DeprecationMessage: "This resource has been deprecated in favour of `azurerm_static_web_app` and will be removed in v5.0 of the AzureRM provider.", Create: resourceStaticSiteCreateOrUpdate, Read: resourceStaticSiteRead, Update: resourceStaticSiteCreateOrUpdate, @@ -103,7 +103,7 @@ func resourceStaticSite() *pluginsdk.Resource { } func resourceStaticSiteCreateOrUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.StaticSitesClient + client := meta.(*clients.Client).Web.StaticSitesClientV1 subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -174,7 +174,7 @@ func resourceStaticSiteCreateOrUpdate(d *pluginsdk.ResourceData, meta interface{ } func resourceStaticSiteRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.StaticSitesClient + client := meta.(*clients.Client).Web.StaticSitesClientV1 ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -249,7 +249,7 @@ func resourceStaticSiteRead(d *pluginsdk.ResourceData, meta interface{}) error { } func resourceStaticSiteDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.StaticSitesClient + client := meta.(*clients.Client).Web.StaticSitesClientV1 ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/static_site_resource_custom_domain_test.go b/internal/services/web/static_site_resource_custom_domain_test.go index fd887463e1a4..bc459dd82087 100644 --- a/internal/services/web/static_site_resource_custom_domain_test.go +++ b/internal/services/web/static_site_resource_custom_domain_test.go @@ -12,6 +12,7 @@ import ( "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -20,6 +21,10 @@ import ( type StaticSiteCustomDomainResource struct{} func TestAccAzureStaticSiteCustomDomain_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_static_site_custom_domain", "test") r := StaticSiteCustomDomainResource{} @@ -36,6 +41,10 @@ func TestAccAzureStaticSiteCustomDomain_basic(t *testing.T) { } func TestAccAzureStaticSiteCustomDomain_requiresImport(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_static_site_custom_domain", "test") r := StaticSiteCustomDomainResource{} @@ -56,7 +65,7 @@ func (r StaticSiteCustomDomainResource) Exists(ctx context.Context, clients *cli return nil, err } - resp, err := clients.Web.StaticSitesClient.GetStaticSiteCustomDomain(ctx, id.ResourceGroup, id.StaticSiteName, id.CustomDomainName) + resp, err := clients.Web.StaticSitesClientV1.GetStaticSiteCustomDomain(ctx, id.ResourceGroup, id.StaticSiteName, id.CustomDomainName) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/internal/services/web/static_site_resource_test.go b/internal/services/web/static_site_resource_test.go index 38944d34bdc0..8ff42c073afa 100644 --- a/internal/services/web/static_site_resource_test.go +++ b/internal/services/web/static_site_resource_test.go @@ -12,6 +12,7 @@ import ( "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" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -20,6 +21,10 @@ import ( type StaticSiteResource struct{} func TestAccAzureStaticSite_basic(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_static_site", "test") r := StaticSiteResource{} @@ -38,6 +43,10 @@ func TestAccAzureStaticSite_basic(t *testing.T) { } func TestAccAzureStaticSite_withSystemAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_static_site", "test") r := StaticSiteResource{} @@ -56,6 +65,10 @@ func TestAccAzureStaticSite_withSystemAssignedIdentity(t *testing.T) { } func TestAccAzureStaticSite_identity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_static_site", "test") r := StaticSiteResource{} @@ -93,6 +106,10 @@ func TestAccAzureStaticSite_identity(t *testing.T) { } func TestAccAzureStaticSite_withSystemAssignedUserAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_static_site", "test") r := StaticSiteResource{} @@ -111,6 +128,10 @@ func TestAccAzureStaticSite_withSystemAssignedUserAssignedIdentity(t *testing.T) } func TestAccAzureStaticSite_withUserAssignedIdentity(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_static_site", "test") r := StaticSiteResource{} @@ -128,6 +149,10 @@ func TestAccAzureStaticSite_withUserAssignedIdentity(t *testing.T) { } func TestAccAzureStaticSite_basicUpdate(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_static_site", "test") r := StaticSiteResource{} @@ -156,6 +181,10 @@ func TestAccAzureStaticSite_basicUpdate(t *testing.T) { } func TestAccAzureStaticSite_requiresImport(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_static_site", "test") r := StaticSiteResource{} @@ -171,6 +200,10 @@ func TestAccAzureStaticSite_requiresImport(t *testing.T) { } func TestAccAzureStaticSite_appSettings(t *testing.T) { + if features.FivePointOh() { + t.Skip("Skipping as this resource was removed in 5.0") + } + data := acceptance.BuildTestData(t, "azurerm_static_site", "test") r := StaticSiteResource{} @@ -207,7 +240,7 @@ func (r StaticSiteResource) Exists(ctx context.Context, clients *clients.Client, return nil, err } - resp, err := clients.Web.StaticSitesClient.GetStaticSite(ctx, id.ResourceGroup, id.Name) + resp, err := clients.Web.StaticSitesClientV1.GetStaticSite(ctx, id.ResourceGroup, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { return pointer.To(false), nil diff --git a/website/docs/5.0-upgrade-guide.html.markdown b/website/docs/5.0-upgrade-guide.html.markdown index ce3b26612b5c..74d23de78657 100644 --- a/website/docs/5.0-upgrade-guide.html.markdown +++ b/website/docs/5.0-upgrade-guide.html.markdown @@ -121,6 +121,30 @@ Please follow the format in the example below for adding removed resources: This deprecated resource has been superseded/retired and has been removed from the Azure Provider. ``` +### `azurerm_app_service` + +* This deprecated resource has been superseded by `azurerm_linux_web_app` and `azurerm_windows_web_app` and has been removed from the AzureRM Provider. + +### `azurerm_app_service_active_slot` + +* This deprecated resource has been superseded by `azurerm_web_app_active_slot` and `azurerm_function_app_active_slot` and has been removed from the AzureRM Provider. + +### `azurerm_app_service_hybrid_connection` + +* This deprecated resource has been superseded by `azurerm_web_app_hybrid_connection` and `azurerm_function_app_hybrid_connection` and has been removed from the AzureRM Provider. + +### `azurerm_app_service_plan` + +* This deprecated resource has been superseded by `azurerm_service_plan` and has been removed from the AzureRM Provider. + +### `azurerm_app_service_slot` + +* This deprecated resource has been superseded by `azurerm_linux_web_app_slot` and `azurerm_windows_web_app_slot` and has been removed from the AzureRM Provider. + +### `azurerm_app_service_source_control_token` + +* This deprecated resource has been removed from the AzureRM Provider. + ### `azurerm_automation_software_update_configuration` * This deprecated resource has been retired and has been removed from the Azure Provider. @@ -137,6 +161,14 @@ This deprecated resource has been superseded/retired and has been removed from t * This deprecated resource has been retired and has been removed from the Azure Provider. +### `azurerm_function_app` + +* This deprecated resource has been superseded by `azurerm_linux_function_app` and `azurerm_windows_function_app` and has been removed from the AzureRM Provider. + +### `azurerm_function_app_slot` + +* This deprecated resource has been superseded by `azurerm_linux_function_app_slot` and `azurerm_windows_function_app_slot` and has been removed from the AzureRM Provider. + ### `azurerm_hpc_cache` * This deprecated resource has been retired and has been removed from the Azure Provider. @@ -157,10 +189,6 @@ This deprecated resource has been superseded/retired and has been removed from t * This deprecated resource has been retired and has been removed from the Azure Provider. -### `azurerm_logic_app_standard` - -* The `client_certificate_mode` property now defaults to `Required` aligning with the service default for this value. - ### `azurerm_maps_creator` * This deprecated resource has been removed from the Azure Provider. Please see the [documentation for more details](https://aka.ms/AzureMapsCreatorDeprecation). @@ -209,10 +237,6 @@ This deprecated resource has been superseded/retired and has been removed from t * This deprecated resource has been retired and has been removed from the Azure Provider. -### `azurerm_redis_enterprise_cluster` - -* The property `minimum_tls_version` property no longer accepts `1.0` or `1.1` as a value. Please see the [documentation for more details](https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-remove-tls-10-11). - ### `azurerm_security_center_auto_provisioning` * This deprecated resource has been removed from the Azure Provider. Please see the [documentation for more details](https://learn.microsoft.com/en-us/azure/defender-for-cloud/prepare-deprecation-log-analytics-mma-agent#log-analytics-agent-autoprovisioning-experience---deprecation-plan). @@ -221,6 +245,14 @@ This deprecated resource has been superseded/retired and has been removed from t * This deprecated resource has been retired and has been removed from the Azure Provider. +### `azurerm_static_site` + +* This deprecated resource has been superseded by `azurerm_static_web_app` and has been removed from the AzureRM Provider. + +### `azurerm_static_site_custom_domain` + +* This deprecated resource has been superseded by `azurerm_static_web_app_custom_domain` and has been removed from the AzureRM Provider. + ## Removed Data Sources @@ -232,6 +264,18 @@ Please follow the format in the example below for adding removed data sources: This deprecated data source has been superseded/retired and has been removed from the Azure Provider. ``` +### `azurerm_app_service` + +* This deprecated data source has been superseded by `azurerm_linux_web_app` and `azurerm_windows_web_app` and has been removed from the Azure Provider + +### `azurerm_app_service_plan` + +* This deprecated data source has been superseded by `azurerm_service_plan` and has been removed from the Azure Provider. + +### `azurerm_function_app` + +* This deprecated data source has been superseded by `azurerm_linux_function_app` and `azurerm_windows_function_app` and has been removed from the Azure Provider. + ### `azurerm_batch_certificate` * This deprecated data source has been retired and has been removed from the Azure Provider. diff --git a/website/docs/d/app_service.html.markdown b/website/docs/d/app_service.html.markdown index 77ceb94e32ce..e9b2976ff8ba 100644 --- a/website/docs/d/app_service.html.markdown +++ b/website/docs/d/app_service.html.markdown @@ -10,7 +10,7 @@ description: |- Use this data source to access information about an existing App Service. -!> **Note:** The `azurerm_app_service` data source is deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use the [`azurerm_linux_web_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/linux_web_app) and [`azurerm_windows_web_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/windows_web_app) data sources instead. +!> **Note:** This data source has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use the [`azurerm_linux_web_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/linux_web_app) and [`azurerm_windows_web_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/windows_web_app) data sources instead. ## Example Usage diff --git a/website/docs/d/app_service_plan.html.markdown b/website/docs/d/app_service_plan.html.markdown index a6418991ee96..158558853d34 100644 --- a/website/docs/d/app_service_plan.html.markdown +++ b/website/docs/d/app_service_plan.html.markdown @@ -10,7 +10,7 @@ description: |- Use this data source to access information about an existing App Service Plan (formerly known as a `Server Farm`). -!> **Note:** The `azurerm_app_service_plan` data source is deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use the [`azurerm_service_plan`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/service_plan) data source instead. +!> **Note:** This data source has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use the [`azurerm_service_plan`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/service_plan) data source instead. ## Example Usage diff --git a/website/docs/d/function_app.html.markdown b/website/docs/d/function_app.html.markdown index fbd76f78e40f..980c49ec1773 100644 --- a/website/docs/d/function_app.html.markdown +++ b/website/docs/d/function_app.html.markdown @@ -11,7 +11,7 @@ description: |- Use this data source to access information about a Function App. -!> **Note:** The `azurerm_function_app` data source is deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use the [`azurerm_linux_function_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/linux_function_app) and [`azurerm_windows_function_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/windows_function_app) data sources instead. +!> **Note:** This data source has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use the [`azurerm_linux_function_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/linux_function_app) and [`azurerm_windows_function_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/windows_function_app) data sources instead. ## Example Usage diff --git a/website/docs/r/app_service.html.markdown b/website/docs/r/app_service.html.markdown index 50d939053a1a..d36d174be2f0 100644 --- a/website/docs/r/app_service.html.markdown +++ b/website/docs/r/app_service.html.markdown @@ -11,7 +11,7 @@ description: |- Manages an App Service (within an App Service Plan). -!> **Note:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_linux_web_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_web_app) and [`azurerm_windows_web_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_web_app) resources instead. +!> **Note:** This resource has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use [`azurerm_linux_web_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_web_app) and [`azurerm_windows_web_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_web_app) resources instead. -> **Note:** When using Slots - the `app_settings`, `connection_string` and `site_config` blocks on the `azurerm_app_service` resource will be overwritten when promoting a Slot using the `azurerm_app_service_active_slot` resource. diff --git a/website/docs/r/app_service_active_slot.html.markdown b/website/docs/r/app_service_active_slot.html.markdown index 79cb24a216da..432cfe1a74fd 100644 --- a/website/docs/r/app_service_active_slot.html.markdown +++ b/website/docs/r/app_service_active_slot.html.markdown @@ -11,7 +11,7 @@ description: |- Promotes an App Service Slot to Production within an App Service. -!> **Note:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_web_app_active_slot`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/web_app_active_slot) resource instead. +!> **Note:** This resource has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use [`azurerm_web_app_active_slot`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/web_app_active_slot) resource instead. -> **Note:** When using Slots - the `app_settings`, `connection_string` and `site_config` blocks on the `azurerm_app_service` resource will be overwritten when promoting a Slot using the `azurerm_app_service_active_slot` resource. diff --git a/website/docs/r/app_service_hybrid_connection.html.markdown b/website/docs/r/app_service_hybrid_connection.html.markdown index 38e98d1b85a0..47b0d9b2a408 100644 --- a/website/docs/r/app_service_hybrid_connection.html.markdown +++ b/website/docs/r/app_service_hybrid_connection.html.markdown @@ -11,7 +11,7 @@ description: |- Manages an App Service Hybrid Connection for an existing App Service, Relay and Service Bus. -!> **Note:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_function_app_hybrid_connection`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app_hybrid_connection) and [`azurerm_web_app_hybrid_connection`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/web_app_hybrid_connection) resources instead. +!> **Note:** This resource has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use [`azurerm_function_app_hybrid_connection`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app_hybrid_connection) and [`azurerm_web_app_hybrid_connection`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/web_app_hybrid_connection) resources instead. ## Example Usage diff --git a/website/docs/r/app_service_plan.html.markdown b/website/docs/r/app_service_plan.html.markdown index d80d3704b791..f45f56a387c8 100644 --- a/website/docs/r/app_service_plan.html.markdown +++ b/website/docs/r/app_service_plan.html.markdown @@ -10,7 +10,7 @@ description: |- Manages an App Service Plan component. -!> **Note:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_service_plan`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan) resource instead. +!> **Note:** This resource has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use [`azurerm_service_plan`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan) resource instead. ## Example Usage (Dedicated) diff --git a/website/docs/r/app_service_slot.html.markdown b/website/docs/r/app_service_slot.html.markdown index 0e864bdade7b..8a8424c9d951 100644 --- a/website/docs/r/app_service_slot.html.markdown +++ b/website/docs/r/app_service_slot.html.markdown @@ -11,7 +11,7 @@ description: |- Manages an App Service Slot (within an App Service). -!> **Note:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_linux_web_app_slot`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_web_app_slot) and [`azurerm_windows_web_app_slot`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_web_app_slot) resources instead. +!> **Note:** This resource has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use [`azurerm_linux_web_app_slot`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_web_app_slot) and [`azurerm_windows_web_app_slot`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_web_app_slot) resources instead. -> **Note:** When using Slots - the `app_settings`, `connection_string` and `site_config` blocks on the `azurerm_app_service` resource will be overwritten when promoting a Slot using the `azurerm_app_service_active_slot` resource. diff --git a/website/docs/r/app_service_source_control_token.html.markdown b/website/docs/r/app_service_source_control_token.html.markdown index c26ae05424a3..101d17af18dc 100644 --- a/website/docs/r/app_service_source_control_token.html.markdown +++ b/website/docs/r/app_service_source_control_token.html.markdown @@ -11,7 +11,7 @@ description: |- Manages an App Service source control token. -!> **Note:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_service_plan`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan) resource instead. +!> **Note:** This resource has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use [`azurerm_service_plan`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/service_plan) resource instead. ~> **Note:** Source Control Tokens are configured at the subscription level, not on each App Service - as such this can only be configured Subscription-wide diff --git a/website/docs/r/function_app.html.markdown b/website/docs/r/function_app.html.markdown index 539333189fe3..cf290956feb8 100644 --- a/website/docs/r/function_app.html.markdown +++ b/website/docs/r/function_app.html.markdown @@ -11,7 +11,7 @@ description: |- Manages a Function App. -!> **Note:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_linux_function_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app) and [`azurerm_windows_function_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_function_app) resources instead. +!> **Note:** This resource has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use [`azurerm_linux_function_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app) and [`azurerm_windows_function_app`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_function_app) resources instead. ~> **Note:** To connect an Azure Function App and a subnet within the same region `azurerm_app_service_virtual_network_swift_connection` can be used. For an example, check the `azurerm_app_service_virtual_network_swift_connection` documentation. diff --git a/website/docs/r/function_app_slot.html.markdown b/website/docs/r/function_app_slot.html.markdown index 4d5e29e88daa..77e155a0cac6 100644 --- a/website/docs/r/function_app_slot.html.markdown +++ b/website/docs/r/function_app_slot.html.markdown @@ -11,7 +11,7 @@ description: |- Manages a Function App deployment Slot. -!> **Note:** This resource has been deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use [`azurerm_linux_function_app_slot`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app_slot) and [`azurerm_windows_function_app_slot`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_function_app_slot) resources instead. +!> **Note:** This resource has been deprecated and will be removed in version 5.0 of the AzureRM provider. Please use [`azurerm_linux_function_app_slot`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app_slot) and [`azurerm_windows_function_app_slot`](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_function_app_slot) resources instead. ## Example Usage (with App Service Plan) diff --git a/website/docs/r/static_site.html.markdown b/website/docs/r/static_site.html.markdown index 0c1ed1f7ae05..e698d3e552e3 100644 --- a/website/docs/r/static_site.html.markdown +++ b/website/docs/r/static_site.html.markdown @@ -10,7 +10,7 @@ description: |- Manages an App Service Static Site. --> **Note:** The `azurerm_static_site` resource is deprecated in favour of `azurerm_static_web_app` and will be removed in a future major release. +!> **Note:** This resource has been superseded by `azurerm_static_web_app` and will be removed in version 5.0 of the AzureRM provider. -> **Note:** After the Static Site is provisioned, you'll need to associate your target repository, which contains your web app, to the Static Site, by following the [Azure Static Site document](https://docs.microsoft.com/azure/static-web-apps/github-actions-workflow). diff --git a/website/docs/r/static_site_custom_domain.html.markdown b/website/docs/r/static_site_custom_domain.html.markdown index 9dfcc9faae1d..658afeef2376 100644 --- a/website/docs/r/static_site_custom_domain.html.markdown +++ b/website/docs/r/static_site_custom_domain.html.markdown @@ -10,9 +10,9 @@ description: |- Manages a Static Site Custom Domain. -!> **Note:** DNS validation polling is only done for CNAME records, terraform will not validate TXT validation records are complete. +!> **Note:** This resource has been superseded by `azurerm_static_web_app_custom_domain` and will be removed in version 5.0 of the AzureRM provider. --> **Note:** The `azurerm_static_site_custom_domain` resource is deprecated in favour of `azurerm_static_web_app_custom_domain` and will be removed in a future major release. +!> **Note:** DNS validation polling is only done for CNAME records, terraform will not validate TXT validation records are complete. ## Example Usage From cd12b69ebaee5bf35e0c7ff53b228565430344f9 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 10:56:12 -0600 Subject: [PATCH 02/18] web - client updates --- internal/clients/client.go | 5 ++- internal/services/web/client/client.go | 43 +++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/internal/clients/client.go b/internal/clients/client.go index a7a342a4ed18..92492d7b2449 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -675,7 +675,10 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.VoiceServices, err = voiceServices.NewClient(o); err != nil { return fmt.Errorf("building clients for Voice Services: %+v", err) } - client.Web = web.NewClient(o) + + if client.Web, err = web.NewClient(o); err != nil { + return fmt.Errorf("building clients for Web: %+v", err) + } if client.Workloads, err = workloads.NewClient(o); err != nil { return fmt.Errorf("building clients for Workloads: %+v", err) diff --git a/internal/services/web/client/client.go b/internal/services/web/client/client.go index c23f1ecb31d7..98432994b043 100644 --- a/internal/services/web/client/client.go +++ b/internal/services/web/client/client.go @@ -4,11 +4,21 @@ package client import ( + "fmt" + "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck + "github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { + AppServiceCertificateOrdersClient *appservicecertificateorders.AppServiceCertificateOrdersClient + CertificatesClient *certificates.CertificatesClient + WebAppsClient *webapps.WebAppsClient + + // azure-sdk-for-go AppServiceEnvironmentsClientV1 *web.AppServiceEnvironmentsClient AppServicePlansClientV1 *web.AppServicePlansClient AppServicesClientV1 *web.AppsClient @@ -18,7 +28,26 @@ type Client struct { StaticSitesClientV1 *web.StaticSitesClient } -func NewClient(o *common.ClientOptions) *Client { +func NewClient(o *common.ClientOptions) (*Client, error) { + appServiceCertificateOrdersClient, err := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building App Service Certificate Orders client: %w", err) + } + o.Configure(appServiceCertificateOrdersClient.Client, o.Authorizers.ResourceManager) + + certificatesClient, err := certificates.NewCertificatesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Certificates client: %w", err) + } + o.Configure(certificatesClient.Client, o.Authorizers.ResourceManager) + + webAppsClient, err := webapps.NewWebAppsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building Web Apps client: %w", err) + } + o.Configure(webAppsClient.Client, o.Authorizers.ResourceManager) + + // Track 1 appServiceEnvironmentsClient := web.NewAppServiceEnvironmentsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&appServiceEnvironmentsClient.Client, o.ResourceManagerAuthorizer) @@ -31,8 +60,8 @@ func NewClient(o *common.ClientOptions) *Client { baseClient := web.NewWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&baseClient.Client, o.ResourceManagerAuthorizer) - certificatesClient := web.NewCertificatesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) - o.ConfigureClient(&certificatesClient.Client, o.ResourceManagerAuthorizer) + certificatesClientV1 := web.NewCertificatesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&certificatesClientV1.Client, o.ResourceManagerAuthorizer) certificatesOrderClient := web.NewAppServiceCertificateOrdersClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&certificatesOrderClient.Client, o.ResourceManagerAuthorizer) @@ -41,12 +70,16 @@ func NewClient(o *common.ClientOptions) *Client { o.ConfigureClient(&staticSitesClient.Client, o.ResourceManagerAuthorizer) return &Client{ + AppServiceCertificateOrdersClient: appServiceCertificateOrdersClient, + CertificatesClient: certificatesClient, + WebAppsClient: webAppsClient, + AppServiceEnvironmentsClientV1: &appServiceEnvironmentsClient, AppServicePlansClientV1: &appServicePlansClient, AppServicesClientV1: &appServicesClient, BaseClientV1: &baseClient, - CertificatesClientV1: &certificatesClient, + CertificatesClientV1: &certificatesClientV1, CertificatesOrderClientV1: &certificatesOrderClient, StaticSitesClientV1: &staticSitesClient, - } + }, nil } From 6076c85819d5e8c22432172d26b4e1c063cec0d7 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:05:24 -0600 Subject: [PATCH 03/18] `azurerm_app_service_certificate_binding` - migrate to `go-azure-sdk` --- ...pp_service_certificate_binding_resource.go | 147 +++++++++--------- ...rvice_certificate_binding_resource_test.go | 64 ++++---- .../app_service_certificate_data_source.go | 54 +++---- ...pp_service_certificate_data_source_test.go | 3 +- .../services/web/parse/certificate_binding.go | 61 -------- .../web/parse/certificate_binding_test.go | 114 -------------- 6 files changed, 127 insertions(+), 316 deletions(-) delete mode 100644 internal/services/web/parse/certificate_binding.go delete mode 100644 internal/services/web/parse/certificate_binding_test.go diff --git a/internal/services/web/app_service_certificate_binding_resource.go b/internal/services/web/app_service_certificate_binding_resource.go index 883a5793f159..b64e29ffec61 100644 --- a/internal/services/web/app_service_certificate_binding_resource.go +++ b/internal/services/web/app_service_certificate_binding_resource.go @@ -5,22 +5,22 @@ package web import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) -var appServiceHostnameBindingResourceName = "azurerm_app_service_custom_hostname_binding" +const appServiceHostnameBindingResourceName = "azurerm_app_service_custom_hostname_binding" func resourceAppServiceCertificateBinding() *pluginsdk.Resource { return &pluginsdk.Resource{ @@ -29,7 +29,7 @@ func resourceAppServiceCertificateBinding() *pluginsdk.Resource { Delete: resourceAppServiceCertificateBindingDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.CertificateBindingID(id) + _, err := commonids.ParseCompositeResourceID(id, &webapps.HostNameBindingId{}, &certificates.CertificateId{}) return err }), @@ -44,14 +44,14 @@ func resourceAppServiceCertificateBinding() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.HostnameBindingID, + ValidateFunc: webapps.ValidateHostNameBindingID, }, "certificate_id": { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.CertificateID, + ValidateFunc: certificates.ValidateCertificateID, }, "ssl_state": { @@ -59,8 +59,8 @@ func resourceAppServiceCertificateBinding() *pluginsdk.Resource { Required: true, ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ - string(web.SslStateIPBasedEnabled), - string(web.SslStateSniEnabled), + string(webapps.SslStateIPBasedEnabled), + string(webapps.SslStateSniEnabled), }, false), }, @@ -83,61 +83,64 @@ func resourceAppServiceCertificateBinding() *pluginsdk.Resource { } func resourceAppServiceCertificateBindingCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 - certClient := meta.(*clients.Client).Web.CertificatesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient + certClient := meta.(*clients.Client).Web.CertificatesClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - log.Printf("[INFO] preparing arguments for App Service Hostname Binding creation.") - - hostnameBindingID, err := parse.HostnameBindingID(d.Get("hostname_binding_id").(string)) + hostnameBindingID, err := webapps.ParseHostNameBindingID(d.Get("hostname_binding_id").(string)) if err != nil { return err } - certificateID, err := parse.CertificateID(d.Get("certificate_id").(string)) + certificateID, err := certificates.ParseCertificateID(d.Get("certificate_id").(string)) if err != nil { - return fmt.Errorf("could not parse ID: %+v", err) + return err } - id := parse.NewCertificateBindingId(*hostnameBindingID, *certificateID) + id := commonids.NewCompositeResourceID(hostnameBindingID, certificateID) - certDetails, err := certClient.Get(ctx, id.CertificateId.ResourceGroup, id.CertificateId.Name) + certificate, err := certClient.Get(ctx, *id.Second) if err != nil { - if utils.ResponseWasNotFound(certDetails.Response) { - return fmt.Errorf("retrieving App Service Certificate %q (Resource Group %q), not found", id.CertificateId.Name, id.CertificateId.ResourceGroup) - } - return fmt.Errorf("failed reading App Service Certificate %q (Resource Group %q): %+v", id.CertificateId.Name, id.CertificateId.ResourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", id.Second, err) + } + + if certificate.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", id.Second) + } + + if certificate.Model.Properties == nil { + return fmt.Errorf("retrieving %s: `properties` was nil", id.Second) } - if certDetails.Thumbprint == nil { - return fmt.Errorf("could not read thumbprint from certificate %q (resource group %q): %+v", id.CertificateId.Name, id.CertificateId.ResourceGroup, err) + if certificate.Model.Properties.Thumbprint == nil { + return fmt.Errorf("retrieving %s: `thumbprint` was nil", id.Second) } - thumbprint := certDetails.Thumbprint + thumbprint := certificate.Model.Properties.Thumbprint - binding, err := client.GetHostNameBinding(ctx, id.HostnameBindingId.ResourceGroup, id.SiteName, id.HostnameBindingId.Name) + binding, err := client.GetHostNameBinding(ctx, *id.First) if err != nil { - if utils.ResponseWasNotFound(binding.Response) { - return fmt.Errorf("retrieving Custom Hostname Binding %q (App Service %q / Resource Group %q): %+v", id.HostnameBindingId.Name, id.SiteName, id.HostnameBindingId.ResourceGroup, err) - } - return fmt.Errorf("retrieving Custom Hostname Certificate Binding %q with certificate name %q (App Service %q / Resource Group %q): %+v", id.HostnameBindingId.Name, id.SiteName, id.CertificateId.Name, id.HostnameBindingId.ResourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", id.First, err) } - props := binding.HostNameBindingProperties - if props != nil { - if props.Thumbprint != nil && *props.Thumbprint == *thumbprint { - return tf.ImportAsExistsError("azurerm_app_service_certificate_binding", id.ID()) - } + if binding.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", id.First) + } + + props := binding.Model.Properties + if props != nil && props.Thumbprint != nil && *props.Thumbprint == *thumbprint { + return tf.ImportAsExistsError("azurerm_app_service_certificate_binding", id.ID()) } - locks.ByName(id.SiteName, appServiceHostnameBindingResourceName) - defer locks.UnlockByName(id.SiteName, appServiceHostnameBindingResourceName) + locks.ByName(id.First.SiteName, appServiceHostnameBindingResourceName) + defer locks.UnlockByName(id.First.SiteName, appServiceHostnameBindingResourceName) - binding.SslState = web.SslState(d.Get("ssl_state").(string)) - binding.Thumbprint = thumbprint + props.SslState = pointer.ToEnum[webapps.SslState](d.Get("ssl_state").(string)) + props.Thumbprint = thumbprint - if _, err := client.CreateOrUpdateHostNameBinding(ctx, id.HostnameBindingId.ResourceGroup, id.SiteName, id.HostnameBindingId.Name, binding); err != nil { - return fmt.Errorf("creating/updating Custom Hostname Certificate Binding %q with certificate name %q (App Service %q / Resource Group %q): %+v", id.HostnameBindingId.Name, id.CertificateId.Name, id.SiteName, id.HostnameBindingId.ResourceGroup, err) + if _, err := client.CreateOrUpdateHostNameBinding(ctx, *id.First, *binding.Model); err != nil { + return fmt.Errorf("updating certificate for %s: %+v", id.First, err) } d.SetId(id.ID()) @@ -146,79 +149,75 @@ func resourceAppServiceCertificateBindingCreate(d *pluginsdk.ResourceData, meta } func resourceAppServiceCertificateBindingRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CertificateBindingID(d.Id()) + id, err := commonids.ParseCompositeResourceID(d.Id(), &webapps.HostNameBindingId{}, &certificates.CertificateId{}) if err != nil { return err } - resp, err := client.GetHostNameBinding(ctx, id.HostnameBindingId.ResourceGroup, id.SiteName, id.HostnameBindingId.Name) + resp, err := client.GetHostNameBinding(ctx, *id.First) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[DEBUG] App Service Hostname Certificate Binding %q (App Service %q / Resource Group %q) was not found - removing from state", id.HostnameBindingId.Name, id.SiteName, id.HostnameBindingId.ResourceGroup) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("retrieving Custom Hostname Certificate Binding %q (App Service %q / Resource Group %q): %+v", id.HostnameBindingId.Name, id.SiteName, id.HostnameBindingId.ResourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", id.First, err) } - props := resp.HostNameBindingProperties - if props == nil || props.Thumbprint == nil { - log.Printf("[DEBUG] App Service Hostname Certificate Binding %q (App Service %q / Resource Group %q) was not found - removing from state", id.HostnameBindingId.Name, id.SiteName, id.HostnameBindingId.ResourceGroup) + if resp.Model == nil || resp.Model.Properties == nil || resp.Model.Properties.Thumbprint == nil { d.SetId("") return nil } + props := resp.Model.Properties - d.Set("hostname_binding_id", id.HostnameBindingId.ID()) - d.Set("certificate_id", id.CertificateId.ID()) - d.Set("ssl_state", string(props.SslState)) + d.Set("hostname_binding_id", id.First.ID()) + d.Set("certificate_id", id.Second.ID()) + d.Set("ssl_state", pointer.FromEnum(props.SslState)) d.Set("thumbprint", props.Thumbprint) - d.Set("hostname", id.HostnameBindingId.Name) - d.Set("app_service_name", id.SiteName) + d.Set("hostname", id.First.HostNameBindingName) + d.Set("app_service_name", id.First.SiteName) return nil } func resourceAppServiceCertificateBindingDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CertificateBindingID(d.Id()) + id, err := commonids.ParseCompositeResourceID(d.Id(), &webapps.HostNameBindingId{}, &certificates.CertificateId{}) if err != nil { return err } - binding, err := client.GetHostNameBinding(ctx, id.HostnameBindingId.ResourceGroup, id.SiteName, id.HostnameBindingId.Name) + binding, err := client.GetHostNameBinding(ctx, *id.First) if err != nil { - if utils.ResponseWasNotFound(binding.Response) { - log.Printf("[DEBUG] App Service Hostname Certificate Binding %q (App Service %q / Resource Group %q) was not found - removing from state", id.HostnameBindingId.Name, id.SiteName, id.HostnameBindingId.ResourceGroup) + if response.WasNotFound(binding.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("retrieving Custom Hostname Certificate Binding %q (App Service %q / Resource Group %q): %+v", id.HostnameBindingId.Name, id.SiteName, id.HostnameBindingId.ResourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", id.First, err) } - props := binding.HostNameBindingProperties - if props == nil || props.Thumbprint == nil { - log.Printf("[DEBUG] App Service Hostname Certificate Binding %q (App Service %q / Resource Group %q) was not found - removing from state", id.HostnameBindingId.Name, id.SiteName, id.HostnameBindingId.ResourceGroup) + if binding.Model == nil || binding.Model.Properties == nil || binding.Model.Properties.Thumbprint == nil { d.SetId("") return nil } + props := binding.Model.Properties - locks.ByName(id.SiteName, appServiceHostnameBindingResourceName) - defer locks.UnlockByName(id.SiteName, appServiceHostnameBindingResourceName) - - log.Printf("[DEBUG] Deleting App Service Hostname Binding %q (App Service %q / Resource Group %q)", id.HostnameBindingId.Name, id.SiteName, id.HostnameBindingId.ResourceGroup) + locks.ByName(id.First.SiteName, appServiceHostnameBindingResourceName) + defer locks.UnlockByName(id.First.SiteName, appServiceHostnameBindingResourceName) - binding.SslState = web.SslStateDisabled - binding.Thumbprint = nil + props.SslState = pointer.To(webapps.SslStateDisabled) + props.Thumbprint = nil - if _, err := client.CreateOrUpdateHostNameBinding(ctx, id.HostnameBindingId.ResourceGroup, id.SiteName, id.HostnameBindingId.Name, binding); err != nil { - return fmt.Errorf("deleting Custom Hostname Certificate Binding %q (App Service %q / Resource Group %q): %+v", id.HostnameBindingId.Name, id.SiteName, id.HostnameBindingId.ResourceGroup, err) + if _, err := client.CreateOrUpdateHostNameBinding(ctx, *id.First, *binding.Model); err != nil { + return fmt.Errorf("deleting certificate from %s: %+v", id.First, err) } return nil diff --git a/internal/services/web/app_service_certificate_binding_resource_test.go b/internal/services/web/app_service_certificate_binding_resource_test.go index 41cec65f2a90..9d6d6c193853 100644 --- a/internal/services/web/app_service_certificate_binding_resource_test.go +++ b/internal/services/web/app_service_certificate_binding_resource_test.go @@ -10,12 +10,13 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" "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" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type AppServiceCertificateBindingResource struct{} @@ -80,41 +81,36 @@ func TestAccAppServiceCertificateBinding_requiresImport(t *testing.T) { } func (t AppServiceCertificateBindingResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.CertificateBindingID(state.ID) + id, err := commonids.ParseCompositeResourceID(state.ID, &webapps.HostNameBindingId{}, &certificates.CertificateId{}) if err != nil { return nil, err } - binding, err := clients.Web.AppServicesClientV1.GetHostNameBinding(ctx, id.HostnameBindingId.ResourceGroup, id.SiteName, id.HostnameBindingId.Name) + binding, err := clients.Web.WebAppsClient.GetHostNameBinding(ctx, *id.First) if err != nil { - if utils.ResponseWasNotFound(binding.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("retrieving App Service Hostname Binding %q (resource group %q) to check for Certificate Binding %q: %+v", id.HostnameBindingId.Name, id.HostnameBindingId.ResourceGroup, id.HostnameBindingId.Name, err) + return nil, fmt.Errorf("retrieving %s: %+v", id.First, err) } - certificate, err := clients.Web.CertificatesClientV1.Get(ctx, id.CertificateId.ResourceGroup, id.CertificateId.Name) + + certificate, err := clients.Web.CertificatesClient.Get(ctx, *id.Second) if err != nil { - if utils.ResponseWasNotFound(certificate.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("retrieving App Service Certificate %q (resource group %q) to check for Certificate Binding: %+v", id.CertificateId.Name, id.CertificateId.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", *id.First, err) } - bindingProps := binding.HostNameBindingProperties - if bindingProps == nil || bindingProps.Thumbprint == nil { - return pointer.To(false), nil + + if binding.Model == nil || binding.Model.Properties == nil || binding.Model.Properties.Thumbprint == nil { + return nil, fmt.Errorf("retrieving %s: unable to retrieve thumbprint", id.First) } - certProps := certificate.CertificateProperties - if certProps == nil || certProps.Thumbprint == nil { - return nil, fmt.Errorf("reading Certificate thumbprint for verification on binding") + + if certificate.Model == nil || certificate.Model.Properties == nil || certificate.Model.Properties.Thumbprint == nil { + return nil, fmt.Errorf("retrieving %s: unable to retrieve thumbprint", id.Second) } - if *certProps.Thumbprint != *bindingProps.Thumbprint { + + if *certificate.Model.Properties.Thumbprint != *binding.Model.Properties.Thumbprint { return pointer.To(false), nil } return pointer.To(true), nil } func (t AppServiceCertificateBindingResource) basic(data acceptance.TestData) string { - template := t.testAccCertificateBinding_template(data) return fmt.Sprintf(` provider "azurerm" { features {} @@ -127,11 +123,10 @@ resource "azurerm_app_service_certificate_binding" "test" { } %s -`, template) +`, t.testAccCertificateBinding_template(data)) } func (t AppServiceCertificateBindingResource) basicSniEnabled(data acceptance.TestData) string { - template := t.testAccCertificateBinding_template(data) return fmt.Sprintf(` provider "azurerm" { features {} @@ -144,11 +139,10 @@ resource "azurerm_app_service_certificate_binding" "test" { } %s -`, template) +`, t.testAccCertificateBinding_template(data)) } func (t AppServiceCertificateBindingResource) requiresImport(data acceptance.TestData) string { - template := t.basic(data) return fmt.Sprintf(` %s @@ -157,7 +151,7 @@ resource "azurerm_app_service_certificate_binding" "import" { certificate_id = azurerm_app_service_certificate_binding.test.certificate_id ssl_state = azurerm_app_service_certificate_binding.test.ssl_state } -`, template) +`, t.basic(data)) } func (AppServiceCertificateBindingResource) testAccCertificateBinding_template(data acceptance.TestData) string { @@ -166,12 +160,12 @@ func (AppServiceCertificateBindingResource) testAccCertificateBinding_template(d return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-asmc-%d" - location = "%s" + name = "acctestRG-asmc-%[1]d" + location = "%[2]s" } resource "azurerm_app_service_plan" "test" { - name = "acctestASP-%d" + name = "acctestASP-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name kind = "Linux" @@ -185,19 +179,19 @@ resource "azurerm_app_service_plan" "test" { } resource "azurerm_app_service" "test" { - name = "acctest%s" + name = "acctest%[3]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name app_service_plan_id = azurerm_app_service_plan.test.id } data "azurerm_dns_zone" "test" { - name = "%s" - resource_group_name = "%s" + name = "%[4]s" + resource_group_name = "%[5]s" } resource "azurerm_dns_cname_record" "test" { - name = "%s" + name = "%[3]s" zone_name = data.azurerm_dns_zone.test.name resource_group_name = data.azurerm_dns_zone.test.resource_group_name ttl = 300 @@ -205,7 +199,7 @@ resource "azurerm_dns_cname_record" "test" { } resource "azurerm_dns_txt_record" "test" { - name = join(".", ["asuid", "%s"]) + name = join(".", ["asuid", "%[3]s"]) zone_name = data.azurerm_dns_zone.test.name resource_group_name = data.azurerm_dns_zone.test.resource_group_name ttl = 300 @@ -224,5 +218,5 @@ resource "azurerm_app_service_custom_hostname_binding" "test" { resource "azurerm_app_service_managed_certificate" "test" { custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.test.id } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString, dnsZone, dataResourceGroup, data.RandomString, data.RandomString) +`, data.RandomInteger, data.Locations.Primary, data.RandomString, dnsZone, dataResourceGroup) } diff --git a/internal/services/web/app_service_certificate_data_source.go b/internal/services/web/app_service_certificate_data_source.go index b87d474bdc8c..bbffc78bf233 100644 --- a/internal/services/web/app_service_certificate_data_source.go +++ b/internal/services/web/app_service_certificate_data_source.go @@ -7,15 +7,14 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceAppServiceCertificate() *pluginsdk.Resource { @@ -81,17 +80,17 @@ func dataSourceAppServiceCertificate() *pluginsdk.Resource { } func dataSourceAppServiceCertificateRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClientV1 - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Web.CertificatesClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewCertificateID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + id := certificates.NewCertificateID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("%s does not exist", id) + if response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("%s was not found", id) } return fmt.Errorf("retrieving %s: %+v", id, err) @@ -99,28 +98,23 @@ func dataSourceAppServiceCertificateRead(d *pluginsdk.ResourceData, meta interfa d.SetId(id.ID()) - d.Set("name", resp.Name) - d.Set("resource_group_name", id.ResourceGroup) - - d.Set("location", location.NormalizeNilable(resp.Location)) - - if props := resp.CertificateProperties; props != nil { - d.Set("friendly_name", props.FriendlyName) - d.Set("subject_name", props.SubjectName) - d.Set("host_names", props.HostNames) - d.Set("issuer", props.Issuer) - issueDate := "" - if props.IssueDate != nil { - issueDate = props.IssueDate.Format(time.RFC3339) - } - d.Set("issue_date", issueDate) - expirationDate := "" - if props.ExpirationDate != nil { - expirationDate = props.ExpirationDate.Format(time.RFC3339) + d.Set("name", id.CertificateName) + d.Set("resource_group_name", id.ResourceGroupName) + + if model := resp.Model; model != nil { + d.Set("location", location.Normalize(model.Location)) + d.Set("tags", model.Tags) + + if props := model.Properties; props != nil { + d.Set("friendly_name", props.FriendlyName) + d.Set("subject_name", props.SubjectName) + d.Set("host_names", props.HostNames) + d.Set("issuer", props.Issuer) + d.Set("issue_date", props.IssueDate) + d.Set("expiration_date", props.ExpirationDate) + d.Set("thumbprint", props.Thumbprint) } - d.Set("expiration_date", expirationDate) - d.Set("thumbprint", props.Thumbprint) } - return tags.FlattenAndSet(d, resp.Tags) + return nil } diff --git a/internal/services/web/app_service_certificate_data_source_test.go b/internal/services/web/app_service_certificate_data_source_test.go index 32bf9adbde9d..6cfb229dde03 100644 --- a/internal/services/web/app_service_certificate_data_source_test.go +++ b/internal/services/web/app_service_certificate_data_source_test.go @@ -31,7 +31,6 @@ func TestAccDataSourceAppServiceCertificate_basic(t *testing.T) { } func (d AppServiceCertificateDataSource) basic(data acceptance.TestData) string { - template := AppServiceCertificateResource{}.pfxNoPassword(data) return fmt.Sprintf(` %s @@ -39,5 +38,5 @@ data "azurerm_app_service_certificate" "test" { name = azurerm_app_service_certificate.test.name resource_group_name = azurerm_app_service_certificate.test.resource_group_name } -`, template) +`, AppServiceCertificateResource{}.pfxNoPassword(data)) } diff --git a/internal/services/web/parse/certificate_binding.go b/internal/services/web/parse/certificate_binding.go deleted file mode 100644 index de694999ad02..000000000000 --- a/internal/services/web/parse/certificate_binding.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -// This is a special case ID for a meta resource that links a web certificate to a Web App or Function App - -var _ resourceids.Id = CertificateBindingId{} - -type CertificateBindingId struct { - HostnameBindingId - CertificateId -} - -func NewCertificateBindingId(hostnameBindingId HostnameBindingId, certificateId CertificateId) *CertificateBindingId { - return &CertificateBindingId{ - HostnameBindingId: hostnameBindingId, - CertificateId: certificateId, - } -} - -func (id CertificateBindingId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostNameBindings/%s|/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/certificates/%s" - return fmt.Sprintf(fmtString, id.HostnameBindingId.SubscriptionId, id.HostnameBindingId.ResourceGroup, id.SiteName, id.HostnameBindingId.Name, id.CertificateId.SubscriptionId, id.CertificateId.ResourceGroup, id.CertificateId.Name) -} - -func (id CertificateBindingId) String() string { - components := []string{ - fmt.Sprintf("Hostname Binding ID %q", id.HostnameBindingId.String()), - fmt.Sprintf("Certificate ID %q", id.CertificateId.String()), - } - return fmt.Sprintf("Certificate Binding %s", strings.Join(components, " / ")) -} - -func CertificateBindingID(input string) (*CertificateBindingId, error) { - idParts := strings.Split(input, "|") - if len(idParts) != 2 { - return nil, fmt.Errorf("could not parse Certificate Binding ID, expected two resource IDs joined by `|`") - } - - hostnameBindingId, err := HostnameBindingID(idParts[0]) - if err != nil { - return nil, fmt.Errorf("could not parse Hostname Binding portion of Certificate Binding ID: %+v", err) - } - certificateId, err := CertificateID(idParts[1]) - if err != nil { - return nil, fmt.Errorf("could not parse Certificate ID portion of Certificate Binding ID: %+v", err) - } - - return &CertificateBindingId{ - *hostnameBindingId, - *certificateId, - }, nil -} diff --git a/internal/services/web/parse/certificate_binding_test.go b/internal/services/web/parse/certificate_binding_test.go deleted file mode 100644 index d53985b00d54..000000000000 --- a/internal/services/web/parse/certificate_binding_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -import ( - "reflect" - "testing" -) - -func TestCertificateBindingIDFormatter(t *testing.T) { - hostnameBindingId := HostnameBindingId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "mygroup1", - SiteName: "site1", - Name: "binding1", - } - certificateId := CertificateId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "certificate1", - } - actual := NewCertificateBindingId(hostnameBindingId, certificateId) - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1|/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/certificate1" - if actual.ID() != expected { - t.Fatalf("Expected %q, got %q", expected, actual) - } -} - -func TestCertificateBindingID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *CertificateBindingId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // Missing CertificateId Portion - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1|", - Error: true, - }, - - { - // Missing HostnameBindingId Portion - Input: "|/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/certificate1", - Error: true, - }, - - { - // Incorrect ordering - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/certificate1|/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1", - Error: true, - }, - - { - // missing certificate name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1|/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/", - Error: true, - }, - - { - // invalid HostnameBindingId - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1|/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/certificate1", - Error: true, - }, - - { - // missing certificate name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1|/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/certificate1", - Expected: &CertificateBindingId{ - HostnameBindingId: HostnameBindingId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "mygroup1", - SiteName: "site1", - Name: "binding1", - }, - CertificateId: CertificateId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "certificate1", - }, - }, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := CertificateBindingID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expected a value, but got an error: %s", err) - } - if v.Error { - t.Fatalf("Expected an error, but did not get one") - } - - if !reflect.DeepEqual(actual.HostnameBindingId, v.Expected.HostnameBindingId) { - t.Fatalf("expected %+v, got %+v", v.Expected.HostnameBindingId, actual.HostnameBindingId) - } - - if !reflect.DeepEqual(actual.CertificateId, v.Expected.CertificateId) { - t.Fatalf("expected %+v, got %+v", v.Expected.CertificateId, actual.CertificateId) - } - } -} From 9209d54bf86f74a8816a6e528fa34a28ab4ced64 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:07:56 -0600 Subject: [PATCH 04/18] `azurerm_app_service_certificate_order` - migrate to `go-azure-sdk` --- ...p_service_certificate_order_data_source.go | 91 +++--- ...vice_certificate_order_data_source_test.go | 9 +- .../app_service_certificate_order_resource.go | 272 ++++++++++-------- ...service_certificate_order_resource_test.go | 40 ++- .../app_service_certificate_order.go | 3 +- .../services/web/parse/certificate_order.go | 73 ----- .../web/parse/certificate_order_test.go | 114 -------- .../web/validate/certificate_order_id.go | 26 -- .../web/validate/certificate_order_id_test.go | 78 ----- 9 files changed, 225 insertions(+), 481 deletions(-) delete mode 100644 internal/services/web/parse/certificate_order.go delete mode 100644 internal/services/web/parse/certificate_order_test.go delete mode 100644 internal/services/web/validate/certificate_order_id.go delete mode 100644 internal/services/web/validate/certificate_order_id_test.go diff --git a/internal/services/web/app_service_certificate_order_data_source.go b/internal/services/web/app_service_certificate_order_data_source.go index 3048fe1bb430..942764ce587a 100644 --- a/internal/services/web/app_service_certificate_order_data_source.go +++ b/internal/services/web/app_service_certificate_order_data_source.go @@ -7,15 +7,14 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceAppServiceCertificateOrder() *pluginsdk.Resource { @@ -143,63 +142,57 @@ func dataSourceAppServiceCertificateOrder() *pluginsdk.Resource { } func dataSourceAppServiceCertificateOrderRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesOrderClientV1 - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Web.AppServiceCertificateOrdersClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewCertificateOrderID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + id := appservicecertificateorders.NewCertificateOrderID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { + if response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("%s was not found", id) } - - return fmt.Errorf("making Read request on %s: %+v", id.Name, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } d.SetId(id.ID()) - d.Set("name", id.Name) - d.Set("resource_group_name", id.ResourceGroup) - - d.Set("location", location.NormalizeNilable(resp.Location)) - - if props := resp.AppServiceCertificateOrderProperties; props != nil { - d.Set("auto_renew", props.AutoRenew) - d.Set("csr", props.Csr) - d.Set("distinguished_name", props.DistinguishedName) - d.Set("key_size", props.KeySize) - d.Set("validity_in_years", props.ValidityInYears) - d.Set("domain_verification_token", props.DomainVerificationToken) - d.Set("status", string(props.Status)) - d.Set("is_private_key_external", props.IsPrivateKeyExternal) - d.Set("certificates", flattenArmCertificateOrderCertificate(props.Certificates)) - d.Set("app_service_certificate_not_renewable_reasons", utils.FlattenStringSlice(props.AppServiceCertificateNotRenewableReasons)) - - if productType := props.ProductType; productType == web.CertificateProductTypeStandardDomainValidatedSsl { - d.Set("product_type", "Standard") - } else if productType == web.CertificateProductTypeStandardDomainValidatedWildCardSsl { - d.Set("product_type", "WildCard") - } - - if expirationTime := props.ExpirationTime; expirationTime != nil { - d.Set("expiration_time", expirationTime.Format(time.RFC3339)) - } - - if signedCertificate := props.SignedCertificate; signedCertificate != nil { - d.Set("signed_certificate_thumbprint", signedCertificate.Thumbprint) - } - - if root := props.Root; root != nil { - d.Set("root_thumbprint", root.Thumbprint) - } - - if intermediate := props.Intermediate; intermediate != nil { - d.Set("intermediate_thumbprint", intermediate.Thumbprint) + d.Set("name", id.CertificateOrderName) + d.Set("resource_group_name", id.ResourceGroupName) + + if model := resp.Model; model != nil { + d.Set("location", location.Normalize(model.Location)) + d.Set("tags", model.Tags) + + if props := model.Properties; props != nil { + d.Set("auto_renew", props.AutoRenew) + d.Set("csr", props.Csr) + d.Set("distinguished_name", props.DistinguishedName) + d.Set("key_size", props.KeySize) + d.Set("validity_in_years", props.ValidityInYears) + d.Set("domain_verification_token", props.DomainVerificationToken) + d.Set("status", pointer.FromEnum(props.Status)) + d.Set("is_private_key_external", props.IsPrivateKeyExternal) + d.Set("certificates", flattenArmCertificateOrderCertificate(props.Certificates)) + d.Set("app_service_certificate_not_renewable_reasons", flattenAppServiceCertificateNotRenewableReasons(props.AppServiceCertificateNotRenewableReasons)) + d.Set("expiration_time", props.ExpirationTime) + d.Set("product_type", flattenProductType(props.ProductType)) + + if signedCertificate := props.SignedCertificate; signedCertificate != nil { + d.Set("signed_certificate_thumbprint", signedCertificate.Thumbprint) + } + + if root := props.Root; root != nil { + d.Set("root_thumbprint", root.Thumbprint) + } + + if intermediate := props.Intermediate; intermediate != nil { + d.Set("intermediate_thumbprint", intermediate.Thumbprint) + } } } - return tags.FlattenAndSet(d, resp.Tags) + return nil } diff --git a/internal/services/web/app_service_certificate_order_data_source_test.go b/internal/services/web/app_service_certificate_order_data_source_test.go index c24c64a684de..0d000aa92c7d 100644 --- a/internal/services/web/app_service_certificate_order_data_source_test.go +++ b/internal/services/web/app_service_certificate_order_data_source_test.go @@ -81,7 +81,6 @@ func TestAccDataSourceAppServiceCertificateOrder_complete(t *testing.T) { } func (d AppServiceCertificateOrderDataSource) basic(data acceptance.TestData) string { - config := AppServiceCertificateOrderResource{}.basic(data) return fmt.Sprintf(` %s @@ -89,11 +88,10 @@ data "azurerm_app_service_certificate_order" "test" { name = azurerm_app_service_certificate_order.test.name resource_group_name = azurerm_app_service_certificate_order.test.resource_group_name } -`, config) +`, AppServiceCertificateOrderResource{}.basic(data)) } func (d AppServiceCertificateOrderDataSource) wildcard(data acceptance.TestData) string { - config := AppServiceCertificateOrderResource{}.wildcard(data) return fmt.Sprintf(` %s @@ -101,11 +99,10 @@ data "azurerm_app_service_certificate_order" "test" { name = azurerm_app_service_certificate_order.test.name resource_group_name = azurerm_app_service_certificate_order.test.resource_group_name } -`, config) +`, AppServiceCertificateOrderResource{}.wildcard(data)) } func (d AppServiceCertificateOrderDataSource) complete(data acceptance.TestData) string { - config := AppServiceCertificateOrderResource{}.complete(data, 4096) return fmt.Sprintf(` %s @@ -113,5 +110,5 @@ data "azurerm_app_service_certificate_order" "test" { name = azurerm_app_service_certificate_order.test.name resource_group_name = azurerm_app_service_certificate_order.test.resource_group_name } -`, config) +`, AppServiceCertificateOrderResource{}.complete(data, 4096)) } diff --git a/internal/services/web/app_service_certificate_order_resource.go b/internal/services/web/app_service_certificate_order_resource.go index 1c00cc8a64a7..a79b1aa516b0 100644 --- a/internal/services/web/app_service_certificate_order_resource.go +++ b/internal/services/web/app_service_certificate_order_resource.go @@ -5,18 +5,16 @@ package web import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -25,12 +23,12 @@ import ( func resourceAppServiceCertificateOrder() *pluginsdk.Resource { return &pluginsdk.Resource{ - Create: resourceAppServiceCertificateOrderCreateUpdate, + Create: resourceAppServiceCertificateOrderCreate, Read: resourceAppServiceCertificateOrderRead, - Update: resourceAppServiceCertificateOrderCreateUpdate, + Update: resourceAppServiceCertificateOrderUpdate, Delete: resourceAppServiceCertificateOrderDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.CertificateOrderID(id) + _, err := appservicecertificateorders.ParseCertificateOrderID(id) return err }), @@ -178,67 +176,37 @@ func resourceAppServiceCertificateOrder() *pluginsdk.Resource { } } -func resourceAppServiceCertificateOrderCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesOrderClientV1 - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) - defer cancel() +func resourceAppServiceCertificateOrderCreate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Web.AppServiceCertificateOrdersClient - log.Printf("[INFO] preparing arguments for App Service Certificate creation.") + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) + defer cancel() - id := parse.NewCertificateOrderID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + id := appservicecertificateorders.NewCertificateOrderID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) - if d.IsNewResource() { - existing, err := client.Get(ctx, id.ResourceGroup, id.Name) + existing, err := client.Get(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %s", id, err) - } - } - - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_app_service_certificate_order", id.ID()) + return fmt.Errorf("checking for presence of existing %s: %s", id, err) } + return tf.ImportAsExistsError("azurerm_app_service_certificate_order", id.ID()) } - location := location.Normalize(d.Get("location").(string)) - t := d.Get("tags").(map[string]interface{}) - distinguishedName := d.Get("distinguished_name").(string) - csr := d.Get("csr").(string) - keySize := d.Get("key_size").(int) - autoRenew := d.Get("auto_renew").(bool) - validityInYears := d.Get("validity_in_years").(int) - - properties := web.AppServiceCertificateOrderProperties{ - DistinguishedName: pointer.To(distinguishedName), - Csr: pointer.To(csr), - KeySize: pointer.To(int32(keySize)), - AutoRenew: pointer.To(autoRenew), - ValidityInYears: pointer.To(int32(validityInYears)), - } - - switch d.Get("product_type").(string) { - case "Standard": - properties.ProductType = web.CertificateProductTypeStandardDomainValidatedSsl - case "WildCard": - properties.ProductType = web.CertificateProductTypeStandardDomainValidatedWildCardSsl - default: - return fmt.Errorf("`product_type` must be `Standard` or `WildCard`") - } - - certificateOrder := web.AppServiceCertificateOrder{ - AppServiceCertificateOrderProperties: &properties, - Location: pointer.To(location), - Tags: tags.Expand(t), - } - - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, certificateOrder) - if err != nil { - return fmt.Errorf("creating/updating %s: %s", id, err) + certificateOrder := appservicecertificateorders.AppServiceCertificateOrder{ + Properties: &appservicecertificateorders.AppServiceCertificateOrderProperties{ + AutoRenew: pointer.To(d.Get("auto_renew").(bool)), + Csr: pointer.To(d.Get("csr").(string)), + DistinguishedName: pointer.To(d.Get("distinguished_name").(string)), + KeySize: pointer.To(int64(d.Get("key_size").(int))), + ProductType: expandProductType(d.Get("product_type").(string)), + ValidityInYears: pointer.To(int64(d.Get("validity_in_years").(int))), + }, + Location: location.Normalize(d.Get("location").(string)), + Tags: utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})), } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creating/updating %s: %+v", id, err) + if err := client.CreateOrUpdateThenPoll(ctx, id, certificateOrder); err != nil { + return fmt.Errorf("creating %s: %w", id, err) } d.SetId(id.ID()) @@ -247,111 +215,191 @@ func resourceAppServiceCertificateOrderCreateUpdate(d *pluginsdk.ResourceData, m } func resourceAppServiceCertificateOrderRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesOrderClientV1 + client := meta.(*clients.Client).Web.AppServiceCertificateOrdersClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CertificateOrderID(d.Id()) + id, err := appservicecertificateorders.ParseCertificateOrderID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[DEBUG] App Service Certificate Order %q (resource group %q) was not found - removing from state", id.Name, id.ResourceGroup) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("making Read request on AzureRM App Service Certificate Order %q: %+v", id.Name, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("name", resp.Name) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("name", id.CertificateOrderName) + d.Set("resource_group_name", id.ResourceGroupName) + + if model := resp.Model; model != nil { + d.Set("location", location.Normalize(model.Location)) + d.Set("tags", model.Tags) + + if props := model.Properties; props != nil { + d.Set("auto_renew", props.AutoRenew) + d.Set("csr", props.Csr) + d.Set("distinguished_name", props.DistinguishedName) + d.Set("key_size", props.KeySize) + d.Set("validity_in_years", props.ValidityInYears) + d.Set("domain_verification_token", props.DomainVerificationToken) + d.Set("status", pointer.FromEnum(props.Status)) + d.Set("is_private_key_external", props.IsPrivateKeyExternal) + d.Set("certificates", flattenArmCertificateOrderCertificate(props.Certificates)) + d.Set("app_service_certificate_not_renewable_reasons", flattenAppServiceCertificateNotRenewableReasons(props.AppServiceCertificateNotRenewableReasons)) + d.Set("expiration_time", props.ExpirationTime) + d.Set("product_type", flattenProductType(props.ProductType)) + + if signedCertificate := props.SignedCertificate; signedCertificate != nil { + d.Set("signed_certificate_thumbprint", signedCertificate.Thumbprint) + } - if loc := resp.Location; loc != nil { - d.Set("location", location.Normalize(*loc)) - } + if root := props.Root; root != nil { + d.Set("root_thumbprint", root.Thumbprint) + } - if props := resp.AppServiceCertificateOrderProperties; props != nil { - d.Set("auto_renew", props.AutoRenew) - d.Set("csr", props.Csr) - d.Set("distinguished_name", props.DistinguishedName) - d.Set("key_size", props.KeySize) - d.Set("validity_in_years", props.ValidityInYears) - d.Set("domain_verification_token", props.DomainVerificationToken) - d.Set("status", string(props.Status)) - d.Set("is_private_key_external", props.IsPrivateKeyExternal) - d.Set("certificates", flattenArmCertificateOrderCertificate(props.Certificates)) - d.Set("app_service_certificate_not_renewable_reasons", utils.FlattenStringSlice(props.AppServiceCertificateNotRenewableReasons)) - - if productType := props.ProductType; productType == web.CertificateProductTypeStandardDomainValidatedSsl { - d.Set("product_type", "Standard") - } else if productType == web.CertificateProductTypeStandardDomainValidatedWildCardSsl { - d.Set("product_type", "WildCard") + if intermediate := props.Intermediate; intermediate != nil { + d.Set("intermediate_thumbprint", intermediate.Thumbprint) + } } + } - if expirationTime := props.ExpirationTime; expirationTime != nil { - d.Set("expiration_time", expirationTime.Format(time.RFC3339)) - } + return nil +} - if signedCertificate := props.SignedCertificate; signedCertificate != nil { - d.Set("signed_certificate_thumbprint", signedCertificate.Thumbprint) - } +func resourceAppServiceCertificateOrderUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Web.AppServiceCertificateOrdersClient - if root := props.Root; root != nil { - d.Set("root_thumbprint", root.Thumbprint) - } + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() - if intermediate := props.Intermediate; intermediate != nil { - d.Set("intermediate_thumbprint", intermediate.Thumbprint) - } + id, err := appservicecertificateorders.ParseCertificateOrderID(d.Id()) + if err != nil { + return err } - return tags.FlattenAndSet(d, resp.Tags) + existing, err := client.Get(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %s", id, err) + } + + if existing.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", id) + } + + if existing.Model.Properties == nil { + return fmt.Errorf("retrieving %s: `properties` was nil", id) + } + props := existing.Model.Properties + + if d.HasChange("auto_renew") { + props.AutoRenew = pointer.To(d.Get("auto_renew").(bool)) + } + + if d.HasChange("csr") { + props.Csr = pointer.To(d.Get("csr").(string)) + } + + if d.HasChange("distinguished_name") { + props.DistinguishedName = pointer.To(d.Get("distinguished_name").(string)) + } + + if d.HasChange("key_size") { + props.KeySize = pointer.To(int64(d.Get("key_size").(int))) + } + + if d.HasChange("product_type") { + props.ProductType = expandProductType(d.Get("product_type").(string)) + } + + if d.HasChange("validity_in_years") { + props.ValidityInYears = pointer.To(int64(d.Get("validity_in_years").(int))) + } + + if d.HasChange("tags") { + existing.Model.Tags = utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})) + } + + if err := client.CreateOrUpdateThenPoll(ctx, *id, *existing.Model); err != nil { + return fmt.Errorf("updating %s: %w", id, err) + } + + return resourceAppServiceCertificateOrderRead(d, meta) } func resourceAppServiceCertificateOrderDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesOrderClientV1 + client := meta.(*clients.Client).Web.AppServiceCertificateOrdersClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CertificateOrderID(d.Id()) + id, err := appservicecertificateorders.ParseCertificateOrderID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Deleting App Service Certificate Order %q (Resource Group %q)", id.Name, id.ResourceGroup) - - resp, err := client.Delete(ctx, id.ResourceGroup, id.Name) - if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting App Service Certificate Order %q (Resource Group %q): %s)", id.Name, id.ResourceGroup, err) - } + if _, err := client.Delete(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) } return nil } -func flattenArmCertificateOrderCertificate(input map[string]*web.AppServiceCertificate) []interface{} { +func flattenArmCertificateOrderCertificate(input *map[string]appservicecertificateorders.AppServiceCertificate) []interface{} { results := make([]interface{}, 0) + if input == nil { + return results + } - for k, v := range input { + for k, v := range *input { result := make(map[string]interface{}) result["certificate_name"] = k - if keyVaultID := v.KeyVaultID; keyVaultID != nil { + if keyVaultID := v.KeyVaultId; keyVaultID != nil { result["key_vault_id"] = *keyVaultID } if keyVaultSecretName := v.KeyVaultSecretName; keyVaultSecretName != nil { result["key_vault_secret_name"] = *keyVaultSecretName } - result["provisioning_state"] = string(v.ProvisioningState) + result["provisioning_state"] = pointer.FromEnum(v.ProvisioningState) results = append(results, result) } return results } + +func flattenAppServiceCertificateNotRenewableReasons(input *[]appservicecertificateorders.ResourceNotRenewableReason) []string { + results := make([]string, 0) + + if input == nil { + return results + } + + for _, v := range *input { + results = append(results, string(v)) + } + + return results +} + +func expandProductType(input string) appservicecertificateorders.CertificateProductType { + if input == "WildCard" { + return appservicecertificateorders.CertificateProductTypeStandardDomainValidatedWildCardSsl + } + return appservicecertificateorders.CertificateProductTypeStandardDomainValidatedSsl +} + +func flattenProductType(input appservicecertificateorders.CertificateProductType) string { + if input == appservicecertificateorders.CertificateProductTypeStandardDomainValidatedWildCardSsl { + return "WildCard" + } + return "Standard" +} diff --git a/internal/services/web/app_service_certificate_order_resource_test.go b/internal/services/web/app_service_certificate_order_resource_test.go index 8a80d20ca745..59fd3b66ec27 100644 --- a/internal/services/web/app_service_certificate_order_resource_test.go +++ b/internal/services/web/app_service_certificate_order_resource_test.go @@ -10,12 +10,11 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders" "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" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type AppServiceCertificateOrderResource struct{} @@ -157,19 +156,16 @@ func TestAccAppServiceCertificateOrder_update(t *testing.T) { } func (r AppServiceCertificateOrderResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.CertificateOrderID(state.ID) + id, err := appservicecertificateorders.ParseCertificateOrderID(state.ID) if err != nil { return nil, err } - resp, err := clients.Web.CertificatesOrderClientV1.Get(ctx, id.ResourceGroup, id.Name) + resp, err := clients.Web.AppServiceCertificateOrdersClient.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("retrieving App Service Certificate Order %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(true), nil + return pointer.To(resp.Model != nil), nil } func (r AppServiceCertificateOrderResource) basic(data acceptance.TestData) string { @@ -179,18 +175,18 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_app_service_certificate_order" "test" { - name = "acctestASCO-%d" + name = "acctestASCO-%[1]d" location = "global" resource_group_name = azurerm_resource_group.test.name distinguished_name = "CN=example.com" product_type = "Standard" } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary) } func (r AppServiceCertificateOrderResource) wildcard(data acceptance.TestData) string { @@ -200,18 +196,18 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_app_service_certificate_order" "test" { - name = "acctestASCO-%d" + name = "acctestASCO-%[1]d" location = "global" resource_group_name = azurerm_resource_group.test.name distinguished_name = "CN=*.example.com" product_type = "WildCard" } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary) } func (r AppServiceCertificateOrderResource) requiresImport(data acceptance.TestData) string { @@ -236,19 +232,19 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_app_service_certificate_order" "test" { - name = "acctestASCO-%d" + name = "acctestASCO-%[1]d" location = "global" resource_group_name = azurerm_resource_group.test.name distinguished_name = "CN=example.com" product_type = "Standard" auto_renew = false validity_in_years = 1 - key_size = %d + key_size = %[3]d } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, keySize) +`, data.RandomInteger, data.Locations.Primary, keySize) } diff --git a/internal/services/web/migration/app_service_certificate_order.go b/internal/services/web/migration/app_service_certificate_order.go index dad3ec819b44..13944cf97bf4 100644 --- a/internal/services/web/migration/app_service_certificate_order.go +++ b/internal/services/web/migration/app_service_certificate_order.go @@ -7,6 +7,7 @@ import ( "context" "fmt" + "github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -153,7 +154,7 @@ func (AppServiceCertificateOrderResourceV0ToV1) UpgradeFunc() pluginsdk.StateUpg return rawState, fmt.Errorf("parsing ID %q to upgrade: %+v", oldIdRaw, err) } - appServiceCertOrderId := parse.NewCertificateOrderID(oldId.SubscriptionId, oldId.ResourceGroup, oldId.CertificateOrderName) + appServiceCertOrderId := appservicecertificateorders.NewCertificateOrderID(oldId.SubscriptionId, oldId.ResourceGroup, oldId.CertificateOrderName) newId := appServiceCertOrderId.ID() rawState["id"] = newId diff --git a/internal/services/web/parse/certificate_order.go b/internal/services/web/parse/certificate_order.go deleted file mode 100644 index 12d65ba5c04c..000000000000 --- a/internal/services/web/parse/certificate_order.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type CertificateOrderId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewCertificateOrderID(subscriptionId, resourceGroup, name string) CertificateOrderId { - return CertificateOrderId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id CertificateOrderId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Certificate Order", segmentsStr) -} - -func (id CertificateOrderId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// CertificateOrderID parses a CertificateOrder ID into an CertificateOrderId struct -func CertificateOrderID(input string) (*CertificateOrderId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an CertificateOrder ID: %+v", input, err) - } - - resourceId := CertificateOrderId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("certificateOrders"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/web/parse/certificate_order_test.go b/internal/services/web/parse/certificate_order_test.go deleted file mode 100644 index 20053dd4e502..000000000000 --- a/internal/services/web/parse/certificate_order_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = CertificateOrderId{} - -func TestCertificateOrderIDFormatter(t *testing.T) { - actual := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "resGroup1", "order1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/order1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestCertificateOrderID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *CertificateOrderId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/order1", - Expected: &CertificateOrderId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "order1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.CERTIFICATEREGISTRATION/CERTIFICATEORDERS/ORDER1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := CertificateOrderID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/web/validate/certificate_order_id.go b/internal/services/web/validate/certificate_order_id.go deleted file mode 100644 index 5b31bc7f4bb7..000000000000 --- a/internal/services/web/validate/certificate_order_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" -) - -func CertificateOrderID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.CertificateOrderID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/web/validate/certificate_order_id_test.go b/internal/services/web/validate/certificate_order_id_test.go deleted file mode 100644 index 9e299167755e..000000000000 --- a/internal/services/web/validate/certificate_order_id_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestCertificateOrderID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/order1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.CERTIFICATEREGISTRATION/CERTIFICATEORDERS/ORDER1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := CertificateOrderID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} From 2962e27ec608a5f0b9ad404e9cbc78164f36de48 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:32:47 -0600 Subject: [PATCH 05/18] `azurerm_app_service_certificate` - migrate to `go-azure-sdk` --- .../web/app_service_certificate_resource.go | 183 +++++++++--------- .../app_service_certificate_resource_test.go | 68 ++++--- internal/services/web/parse/certificate.go | 73 ------- .../services/web/parse/certificate_test.go | 114 ----------- .../services/web/validate/certificate_id.go | 26 --- .../web/validate/certificate_id_test.go | 78 -------- 6 files changed, 129 insertions(+), 413 deletions(-) delete mode 100644 internal/services/web/parse/certificate.go delete mode 100644 internal/services/web/parse/certificate_test.go delete mode 100644 internal/services/web/validate/certificate_id.go delete mode 100644 internal/services/web/validate/certificate_id_test.go diff --git a/internal/services/web/app_service_certificate_resource.go b/internal/services/web/app_service_certificate_resource.go index d66499d34997..b145af876fcc 100644 --- a/internal/services/web/app_service_certificate_resource.go +++ b/internal/services/web/app_service_certificate_resource.go @@ -6,20 +6,18 @@ package web import ( "encoding/base64" "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/keyvault" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" keyVaultSuppress "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/suppress" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -28,12 +26,12 @@ import ( func resourceAppServiceCertificate() *pluginsdk.Resource { return &pluginsdk.Resource{ - Create: resourceAppServiceCertificateCreateUpdate, + Create: resourceAppServiceCertificateCreate, Read: resourceAppServiceCertificateRead, - Update: resourceAppServiceCertificateCreateUpdate, + Update: resourceAppServiceCertificateUpdate, Delete: resourceAppServiceCertificateDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.CertificateID(id) + _, err := certificates.ParseCertificateID(id) return err }), @@ -144,63 +142,56 @@ func resourceAppServiceCertificate() *pluginsdk.Resource { } } -func resourceAppServiceCertificateCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { +func resourceAppServiceCertificateCreate(d *pluginsdk.ResourceData, meta interface{}) error { keyVaultsClient := meta.(*clients.Client).KeyVault - client := meta.(*clients.Client).Web.CertificatesClientV1 - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) - defer cancel() + client := meta.(*clients.Client).Web.CertificatesClient - log.Printf("[INFO] preparing arguments for App Service Certificate creation.") + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) + defer cancel() - id := parse.NewCertificateID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + id := certificates.NewCertificateID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) - if d.IsNewResource() { - existing, err := client.Get(ctx, id.ResourceGroup, id.Name) + existing, err := client.Get(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %s", id, err) - } - } - - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_app_service_certificate", id.ID()) + return fmt.Errorf("checking for presence of existing %s: %w", id, err) } + return tf.ImportAsExistsError("azurerm_app_service_certificate", id.ID()) } - certificate := web.Certificate{ - CertificateProperties: &web.CertificateProperties{ + certificate := certificates.Certificate{ + Properties: &certificates.CertificateProperties{ Password: pointer.To(d.Get("password").(string)), }, - Location: pointer.To(location.Normalize(d.Get("location").(string))), - Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + Location: location.Normalize(d.Get("location").(string)), + Tags: utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})), } - if appServicePlanId := d.Get("app_service_plan_id").(string); appServicePlanId != "" { - certificate.ServerFarmID = &appServicePlanId + if v := d.Get("app_service_plan_id").(string); v != "" { + certificate.Properties.ServerFarmId = &v } - if pfxBlob := d.Get("pfx_blob").(string); pfxBlob != "" { - decodedPfxBlob, err := base64.StdEncoding.DecodeString(pfxBlob) + if v := d.Get("pfx_blob").(string); v != "" { + decodedPfxBlob, err := base64.StdEncoding.DecodeString(v) if err != nil { - return fmt.Errorf("could not decode PFX blob: %+v", err) + return fmt.Errorf("decoding PFX blob: %+v", err) } - certificate.PfxBlob = &decodedPfxBlob + certificate.Properties.PfxBlob = pointer.To(string(decodedPfxBlob)) } - if keyVaultSecretId := d.Get("key_vault_secret_id").(string); keyVaultSecretId != "" { - parsedSecretId, err := keyvault.ParseNestedItemID(keyVaultSecretId, keyvault.VersionTypeAny, keyvault.NestedItemTypeAny) + if v := d.Get("key_vault_secret_id").(string); v != "" { + parsedSecretId, err := keyvault.ParseNestedItemID(v, keyvault.VersionTypeAny, keyvault.NestedItemTypeAny) if err != nil { return err } var keyVaultId *string - if customizedKeyVaultId := d.Get("key_vault_id").(string); customizedKeyVaultId != "" { - keyVaultId = pointer.To(customizedKeyVaultId) + if v := d.Get("key_vault_id").(string); v != "" { + keyVaultId = pointer.To(v) } else { keyVaultBaseUrl := parsedSecretId.KeyVaultBaseURL - subscriptionResourceId := commonids.NewSubscriptionID(subscriptionId) + subscriptionResourceId := commonids.NewSubscriptionID(id.SubscriptionId) keyVaultId, err = keyVaultsClient.KeyVaultIDFromBaseUrl(ctx, subscriptionResourceId, keyVaultBaseUrl) if err != nil { return fmt.Errorf("retrieving the Resource ID for the Key Vault at URL %q: %s", keyVaultBaseUrl, err) @@ -210,12 +201,12 @@ func resourceAppServiceCertificateCreateUpdate(d *pluginsdk.ResourceData, meta i } } - certificate.KeyVaultID = keyVaultId - certificate.KeyVaultSecretName = pointer.To(parsedSecretId.Name) + certificate.Properties.KeyVaultId = keyVaultId + certificate.Properties.KeyVaultSecretName = pointer.To(parsedSecretId.Name) } - if _, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, certificate); err != nil { - return fmt.Errorf("creating/updating %s: %s", id, err) + if _, err := client.CreateOrUpdate(ctx, id, certificate); err != nil { + return fmt.Errorf("creating %s: %s", id, err) } d.SetId(id.ID()) @@ -223,82 +214,100 @@ func resourceAppServiceCertificateCreateUpdate(d *pluginsdk.ResourceData, meta i return resourceAppServiceCertificateRead(d, meta) } +func resourceAppServiceCertificateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Web.CertificatesClient + + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + id := certificates.NewCertificateID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + + existing, err := client.Get(ctx, id) + if err != nil { + return fmt.Errorf("retrieving %s: %w", id, err) + } + + if existing.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", id) + } + + existing.Model.Tags = utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})) + + if _, err := client.CreateOrUpdate(ctx, id, *existing.Model); err != nil { + return fmt.Errorf("updating %s: %s", id, err) + } + + return resourceAppServiceCertificateRead(d, meta) +} + func resourceAppServiceCertificateRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClientV1 + client := meta.(*clients.Client).Web.CertificatesClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CertificateID(d.Id()) + id, err := certificates.ParseCertificateID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[DEBUG] App Service Certificate %q (Resource Group %q) was not found - removing from state", id.Name, id.ResourceGroup) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("name", resp.Name) - d.Set("resource_group_name", id.ResourceGroup) - d.Set("location", location.NormalizeNilable(resp.Location)) - - if props := resp.CertificateProperties; props != nil { - d.Set("friendly_name", props.FriendlyName) - d.Set("subject_name", props.SubjectName) - d.Set("host_names", props.HostNames) - d.Set("issuer", props.Issuer) - - if props.HostingEnvironmentProfile != nil && props.HostingEnvironmentProfile.ID != nil { - envId, err := parse.AppServiceEnvironmentID(*props.HostingEnvironmentProfile.ID) - if err != nil { - return fmt.Errorf("parsing hosting environment error: %+v", err) + d.Set("name", id.CertificateName) + d.Set("resource_group_name", id.ResourceGroupName) + + if model := resp.Model; model != nil { + d.Set("location", location.Normalize(resp.Model.Location)) + + if props := model.Properties; props != nil { + d.Set("friendly_name", props.FriendlyName) + d.Set("subject_name", props.SubjectName) + d.Set("host_names", props.HostNames) + d.Set("issuer", props.Issuer) + d.Set("tags", model.Tags) + d.Set("issue_date", props.IssueDate) + d.Set("expiration_date", props.ExpirationDate) + d.Set("thumbprint", props.Thumbprint) + + if props.HostingEnvironmentProfile != nil && props.HostingEnvironmentProfile.Id != nil { + envId, err := commonids.ParseAppServiceEnvironmentID(*props.HostingEnvironmentProfile.Id) + if err != nil { + return err + } + d.Set("hosting_environment_profile_id", envId.ID()) } - d.Set("hosting_environment_profile_id", envId.ID()) - } - - issueDate := "" - if props.IssueDate != nil { - issueDate = props.IssueDate.Format(time.RFC3339) - } - d.Set("issue_date", issueDate) - expirationDate := "" - if props.ExpirationDate != nil { - expirationDate = props.ExpirationDate.Format(time.RFC3339) + if props.ServerFarmId != nil { + sfID, err := commonids.ParseAppServicePlanID(*props.ServerFarmId) + if err != nil { + return err + } + d.Set("server_farm_id", sfID.ID()) + } } - d.Set("expiration_date", expirationDate) - d.Set("thumbprint", props.Thumbprint) - } - - if err := tags.FlattenAndSet(d, resp.Tags); err != nil { - return err } return nil } func resourceAppServiceCertificateDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClientV1 + client := meta.(*clients.Client).Web.CertificatesClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.CertificateID(d.Id()) + id, err := certificates.ParseCertificateID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Deleting App Service Certificate %q (Resource Group %q)", id.Name, id.ResourceGroup) - - resp, err := client.Delete(ctx, id.ResourceGroup, id.Name) - if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting App Service Certificate %q (Resource Group %q): %s)", id.Name, id.ResourceGroup, err) - } + if _, err := client.Delete(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %w", id, err) } return nil diff --git a/internal/services/web/app_service_certificate_resource_test.go b/internal/services/web/app_service_certificate_resource_test.go index caf6dd07b2a1..1bc4e8f4858e 100644 --- a/internal/services/web/app_service_certificate_resource_test.go +++ b/internal/services/web/app_service_certificate_resource_test.go @@ -9,12 +9,11 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" "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" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type AppServiceCertificateResource struct{} @@ -95,20 +94,19 @@ func TestAccAppServiceCertificate_KeyVaultIdVersionless(t *testing.T) { }) } +// TODO: add test with `app_service_plan_id` set + func (r AppServiceCertificateResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.CertificateID(state.ID) + id, err := certificates.ParseCertificateID(state.ID) if err != nil { return nil, err } - resp, err := clients.Web.CertificatesClientV1.Get(ctx, id.ResourceGroup, id.Name) + resp, err := clients.Web.CertificatesClient.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("retrieving App Service Certificate %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(true), nil + return pointer.To(resp.Model != nil), nil } func (r AppServiceCertificateResource) pfx(data acceptance.TestData) string { @@ -118,18 +116,18 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestwebcert%d" - location = "%s" + name = "acctestwebcert%[1]d" + location = "%[2]s" } resource "azurerm_app_service_certificate" "test" { - name = "acctest%d" + name = "acctest%[1]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location pfx_blob = filebase64("testdata/app_service_certificate.pfx") password = "terraform" } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary) } func (r AppServiceCertificateResource) pfxNoPassword(data acceptance.TestData) string { @@ -139,17 +137,17 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestwebcert%d" - location = "%s" + name = "acctestwebcert%[1]d" + location = "%[2]s" } resource "azurerm_app_service_certificate" "test" { - name = "acctest%d" + name = "acctest%[1]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location pfx_blob = filebase64("testdata/app_service_certificate_nopassword.pfx") } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary) } func (r AppServiceCertificateResource) keyVault(data acceptance.TestData) string { @@ -167,12 +165,12 @@ data "azuread_service_principal" "test" { } resource "azurerm_resource_group" "test" { - name = "acctestwebcert%d" - location = "%s" + name = "acctestwebcert%[1]d" + location = "%[2]s" } resource "azurerm_key_vault" "test" { - name = "acctest%s" + name = "acctest%[3]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -215,7 +213,7 @@ resource "azurerm_key_vault" "test" { } resource "azurerm_key_vault_certificate" "test" { - name = "acctest%d" + name = "acctest%[1]d" key_vault_id = azurerm_key_vault.test.id certificate { @@ -242,12 +240,12 @@ resource "azurerm_key_vault_certificate" "test" { } resource "azurerm_app_service_certificate" "test" { - name = "acctest%d" + name = "acctest%[1]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location key_vault_secret_id = azurerm_key_vault_certificate.test.id } -`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary, data.RandomString) } func (r AppServiceCertificateResource) keyVaultId(data acceptance.TestData) string { @@ -265,12 +263,12 @@ data "azuread_service_principal" "test" { } resource "azurerm_resource_group" "test" { - name = "acctestwebcert%d" - location = "%s" + name = "acctestwebcert%[1]d" + location = "%[2]s" } resource "azurerm_key_vault" "test" { - name = "acctest%s" + name = "acctest%[3]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -313,7 +311,7 @@ resource "azurerm_key_vault" "test" { } resource "azurerm_key_vault_certificate" "test" { - name = "acctest%d" + name = "acctest%[1]d" key_vault_id = azurerm_key_vault.test.id certificate { @@ -340,13 +338,13 @@ resource "azurerm_key_vault_certificate" "test" { } resource "azurerm_app_service_certificate" "test" { - name = "acctest%d" + name = "acctest%[1]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location key_vault_id = azurerm_key_vault.test.id key_vault_secret_id = azurerm_key_vault_certificate.test.id } -`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary, data.RandomString) } func (r AppServiceCertificateResource) keyVaultIdVersionless(data acceptance.TestData) string { @@ -364,12 +362,12 @@ data "azuread_service_principal" "test" { } resource "azurerm_resource_group" "test" { - name = "acctestwebcert%d" - location = "%s" + name = "acctestwebcert%[1]d" + location = "%[2]s" } resource "azurerm_key_vault" "test" { - name = "acctest%s" + name = "acctest%[3]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -412,7 +410,7 @@ resource "azurerm_key_vault" "test" { } resource "azurerm_key_vault_certificate" "test" { - name = "acctest%d" + name = "acctest%[1]d" key_vault_id = azurerm_key_vault.test.id certificate { @@ -439,11 +437,11 @@ resource "azurerm_key_vault_certificate" "test" { } resource "azurerm_app_service_certificate" "test" { - name = "acctest%d" + name = "acctest%[1]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location key_vault_id = azurerm_key_vault.test.id key_vault_secret_id = azurerm_key_vault_certificate.test.versionless_secret_id } -`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary, data.RandomString) } diff --git a/internal/services/web/parse/certificate.go b/internal/services/web/parse/certificate.go deleted file mode 100644 index 656b0bd8487f..000000000000 --- a/internal/services/web/parse/certificate.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type CertificateId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewCertificateID(subscriptionId, resourceGroup, name string) CertificateId { - return CertificateId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id CertificateId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Certificate", segmentsStr) -} - -func (id CertificateId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/certificates/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// CertificateID parses a Certificate ID into an CertificateId struct -func CertificateID(input string) (*CertificateId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an Certificate ID: %+v", input, err) - } - - resourceId := CertificateId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("certificates"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/web/parse/certificate_test.go b/internal/services/web/parse/certificate_test.go deleted file mode 100644 index a3fbefc64b41..000000000000 --- a/internal/services/web/parse/certificate_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = CertificateId{} - -func TestCertificateIDFormatter(t *testing.T) { - actual := NewCertificateID("12345678-1234-9876-4563-123456789012", "resGroup1", "certificate1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/certificate1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestCertificateID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *CertificateId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/certificate1", - Expected: &CertificateId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "certificate1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/CERTIFICATES/CERTIFICATE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := CertificateID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/web/validate/certificate_id.go b/internal/services/web/validate/certificate_id.go deleted file mode 100644 index 3e128bd4d6aa..000000000000 --- a/internal/services/web/validate/certificate_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" -) - -func CertificateID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.CertificateID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/web/validate/certificate_id_test.go b/internal/services/web/validate/certificate_id_test.go deleted file mode 100644 index 2e9e702cde50..000000000000 --- a/internal/services/web/validate/certificate_id_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestCertificateID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/certificate1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/CERTIFICATES/CERTIFICATE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := CertificateID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} From da0d1f10684282d4810fb1edacee9d89aa033430 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:41:17 -0600 Subject: [PATCH 06/18] `azurerm_app_service_custom_hostname_binding` - migrate to `go-azure-sdk` --- ...ervice_custom_hostname_binding_resource.go | 119 ++++++++---------- ...e_custom_hostname_binding_resource_test.go | 54 ++++---- ...ervice_custom_hostname_binding_v0_to_v1.go | 64 ++++++++++ .../app_service_custom_hostname_binding.go | 41 ------ ...pp_service_custom_hostname_binding_test.go | 91 -------------- .../app_service_custom_hostname_binding_id.go | 23 ---- 6 files changed, 143 insertions(+), 249 deletions(-) create mode 100644 internal/services/web/migration/app_service_custom_hostname_binding_v0_to_v1.go delete mode 100644 internal/services/web/parse/app_service_custom_hostname_binding.go delete mode 100644 internal/services/web/parse/app_service_custom_hostname_binding_test.go delete mode 100644 internal/services/web/validate/app_service_custom_hostname_binding_id.go diff --git a/internal/services/web/app_service_custom_hostname_binding_resource.go b/internal/services/web/app_service_custom_hostname_binding_resource.go index ba2535e024cd..b07cb0097657 100644 --- a/internal/services/web/app_service_custom_hostname_binding_resource.go +++ b/internal/services/web/app_service_custom_hostname_binding_resource.go @@ -5,23 +5,22 @@ package web import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) -var appServiceCustomHostnameBindingResourceName = "azurerm_app_service_custom_hostname_binding" +const appServiceCustomHostnameBindingResourceName = "azurerm_app_service_custom_hostname_binding" func resourceAppServiceCustomHostnameBinding() *pluginsdk.Resource { return &pluginsdk.Resource{ @@ -29,10 +28,15 @@ func resourceAppServiceCustomHostnameBinding() *pluginsdk.Resource { Read: resourceAppServiceCustomHostnameBindingRead, Delete: resourceAppServiceCustomHostnameBindingDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.AppServiceCustomHostnameBindingID(id) + _, err := webapps.ParseHostNameBindingID(id) return err }), + SchemaVersion: 1, + StateUpgraders: pluginsdk.StateUpgrades(map[int]pluginsdk.StateUpgrade{ + 0: migration.AppServiceCustomHostnameBindingV0ToV1{}, + }), + Timeouts: &pluginsdk.ResourceTimeout{ Create: pluginsdk.DefaultTimeout(30 * time.Minute), Read: pluginsdk.DefaultTimeout(5 * time.Minute), @@ -60,8 +64,8 @@ func resourceAppServiceCustomHostnameBinding() *pluginsdk.Resource { Computed: true, ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ - string(web.SslStateIPBasedEnabled), - string(web.SslStateSniEnabled), + string(webapps.SslStateIPBasedEnabled), + string(webapps.SslStateSniEnabled), }, false), }, @@ -82,46 +86,38 @@ func resourceAppServiceCustomHostnameBinding() *pluginsdk.Resource { } func resourceAppServiceCustomHostnameBindingCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - log.Printf("[INFO] preparing arguments for App Service Hostname Binding creation.") + id := webapps.NewHostNameBindingID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("app_service_name").(string), d.Get("hostname").(string)) - resourceGroup := d.Get("resource_group_name").(string) - appServiceName := d.Get("app_service_name").(string) - hostname := d.Get("hostname").(string) - sslState := d.Get("ssl_state").(string) - thumbprint := d.Get("thumbprint").(string) + locks.ByName(id.HostNameBindingName, appServiceCustomHostnameBindingResourceName) + defer locks.UnlockByName(id.HostNameBindingName, appServiceCustomHostnameBindingResourceName) - locks.ByName(appServiceName, appServiceCustomHostnameBindingResourceName) - defer locks.UnlockByName(appServiceName, appServiceCustomHostnameBindingResourceName) - - if d.IsNewResource() { - existing, err := client.GetHostNameBinding(ctx, resourceGroup, appServiceName, hostname) + existing, err := client.GetHostNameBinding(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing Custom Hostname Binding %q (App Service %q / Resource Group %q): %s", hostname, appServiceName, resourceGroup, err) - } - } - - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_app_service_custom_hostname_binding", *existing.ID) + return fmt.Errorf("checking for presence of existing %s: %w", id, err) } + return tf.ImportAsExistsError("azurerm_app_service_custom_hostname_binding", id.ID()) } - properties := web.HostNameBinding{ - HostNameBindingProperties: &web.HostNameBindingProperties{ - SiteName: pointer.To(appServiceName), + payload := webapps.HostNameBinding{ + Properties: &webapps.HostNameBindingProperties{ + SiteName: pointer.To(id.SiteName), }, } + sslState := d.Get("ssl_state").(string) + thumbprint := d.Get("thumbprint").(string) if sslState != "" { if thumbprint == "" { return fmt.Errorf("`thumbprint` must be specified when `ssl_state` is set") } - properties.SslState = web.SslState(sslState) + payload.Properties.SslState = pointer.ToEnum[webapps.SslState](sslState) } if thumbprint != "" { @@ -129,78 +125,71 @@ func resourceAppServiceCustomHostnameBindingCreate(d *pluginsdk.ResourceData, me return fmt.Errorf("`ssl_state` must be specified when `thumbprint` is set") } - properties.Thumbprint = pointer.To(thumbprint) - } - - if _, err := client.CreateOrUpdateHostNameBinding(ctx, resourceGroup, appServiceName, hostname, properties); err != nil { - return fmt.Errorf("creating/updating Custom Hostname Binding %q (App Service %q / Resource Group %q): %+v", hostname, appServiceName, resourceGroup, err) + payload.Properties.Thumbprint = pointer.To(thumbprint) } - read, err := client.GetHostNameBinding(ctx, resourceGroup, appServiceName, hostname) - if err != nil { - return fmt.Errorf("retrieving Custom Hostname Binding %q (App Service %q / Resource Group %q): %+v", hostname, appServiceName, resourceGroup, err) - } - if read.ID == nil { - return fmt.Errorf("cannot read Hostname Binding %q (App Service %q / Resource Group %q) ID", hostname, appServiceName, resourceGroup) + if _, err := client.CreateOrUpdateHostNameBinding(ctx, id, payload); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) } - d.SetId(*read.ID) + d.SetId(id.ID()) return resourceAppServiceCustomHostnameBindingRead(d, meta) } func resourceAppServiceCustomHostnameBindingRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.AppServiceCustomHostnameBindingID(d.Id()) + id, err := webapps.ParseHostNameBindingID(d.Id()) if err != nil { return err } - resp, err := client.GetHostNameBinding(ctx, id.ResourceGroup, id.AppServiceName, id.Name) + resp, err := client.GetHostNameBinding(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[DEBUG] App Service Hostname Binding %q (App Service %q / Resource Group %q) was not found - removing from state", id.Name, id.AppServiceName, id.ResourceGroup) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("retrieving Custom Hostname Binding %q (App Service %q / Resource Group %q): %+v", id.Name, id.AppServiceName, id.ResourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - d.Set("hostname", id.Name) - d.Set("app_service_name", id.AppServiceName) - d.Set("resource_group_name", id.ResourceGroup) + d.Set("hostname", id.HostNameBindingName) + d.Set("app_service_name", id.SiteName) + d.Set("resource_group_name", id.ResourceGroupName) - if props := resp.HostNameBindingProperties; props != nil { - d.Set("ssl_state", props.SslState) - d.Set("thumbprint", props.Thumbprint) - d.Set("virtual_ip", props.VirtualIP) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("ssl_state", props.SslState) + d.Set("thumbprint", props.Thumbprint) + d.Set("virtual_ip", props.VirtualIP) + } } return nil } func resourceAppServiceCustomHostnameBindingDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.AppServiceCustomHostnameBindingID(d.Id()) + id, err := webapps.ParseHostNameBindingID(d.Id()) if err != nil { return err } - locks.ByName(id.AppServiceName, appServiceCustomHostnameBindingResourceName) - defer locks.UnlockByName(id.AppServiceName, appServiceCustomHostnameBindingResourceName) - - log.Printf("[DEBUG] Deleting App Service Hostname Binding %q (App Service %q / Resource Group %q)", id.Name, id.AppServiceName, id.ResourceGroup) + locks.ByName(id.HostNameBindingName, appServiceCustomHostnameBindingResourceName) + defer locks.UnlockByName(id.HostNameBindingName, appServiceCustomHostnameBindingResourceName) - resp, err := client.DeleteHostNameBinding(ctx, id.ResourceGroup, id.AppServiceName, id.Name) + resp, err := client.DeleteHostNameBinding(ctx, *id) if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting Custom Hostname Binding %q (App Service %q / Resource Group %q): %+v", id.Name, id.AppServiceName, id.ResourceGroup, err) + if !response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("deleting %s: %+v", id, err) } } diff --git a/internal/services/web/app_service_custom_hostname_binding_resource_test.go b/internal/services/web/app_service_custom_hostname_binding_resource_test.go index fe59a716ac7f..4c1f45c37582 100644 --- a/internal/services/web/app_service_custom_hostname_binding_resource_test.go +++ b/internal/services/web/app_service_custom_hostname_binding_resource_test.go @@ -10,12 +10,11 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" "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" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type ServiceCustomHostnameBindingResource struct{} @@ -61,7 +60,7 @@ func testAccAppServiceCustomHostnameBinding_basic(t *testing.T, appServiceEnv, d data := acceptance.BuildTestData(t, "azurerm_app_service_custom_hostname_binding", "test") r := ServiceCustomHostnameBindingResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ + data.ResourceSequentialTest(t, r, []acceptance.TestStep{ { Config: r.basicConfig(data, appServiceEnv, domainEnv), Check: acceptance.ComposeTestCheckFunc( @@ -76,7 +75,7 @@ func testAccAppServiceCustomHostnameBinding_requiresImport(t *testing.T, appServ data := acceptance.BuildTestData(t, "azurerm_app_service_custom_hostname_binding", "test") r := ServiceCustomHostnameBindingResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ + data.ResourceSequentialTest(t, r, []acceptance.TestStep{ { Config: r.basicConfig(data, appServiceEnv, domainEnv), Check: acceptance.ComposeTestCheckFunc( @@ -99,7 +98,7 @@ func testAccAppServiceCustomHostnameBinding_multiple(t *testing.T, appServiceEnv data := acceptance.BuildTestData(t, "azurerm_app_service_custom_hostname_binding", "test") r := ServiceCustomHostnameBindingResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ + data.ResourceSequentialTest(t, r, []acceptance.TestStep{ { Config: r.multipleConfig(data, appServiceEnv, domainEnv, altDomainEnv), Check: acceptance.ComposeTestCheckFunc( @@ -113,7 +112,7 @@ func testAccAppServiceCustomHostnameBinding_ssl(t *testing.T, appServiceEnv, dom data := acceptance.BuildTestData(t, "azurerm_app_service_custom_hostname_binding", "test") r := ServiceCustomHostnameBindingResource{} - data.ResourceTest(t, r, []acceptance.TestStep{ + data.ResourceSequentialTest(t, r, []acceptance.TestStep{ { Config: r.sslConfig(data, appServiceEnv, domainEnv), Check: acceptance.ComposeTestCheckFunc( @@ -125,20 +124,17 @@ func testAccAppServiceCustomHostnameBinding_ssl(t *testing.T, appServiceEnv, dom } func (r ServiceCustomHostnameBindingResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.AppServiceCustomHostnameBindingID(state.ID) + id, err := webapps.ParseHostNameBindingID(state.ID) if err != nil { return nil, err } - resp, err := clients.Web.AppServicesClientV1.GetHostNameBinding(ctx, id.ResourceGroup, id.AppServiceName, id.Name) + resp, err := clients.Web.WebAppsClient.GetHostNameBinding(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("retrieving App Service Custom Hostname Binding %q (App Service %q / Resource Group %q): %+v", id.Name, id.AppServiceName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(resp.HostNameBindingProperties != nil), nil + return pointer.To(resp.Model != nil), nil } func (ServiceCustomHostnameBindingResource) basicConfig(data acceptance.TestData, appServiceName string, domain string) string { @@ -148,12 +144,12 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_app_service_plan" "test" { - name = "acctestASP-%d" + name = "acctestASP-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -164,18 +160,18 @@ resource "azurerm_app_service_plan" "test" { } resource "azurerm_app_service" "test" { - name = "%s" + name = "%[3]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name app_service_plan_id = azurerm_app_service_plan.test.id } resource "azurerm_app_service_custom_hostname_binding" "test" { - hostname = "%s" + hostname = "%[4]s" app_service_name = azurerm_app_service.test.name resource_group_name = azurerm_resource_group.test.name } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, appServiceName, domain) +`, data.RandomInteger, data.Locations.Primary, appServiceName, domain) } func (r ServiceCustomHostnameBindingResource) requiresImport(data acceptance.TestData, appServiceName string, domain string) string { @@ -209,12 +205,12 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_app_service_plan" "test" { - name = "acctestASP-%d" + name = "acctestASP-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -225,7 +221,7 @@ resource "azurerm_app_service_plan" "test" { } resource "azurerm_app_service" "test" { - name = "%s" + name = "%[3]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name app_service_plan_id = azurerm_app_service_plan.test.id @@ -235,7 +231,7 @@ data "azurerm_client_config" "test" { } resource "azurerm_key_vault" "test" { - name = "acctest-%s" + name = "acctest-%[4]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name tenant_id = data.azurerm_client_config.test.tenant_id @@ -250,7 +246,7 @@ resource "azurerm_key_vault" "test" { } resource "azurerm_key_vault_certificate" "test" { - name = "acct-%d" + name = "acct-%[1]d" key_vault_id = azurerm_key_vault.test.id certificate_policy { @@ -277,7 +273,7 @@ resource "azurerm_key_vault_certificate" "test" { "keyEncipherment", ] - subject = "CN=%s" + subject = "CN=%[5]s" validity_in_months = 12 } } @@ -289,18 +285,18 @@ data "azurerm_key_vault_secret" "test" { } resource "azurerm_app_service_certificate" "test" { - name = "acctestCert-%d" + name = "acctestCert-%[1]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location pfx_blob = data.azurerm_key_vault_secret.test.value } resource "azurerm_app_service_custom_hostname_binding" "test" { - hostname = "%s" + hostname = "%[5]s" app_service_name = azurerm_app_service.test.name resource_group_name = azurerm_resource_group.test.name ssl_state = "SniEnabled" thumbprint = azurerm_app_service_certificate.test.thumbprint } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, appServiceName, data.RandomString, data.RandomInteger, domain, data.RandomInteger, domain) +`, data.RandomInteger, data.Locations.Primary, appServiceName, data.RandomString, domain) } diff --git a/internal/services/web/migration/app_service_custom_hostname_binding_v0_to_v1.go b/internal/services/web/migration/app_service_custom_hostname_binding_v0_to_v1.go new file mode 100644 index 000000000000..655816c1b290 --- /dev/null +++ b/internal/services/web/migration/app_service_custom_hostname_binding_v0_to_v1.go @@ -0,0 +1,64 @@ +package migration + +import ( + "context" + "log" + + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type AppServiceCustomHostnameBindingV0ToV1 struct{} + +func (AppServiceCustomHostnameBindingV0ToV1) Schema() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "hostname": { + Type: pluginsdk.TypeString, + Required: true, + }, + + "resource_group_name": { + Type: schema.TypeString, + Required: true, + }, + + "app_service_name": { + Type: pluginsdk.TypeString, + Required: true, + }, + + "ssl_state": { + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + }, + + "thumbprint": { + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + }, + + "virtual_ip": { + Type: pluginsdk.TypeString, + Computed: true, + }, + } +} + +func (AppServiceCustomHostnameBindingV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { + return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + oldId := rawState["id"].(string) + parsed, err := webapps.ParseHostNameBindingIDInsensitively(oldId) + if err != nil { + return nil, err + } + + newId := parsed.ID() + log.Printf("[DEBUG] Upgrading `%s` to `%s`", oldId, newId) + rawState["id"] = newId + + return rawState, nil + } +} diff --git a/internal/services/web/parse/app_service_custom_hostname_binding.go b/internal/services/web/parse/app_service_custom_hostname_binding.go deleted file mode 100644 index 9ed60f20952c..000000000000 --- a/internal/services/web/parse/app_service_custom_hostname_binding.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" -) - -type AppServiceCustomHostnameBindingId struct { - ResourceGroup string - AppServiceName string - Name string -} - -func AppServiceCustomHostnameBindingID(input string) (*AppServiceCustomHostnameBindingId, error) { - id, err := azure.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("[ERROR] Unable to parse App Service Custom Hostname Binding ID %q: %+v", input, err) - } - - binding := AppServiceCustomHostnameBindingId{ - ResourceGroup: id.ResourceGroup, - } - - if binding.AppServiceName, err = id.PopSegment("sites"); err != nil { - return nil, err - } - - if binding.Name, err = id.PopSegment("hostNameBindings"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &binding, nil -} diff --git a/internal/services/web/parse/app_service_custom_hostname_binding_test.go b/internal/services/web/parse/app_service_custom_hostname_binding_test.go deleted file mode 100644 index 58bb48feff43..000000000000 --- a/internal/services/web/parse/app_service_custom_hostname_binding_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -import ( - "testing" -) - -func TestParseAppServiceCustomHostnameBinding(t *testing.T) { - testData := []struct { - Name string - Input string - Expected *AppServiceCustomHostnameBindingId - }{ - { - Name: "Empty", - Input: "", - Expected: nil, - }, - { - Name: "No Resource Groups Segment", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000", - Expected: nil, - }, - { - Name: "No Resource Groups Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/", - Expected: nil, - }, - { - Name: "Resource Group ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo/", - Expected: nil, - }, - { - Name: "Missing Sites Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/sites/", - Expected: nil, - }, - { - Name: "App Service Resource ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1", - Expected: nil, - }, - { - Name: "Missing Host Name Bindings Valud", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/", - Expected: nil, - }, - { - Name: "Valid Resource ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1", - Expected: &AppServiceCustomHostnameBindingId{ - Name: "binding1", - AppServiceName: "site1", - ResourceGroup: "mygroup1", - }, - }, - { - Name: "Wrong Casing", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/Sites/site1/HostNameBindings/binding1", - Expected: nil, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Name) - - actual, err := AppServiceCustomHostnameBindingID(v.Input) - if err != nil { - if v.Expected == nil { - continue - } - - t.Fatalf("Expected a value but got an error: %s", err) - } - - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - - if actual.AppServiceName != v.Expected.AppServiceName { - t.Fatalf("Expected %q but got %q for SiteName", v.Expected.AppServiceName, actual.AppServiceName) - } - - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup) - } - } -} diff --git a/internal/services/web/validate/app_service_custom_hostname_binding_id.go b/internal/services/web/validate/app_service_custom_hostname_binding_id.go deleted file mode 100644 index b6c13d689c1c..000000000000 --- a/internal/services/web/validate/app_service_custom_hostname_binding_id.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" -) - -func AppServiceCustomHostnameBindingID(i interface{}, k string) (warnings []string, errors []error) { - v, ok := i.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected type of %q to be string", k)) - return - } - - if _, err := parse.AppServiceCustomHostnameBindingID(v); err != nil { - errors = append(errors, fmt.Errorf("can not parse %q as App Service Custom Hostname ID: %+v", k, err)) - } - return -} From e3025722164c85cbdbc5be0141cd48fe4c9dcf04 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:42:21 -0600 Subject: [PATCH 07/18] `azurerm_app_service_managed_certificate` - migrate to `go-azure-sdk` --- ...pp_service_managed_certificate_resource.go | 229 +++++++++--------- ...rvice_managed_certificate_resource_test.go | 165 +++++++++---- ...rvice_managed_certificate_create_poller.go | 42 ++++ .../services/web/parse/managed_certificate.go | 73 ------ .../web/parse/managed_certificate_test.go | 114 --------- .../web/validate/managed_certificate_id.go | 26 -- .../validate/managed_certificate_id_test.go | 78 ------ 7 files changed, 284 insertions(+), 443 deletions(-) create mode 100644 internal/services/web/custompollers/app_service_managed_certificate_create_poller.go delete mode 100644 internal/services/web/parse/managed_certificate.go delete mode 100644 internal/services/web/parse/managed_certificate_test.go delete mode 100644 internal/services/web/validate/managed_certificate_id.go delete mode 100644 internal/services/web/validate/managed_certificate_id_test.go diff --git a/internal/services/web/app_service_managed_certificate_resource.go b/internal/services/web/app_service_managed_certificate_resource.go index ba82257f9329..6ea787959821 100644 --- a/internal/services/web/app_service_managed_certificate_resource.go +++ b/internal/services/web/app_service_managed_certificate_resource.go @@ -5,32 +5,34 @@ package web import ( "fmt" - "log" + "net/http" "time" - "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/custompollers" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceAppServiceManagedCertificate() *pluginsdk.Resource { - return &pluginsdk.Resource{ - Create: resourceAppServiceManagedCertificateCreateUpdate, + r := &pluginsdk.Resource{ + Create: resourceAppServiceManagedCertificateCreate, Read: resourceAppServiceManagedCertificateRead, - Update: resourceAppServiceManagedCertificateCreateUpdate, + Update: resourceAppServiceManagedCertificateUpdate, Delete: resourceAppServiceManagedCertificateDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.ManagedCertificateID(id) + _, err := certificates.ParseCertificateID(id) return err }), @@ -46,7 +48,7 @@ func resourceAppServiceManagedCertificate() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.AppServiceCustomHostnameBindingID, + ValidateFunc: webapps.ValidateHostNameBindingID, }, "canonical_name": { @@ -95,168 +97,179 @@ func resourceAppServiceManagedCertificate() *pluginsdk.Resource { "tags": commonschema.Tags(), }, } + + if !features.FivePointOh() { + // Parse insensitively for 4.x matching existing behaviour, enforce casing in 5.0 + r.Schema["custom_hostname_binding_id"].ValidateFunc = func(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := webapps.ParseHostNameBindingIDInsensitively(v); err != nil { + errors = append(errors, err) + } + + return + } + } + + return r } -func resourceAppServiceManagedCertificateCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClientV1 - appServiceClient := meta.(*clients.Client).Web.AppServicesClientV1 - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) +func resourceAppServiceManagedCertificateCreate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Web.CertificatesClient + appServiceClient := meta.(*clients.Client).Web.WebAppsClient + subscriptionID := meta.(*clients.Client).Account.SubscriptionId + + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - customHostnameBindingId, err := parse.AppServiceCustomHostnameBindingID(d.Get("custom_hostname_binding_id").(string)) + chbID, err := webapps.ParseHostNameBindingID(d.Get("custom_hostname_binding_id").(string)) if err != nil { return err } - appService, err := appServiceClient.Get(ctx, customHostnameBindingId.ResourceGroup, customHostnameBindingId.AppServiceName) + appServiceID := commonids.NewAppServiceID(subscriptionID, chbID.ResourceGroupName, chbID.SiteName) + appService, err := appServiceClient.Get(ctx, appServiceID) if err != nil { - return fmt.Errorf("could not retrieve App Service Custom Hostname details for %q", customHostnameBindingId.Name) + return fmt.Errorf("retrieving %s: %w", appServiceID, err) } - name := customHostnameBindingId.Name - - if appService.SiteProperties == nil || appService.ServerFarmID == nil { - return fmt.Errorf("could not get App Service Plan ID for Custom Hostname Binding %q (resource group %q)", customHostnameBindingId.Name, customHostnameBindingId.ResourceGroup) + if appService.Model == nil || appService.Model.Properties == nil || appService.Model.Properties.ServerFarmId == nil { + return fmt.Errorf("retrieving `serverFarmId` from %s", appServiceID) } - appServicePlanIDRaw := *appService.ServerFarmID - appServicePlanID, err := commonids.ParseAppServicePlanIDInsensitively(appServicePlanIDRaw) + appServicePlanID, err := commonids.ParseAppServicePlanIDInsensitively(*appService.Model.Properties.ServerFarmId) if err != nil { return err } - appServiceLocation := "" - if appService.Location != nil { - appServiceLocation = location.Normalize(*appService.Location) - } - - t := d.Get("tags").(map[string]interface{}) - - id := parse.NewManagedCertificateID(subscriptionId, appServicePlanID.ResourceGroupName, name) + id := certificates.NewCertificateID(subscriptionID, appServicePlanID.ResourceGroupName, chbID.HostNameBindingName) - if d.IsNewResource() { - existing, err := client.Get(ctx, id.ResourceGroup, id.CertificateName) + existing, err := client.Get(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing App Service Certificate %q (Resource Group %q): %s", id.CertificateName, id.ResourceGroup, err) - } - } - - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_app_service_managed_certificate", id.ID()) + return fmt.Errorf("checking for presence of existing %s: %w", id, err) } + return tf.ImportAsExistsError("azurerm_app_service_managed_certificate", id.ID()) } - certificate := web.Certificate{ - CertificateProperties: &web.CertificateProperties{ - CanonicalName: pointer.To(customHostnameBindingId.Name), - ServerFarmID: pointer.To(appServicePlanIDRaw), + certificate := certificates.Certificate{ + Properties: &certificates.CertificateProperties{ + CanonicalName: pointer.To(chbID.HostNameBindingName), + ServerFarmId: pointer.To(appServicePlanID.ID()), Password: new(string), }, - Location: pointer.To(appServiceLocation), - Tags: tags.Expand(t), + Location: location.Normalize(appService.Model.Location), } - if resp, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.CertificateName, certificate); err != nil { - // API returns 202 where 200 is expected - https://github.com/Azure/azure-sdk-for-go/issues/13665 - if !utils.ResponseWasStatusCode(resp.Response, 202) { - return fmt.Errorf("creating/updating App Service Managed Certificate %q (Resource Group %q): %s", id.CertificateName, id.ResourceGroup, err) - } + resp, err := client.CreateOrUpdate(ctx, id, certificate) + if err != nil { + return fmt.Errorf("creating %s: %w", id, err) } - certificateWait := &pluginsdk.StateChangeConf{ - Pending: []string{"NotFound", "Unknown"}, - Target: []string{"Success"}, - MinTimeout: 1 * time.Minute, - Timeout: d.Timeout(pluginsdk.TimeoutCreate), - Refresh: func() (interface{}, string, error) { - resp, err := client.Get(ctx, id.ResourceGroup, id.CertificateName) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return "NotFound", "NotFound", nil - } - return "Unknown", "Unknown", err - } - if utils.ResponseWasStatusCode(resp.Response, 200) { - return "Success", "Success", nil - } - return "Unknown", "Unknown", err - }, + // API may return a 202, however, the Location header returned does not return a ProvisioningState when polled + // causing the provider to poll until timeout. + if response.WasStatusCode(resp.HttpResponse, http.StatusAccepted) { + poller := pollers.NewPoller(custompollers.NewAppServiceManagedCertificateCreatePoller(client, id), 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling %s: %w", id, err) + } } - if !d.IsNewResource() { - certificateWait.Timeout = d.Timeout(pluginsdk.TimeoutUpdate) - } + d.SetId(id.ID()) - if _, err := certificateWait.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for App Service Managed Certificate %q: %+v", id.CertificateName, err) + // An API issue prevents setting tags using the PUT operation, so we'll patch them in after + // https://github.com/Azure/azure-rest-api-specs/issues/14529 + tags := certificates.CertificatePatchResource{ + Tags: utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})), } - d.SetId(id.ID()) + if _, err := client.Update(ctx, id, tags); err != nil { + return fmt.Errorf("creating `tags` for %s: %w", id, err) + } return resourceAppServiceManagedCertificateRead(d, meta) } func resourceAppServiceManagedCertificateRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClientV1 + client := meta.(*clients.Client).Web.CertificatesClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ManagedCertificateID(d.Id()) + id, err := certificates.ParseCertificateID(d.Id()) if err != nil { return err } - resp, err := client.Get(ctx, id.ResourceGroup, id.CertificateName) + resp, err := client.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[DEBUG] App Service Managed Certificate %q (Resource Group %q) was not found - removing from state", id.CertificateName, id.ResourceGroup) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("making Read request on App Service Managed Certificate %q (Resource Group %q): %+v", id.CertificateName, id.ResourceGroup, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } - if props := resp.CertificateProperties; props != nil { - d.Set("canonical_name", props.CanonicalName) - d.Set("friendly_name", props.FriendlyName) - d.Set("subject_name", props.SubjectName) - d.Set("host_names", props.HostNames) - d.Set("issuer", props.Issuer) - issueDate := "" - if props.IssueDate != nil { - issueDate = props.IssueDate.Format(time.RFC3339) - } - d.Set("issue_date", issueDate) - expirationDate := "" - if props.ExpirationDate != nil { - expirationDate = props.ExpirationDate.Format(time.RFC3339) + if model := resp.Model; model != nil { + d.Set("tags", model.Tags) + if props := model.Properties; props != nil { + d.Set("canonical_name", props.CanonicalName) + d.Set("friendly_name", props.FriendlyName) + d.Set("subject_name", props.SubjectName) + d.Set("host_names", props.HostNames) + d.Set("issuer", props.Issuer) + d.Set("issue_date", props.IssueDate) + d.Set("expiration_date", props.ExpirationDate) + d.Set("thumbprint", props.Thumbprint) } - d.Set("expiration_date", expirationDate) - d.Set("thumbprint", props.Thumbprint) } - return tags.FlattenAndSet(d, resp.Tags) + return nil } -func resourceAppServiceManagedCertificateDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.CertificatesClientV1 - ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) +func resourceAppServiceManagedCertificateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Web.CertificatesClient + + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ManagedCertificateID(d.Id()) + id, err := certificates.ParseCertificateID(d.Id()) if err != nil { return err } - log.Printf("[DEBUG] Deleting App Service Certificate %q (Resource Group %q)", id.CertificateName, id.ResourceGroup) + if _, err := client.Get(ctx, *id); err != nil { + return fmt.Errorf("retrieving %s: %w", id, err) + } + + payload := certificates.CertificatePatchResource{ + Tags: utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})), + } + + if _, err := client.Update(ctx, *id, payload); err != nil { + return fmt.Errorf("updating %s: %w", id, err) + } + + return resourceAppServiceManagedCertificateRead(d, meta) +} + +func resourceAppServiceManagedCertificateDelete(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Web.CertificatesClient + + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() - resp, err := client.Delete(ctx, id.ResourceGroup, id.CertificateName) + id, err := certificates.ParseCertificateID(d.Id()) if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting App Service Certificate %q (Resource Group %q): %s)", id.CertificateName, id.ResourceGroup, err) - } + return err + } + + if _, err := client.Delete(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %w", id, err) } return nil diff --git a/internal/services/web/app_service_managed_certificate_resource_test.go b/internal/services/web/app_service_managed_certificate_resource_test.go index 7e17a783b5be..8e8ed0f4e810 100644 --- a/internal/services/web/app_service_managed_certificate_resource_test.go +++ b/internal/services/web/app_service_managed_certificate_resource_test.go @@ -10,12 +10,11 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" "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" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type AppServiceManagedCertificateResource struct{} @@ -59,6 +58,65 @@ func TestAccAppServiceManagedCertificate_requiresImport(t *testing.T) { }) } +func TestAccAppServiceManagedCertificate_completeLinux(t *testing.T) { + if os.Getenv("ARM_TEST_DNS_ZONE") == "" || os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") == "" { + t.Skip("Skipping as ARM_TEST_DNS_ZONE and/or ARM_TEST_DATA_RESOURCE_GROUP are not specified") + return + } + + data := acceptance.BuildTestData(t, "azurerm_app_service_managed_certificate", "test") + r := AppServiceManagedCertificateResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.completeLinux(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + }) +} + +func TestAccAppServiceManagedCertificate_updateLinux(t *testing.T) { + if os.Getenv("ARM_TEST_DNS_ZONE") == "" || os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") == "" { + t.Skip("Skipping as ARM_TEST_DNS_ZONE and/or ARM_TEST_DATA_RESOURCE_GROUP are not specified") + return + } + + data := acceptance.BuildTestData(t, "azurerm_app_service_managed_certificate", "test") + r := AppServiceManagedCertificateResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basicLinux(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.completeLinux(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.updateLinux(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.basicLinux(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + }) +} + func TestAccAppServiceManagedCertificate_basicWindows(t *testing.T) { if os.Getenv("ARM_TEST_DNS_ZONE") == "" || os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") == "" { t.Skip("Skipping as ARM_TEST_DNS_ZONE and/or ARM_TEST_DATA_RESOURCE_GROUP are not specified") @@ -79,59 +137,91 @@ func TestAccAppServiceManagedCertificate_basicWindows(t *testing.T) { } func (t AppServiceManagedCertificateResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.ManagedCertificateID(state.ID) + id, err := certificates.ParseCertificateID(state.ID) if err != nil { return nil, err } - resp, err := clients.Web.CertificatesClientV1.Get(ctx, id.ResourceGroup, id.CertificateName) + resp, err := clients.Web.CertificatesClient.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("App Service Managed Certificate %q (resource group %q) does not exist", id.CertificateName, id.ResourceGroup) + return nil, fmt.Errorf("retrieving %s: %w", id, err) } - return pointer.To(resp.CertificateProperties != nil), nil + return pointer.To(resp.Model != nil), nil } func (t AppServiceManagedCertificateResource) basicLinux(data acceptance.TestData) string { - template := t.linuxTemplate(data) return fmt.Sprintf(` %s resource "azurerm_app_service_managed_certificate" "test" { custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.test.id } -`, template) +`, t.linuxTemplate(data)) +} + +func (t AppServiceManagedCertificateResource) completeLinux(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_app_service_managed_certificate" "test" { + custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.test.id + + tags = { + hello = "world" + } +} +`, t.linuxTemplate(data)) +} + +func (t AppServiceManagedCertificateResource) updateLinux(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_app_service_managed_certificate" "test" { + custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.test.id + + tags = { + hello = "world" + foo = "bar" + } +} +`, t.linuxTemplate(data)) +} + +func (t AppServiceManagedCertificateResource) basicWindows(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_app_service_managed_certificate" "test" { + custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.test.id +} +`, t.windowsTemplate(data)) } func (t AppServiceManagedCertificateResource) requiresImport(data acceptance.TestData) string { - template := t.basicLinux(data) return fmt.Sprintf(` %s resource "azurerm_app_service_managed_certificate" "import" { custom_hostname_binding_id = azurerm_app_service_managed_certificate.test.custom_hostname_binding_id } -`, template) +`, t.basicLinux(data)) } func (AppServiceManagedCertificateResource) linuxTemplate(data acceptance.TestData) string { - dnsZone := os.Getenv("ARM_TEST_DNS_ZONE") - dataResourceGroup := os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") return fmt.Sprintf(` provider "azurerm" { features {} } resource "azurerm_resource_group" "test" { - name = "acctestRG-asmc-%d" - location = "%s" + name = "acctestRG-asmc-%[1]d" + location = "%[2]s" } resource "azurerm_app_service_plan" "test" { - name = "acctestASP-%d" + name = "acctestASP-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name kind = "Linux" @@ -145,7 +235,7 @@ resource "azurerm_app_service_plan" "test" { } resource "azurerm_app_service" "test" { - name = "acctest%s" + name = "acctest%[3]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name app_service_plan_id = azurerm_app_service_plan.test.id @@ -157,7 +247,7 @@ data "azurerm_dns_zone" "test" { } resource "azurerm_dns_cname_record" "test" { - name = "%s" + name = "%[3]s" zone_name = data.azurerm_dns_zone.test.name resource_group_name = data.azurerm_dns_zone.test.resource_group_name ttl = 300 @@ -165,7 +255,7 @@ resource "azurerm_dns_cname_record" "test" { } resource "azurerm_dns_txt_record" "test" { - name = join(".", ["asuid", "%s"]) + name = join(".", ["asuid", "%[3]s"]) zone_name = data.azurerm_dns_zone.test.name resource_group_name = data.azurerm_dns_zone.test.resource_group_name ttl = 300 @@ -180,35 +270,22 @@ resource "azurerm_app_service_custom_hostname_binding" "test" { app_service_name = azurerm_app_service.test.name resource_group_name = azurerm_resource_group.test.name } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString, dnsZone, dataResourceGroup, data.RandomString, data.RandomString) -} - -func (t AppServiceManagedCertificateResource) basicWindows(data acceptance.TestData) string { - template := t.windowsTemplate(data) - return fmt.Sprintf(` -%s - -resource "azurerm_app_service_managed_certificate" "test" { - custom_hostname_binding_id = azurerm_app_service_custom_hostname_binding.test.id -} -`, template) +`, data.RandomInteger, data.Locations.Primary, data.RandomString, os.Getenv("ARM_TEST_DNS_ZONE"), os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP")) } func (AppServiceManagedCertificateResource) windowsTemplate(data acceptance.TestData) string { - dnsZone := os.Getenv("ARM_TEST_DNS_ZONE") - dataResourceGroup := os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") return fmt.Sprintf(` provider "azurerm" { features {} } resource "azurerm_resource_group" "test" { - name = "acctestRG-asmc-%d" - location = "%s" + name = "acctestRG-asmc-%[1]d" + location = "%[2]s" } resource "azurerm_app_service_plan" "test" { - name = "acctestASP-%d" + name = "acctestASP-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -219,19 +296,19 @@ resource "azurerm_app_service_plan" "test" { } resource "azurerm_app_service" "test" { - name = "acctest%s" + name = "acctest%[3]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name app_service_plan_id = azurerm_app_service_plan.test.id } data "azurerm_dns_zone" "test" { - name = "%s" - resource_group_name = "%s" + name = "%[4]s" + resource_group_name = "%[5]s" } resource "azurerm_dns_cname_record" "test" { - name = "%s" + name = "%[3]s" zone_name = data.azurerm_dns_zone.test.name resource_group_name = data.azurerm_dns_zone.test.resource_group_name ttl = 300 @@ -239,7 +316,7 @@ resource "azurerm_dns_cname_record" "test" { } resource "azurerm_dns_txt_record" "test" { - name = join(".", ["asuid", "%s"]) + name = join(".", ["asuid", "%[3]s"]) zone_name = data.azurerm_dns_zone.test.name resource_group_name = data.azurerm_dns_zone.test.resource_group_name ttl = 300 @@ -254,5 +331,5 @@ resource "azurerm_app_service_custom_hostname_binding" "test" { app_service_name = azurerm_app_service.test.name resource_group_name = azurerm_resource_group.test.name } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString, dnsZone, dataResourceGroup, data.RandomString, data.RandomString) +`, data.RandomInteger, data.Locations.Primary, data.RandomString, os.Getenv("ARM_TEST_DNS_ZONE"), os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP")) } diff --git a/internal/services/web/custompollers/app_service_managed_certificate_create_poller.go b/internal/services/web/custompollers/app_service_managed_certificate_create_poller.go new file mode 100644 index 000000000000..e55eb9ee1e15 --- /dev/null +++ b/internal/services/web/custompollers/app_service_managed_certificate_create_poller.go @@ -0,0 +1,42 @@ +package custompollers + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" +) + +var _ pollers.PollerType = &AppServiceManagedCertificateCreatePoller{} + +type AppServiceManagedCertificateCreatePoller struct { + client *certificates.CertificatesClient + id certificates.CertificateId +} + +func NewAppServiceManagedCertificateCreatePoller(client *certificates.CertificatesClient, id certificates.CertificateId) AppServiceManagedCertificateCreatePoller { + return AppServiceManagedCertificateCreatePoller{ + client: client, + id: id, + } +} + +func (p AppServiceManagedCertificateCreatePoller) Poll(ctx context.Context) (*pollers.PollResult, error) { + resp, err := p.client.Get(ctx, p.id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return &pollers.PollResult{ + Status: pollers.PollingStatusInProgress, + PollInterval: 10 * time.Second, + }, nil + } + return nil, fmt.Errorf("retrieving %s: %w", p.id, err) + } + + return &pollers.PollResult{ + Status: pollers.PollingStatusSucceeded, + }, nil +} diff --git a/internal/services/web/parse/managed_certificate.go b/internal/services/web/parse/managed_certificate.go deleted file mode 100644 index c01e117b576c..000000000000 --- a/internal/services/web/parse/managed_certificate.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ManagedCertificateId struct { - SubscriptionId string - ResourceGroup string - CertificateName string -} - -func NewManagedCertificateID(subscriptionId, resourceGroup, certificateName string) ManagedCertificateId { - return ManagedCertificateId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - CertificateName: certificateName, - } -} - -func (id ManagedCertificateId) String() string { - segments := []string{ - fmt.Sprintf("Certificate Name %q", id.CertificateName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Managed Certificate", segmentsStr) -} - -func (id ManagedCertificateId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/certificates/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.CertificateName) -} - -// ManagedCertificateID parses a ManagedCertificate ID into an ManagedCertificateId struct -func ManagedCertificateID(input string) (*ManagedCertificateId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ManagedCertificate ID: %+v", input, err) - } - - resourceId := ManagedCertificateId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.CertificateName, err = id.PopSegment("certificates"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/web/parse/managed_certificate_test.go b/internal/services/web/parse/managed_certificate_test.go deleted file mode 100644 index 8360a36d6dfc..000000000000 --- a/internal/services/web/parse/managed_certificate_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ManagedCertificateId{} - -func TestManagedCertificateIDFormatter(t *testing.T) { - actual := NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "resGroup1", "customhost.contoso.com").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/customhost.contoso.com" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestManagedCertificateID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ManagedCertificateId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing CertificateName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Error: true, - }, - - { - // missing value for CertificateName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/customhost.contoso.com", - Expected: &ManagedCertificateId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - CertificateName: "customhost.contoso.com", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/CERTIFICATES/CUSTOMHOST.CONTOSO.COM", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ManagedCertificateID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.CertificateName != v.Expected.CertificateName { - t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) - } - } -} diff --git a/internal/services/web/validate/managed_certificate_id.go b/internal/services/web/validate/managed_certificate_id.go deleted file mode 100644 index 74436f703f3a..000000000000 --- a/internal/services/web/validate/managed_certificate_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" -) - -func ManagedCertificateID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ManagedCertificateID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/web/validate/managed_certificate_id_test.go b/internal/services/web/validate/managed_certificate_id_test.go deleted file mode 100644 index 4304f79ec576..000000000000 --- a/internal/services/web/validate/managed_certificate_id_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestManagedCertificateID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing CertificateName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Valid: false, - }, - - { - // missing value for CertificateName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/customhost.contoso.com", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/CERTIFICATES/CUSTOMHOST.CONTOSO.COM", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ManagedCertificateID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} From 98dc511d7c25b79a582694f9c52f65df95badc0b Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:43:16 -0600 Subject: [PATCH 08/18] `azurerm_app_service_slot_custom_hostname_binding` - migrate to `go-azure-sdk` --- ...e_slot_custom_hostname_binding_resource.go | 85 +++++----- ...t_custom_hostname_binding_resource_test.go | 12 +- ...pp_service_slot_custom_hostname_binding.go | 85 ---------- ...rvice_slot_custom_hostname_binding_test.go | 146 ------------------ ...service_slot_custom_hostname_binding_id.go | 26 ---- ...ce_slot_custom_hostname_binding_id_test.go | 102 ------------ 6 files changed, 40 insertions(+), 416 deletions(-) delete mode 100644 internal/services/web/parse/app_service_slot_custom_hostname_binding.go delete mode 100644 internal/services/web/parse/app_service_slot_custom_hostname_binding_test.go delete mode 100644 internal/services/web/validate/app_service_slot_custom_hostname_binding_id.go delete mode 100644 internal/services/web/validate/app_service_slot_custom_hostname_binding_id_test.go diff --git a/internal/services/web/app_service_slot_custom_hostname_binding_resource.go b/internal/services/web/app_service_slot_custom_hostname_binding_resource.go index 506534c00f7d..722292d87aa3 100644 --- a/internal/services/web/app_service_slot_custom_hostname_binding_resource.go +++ b/internal/services/web/app_service_slot_custom_hostname_binding_resource.go @@ -5,23 +5,20 @@ package web import ( "fmt" - "log" "time" - "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) -var appServiceSlotCustomHostnameBindingResourceName = "azurerm_app_service_slot_custom_hostname_binding" +const appServiceSlotCustomHostnameBindingResourceName = "azurerm_app_service_slot_custom_hostname_binding" func resourceAppServiceSlotCustomHostnameBinding() *pluginsdk.Resource { return &pluginsdk.Resource{ @@ -29,7 +26,7 @@ func resourceAppServiceSlotCustomHostnameBinding() *pluginsdk.Resource { Read: resourceAppServiceSlotCustomHostnameBindingRead, Delete: resourceAppServiceSlotCustomHostnameBindingDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.AppServiceSlotCustomHostnameBindingID(id) + _, err := webapps.ParseSlotHostNameBindingID(id) return err }), @@ -44,7 +41,7 @@ func resourceAppServiceSlotCustomHostnameBinding() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.AppServiceSlotID, + ValidateFunc: webapps.ValidateSlotID, }, "hostname": { @@ -59,8 +56,8 @@ func resourceAppServiceSlotCustomHostnameBinding() *pluginsdk.Resource { Computed: true, ForceNew: true, ValidateFunc: validation.StringInSlice([]string{ - string(web.SslStateIPBasedEnabled), - string(web.SslStateSniEnabled), + string(webapps.SslStateIPBasedEnabled), + string(webapps.SslStateSniEnabled), }, false), }, @@ -81,52 +78,47 @@ func resourceAppServiceSlotCustomHostnameBinding() *pluginsdk.Resource { } func resourceAppServiceSlotCustomHostnameBindingCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - log.Printf("[INFO] preparing arguments for App Service Slot Hostname Binding creation.") - - slotId, err := parse.AppServiceSlotID(d.Get("app_service_slot_id").(string)) + slotId, err := webapps.ParseSlotID(d.Get("app_service_slot_id").(string)) if err != nil { return err } - hostname := d.Get("hostname").(string) sslState := d.Get("ssl_state").(string) thumbprint := d.Get("thumbprint").(string) - id := parse.NewAppServiceSlotCustomHostnameBindingID(slotId.SubscriptionId, slotId.ResourceGroup, slotId.SiteName, slotId.SlotName, hostname) + id := webapps.NewSlotHostNameBindingID(slotId.SubscriptionId, slotId.ResourceGroupName, slotId.SiteName, slotId.SlotName, d.Get("hostname").(string)) - locks.ByName(hostname, appServiceSlotCustomHostnameBindingResourceName) - defer locks.UnlockByName(hostname, appServiceSlotCustomHostnameBindingResourceName) + locks.ByName(id.HostNameBindingName, appServiceSlotCustomHostnameBindingResourceName) + defer locks.UnlockByName(id.HostNameBindingName, appServiceSlotCustomHostnameBindingResourceName) - existing, err := client.GetHostNameBindingSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName, id.HostNameBindingName) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { + existing, err := client.GetHostNameBindingSlot(ctx, id) + if !response.WasNotFound(existing.HttpResponse) { + if err != nil { return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } - } - - if !utils.ResponseWasNotFound(existing.Response) { return tf.ImportAsExistsError("azurerm_app_service_slot_custom_hostname_binding", id.ID()) } - properties := web.HostNameBinding{ - HostNameBindingProperties: &web.HostNameBindingProperties{ + payload := webapps.HostNameBinding{ + Properties: &webapps.HostNameBindingProperties{ SiteName: pointer.To(id.SiteName), }, } if sslState != "" { - properties.SslState = web.SslState(sslState) + payload.Properties.SslState = pointer.ToEnum[webapps.SslState](sslState) } if thumbprint != "" { - properties.Thumbprint = pointer.To(thumbprint) + payload.Properties.Thumbprint = pointer.To(thumbprint) } - if _, err := client.CreateOrUpdateHostNameBindingSlot(ctx, id.ResourceGroup, id.SiteName, id.HostNameBindingName, properties, id.SlotName); err != nil { + if _, err := client.CreateOrUpdateHostNameBindingSlot(ctx, id, payload); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } @@ -136,44 +128,44 @@ func resourceAppServiceSlotCustomHostnameBindingCreate(d *pluginsdk.ResourceData } func resourceAppServiceSlotCustomHostnameBindingRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.AppServiceSlotCustomHostnameBindingID(d.Id()) + id, err := webapps.ParseSlotHostNameBindingID(d.Id()) if err != nil { return err } - resp, err := client.GetHostNameBindingSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName, id.HostNameBindingName) + resp, err := client.GetHostNameBindingSlot(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - log.Printf("[DEBUG] %s was not found - removing from state", id) + if response.WasNotFound(resp.HttpResponse) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", *id, err) } - slotId := parse.NewAppServiceSlotID(id.SubscriptionId, id.ResourceGroup, id.SiteName, id.SlotName) - d.Set("app_service_slot_id", slotId.ID()) + d.Set("app_service_slot_id", webapps.NewSlotID(id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName).ID()) d.Set("hostname", id.HostNameBindingName) - if props := resp.HostNameBindingProperties; props != nil { - d.Set("ssl_state", string(props.SslState)) - d.Set("thumbprint", props.Thumbprint) - d.Set("virtual_ip", props.VirtualIP) + if resp.Model != nil { + if props := resp.Model.Properties; props != nil { + d.Set("ssl_state", pointer.FromEnum(props.SslState)) + d.Set("thumbprint", props.Thumbprint) + d.Set("virtual_ip", props.VirtualIP) + } } return nil } func resourceAppServiceSlotCustomHostnameBindingDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.AppServiceSlotCustomHostnameBindingID(d.Id()) + id, err := webapps.ParseSlotHostNameBindingID(d.Id()) if err != nil { return err } @@ -181,13 +173,8 @@ func resourceAppServiceSlotCustomHostnameBindingDelete(d *pluginsdk.ResourceData locks.ByName(id.HostNameBindingName, appServiceSlotCustomHostnameBindingResourceName) defer locks.UnlockByName(id.HostNameBindingName, appServiceSlotCustomHostnameBindingResourceName) - log.Printf("[DEBUG] deleting %s", id) - - resp, err := client.DeleteHostNameBindingSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName, id.HostNameBindingName) - if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting %s: %+v", *id, err) - } + if _, err := client.DeleteHostNameBindingSlot(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) } return nil diff --git a/internal/services/web/app_service_slot_custom_hostname_binding_resource_test.go b/internal/services/web/app_service_slot_custom_hostname_binding_resource_test.go index 715f2cbb45ea..2109d797f689 100644 --- a/internal/services/web/app_service_slot_custom_hostname_binding_resource_test.go +++ b/internal/services/web/app_service_slot_custom_hostname_binding_resource_test.go @@ -10,12 +10,11 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" "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" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type AppServiceSlotCustomHostnameBindingResource struct{} @@ -78,20 +77,17 @@ func TestAccAppServiceSlotCustomHostnameBinding_ssl(t *testing.T) { } func (r AppServiceSlotCustomHostnameBindingResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.AppServiceSlotCustomHostnameBindingID(state.ID) + id, err := webapps.ParseSlotHostNameBindingID(state.ID) if err != nil { return nil, err } - resp, err := clients.Web.AppServicesClientV1.GetHostNameBindingSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName, id.HostNameBindingName) + resp, err := clients.Web.WebAppsClient.GetHostNameBindingSlot(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } return nil, fmt.Errorf("retrieving %s: %+v", *id, err) } - return pointer.To(resp.HostNameBindingProperties != nil), nil + return pointer.To(resp.Model != nil), nil } func (AppServiceSlotCustomHostnameBindingResource) basicConfig(data acceptance.TestData) string { diff --git a/internal/services/web/parse/app_service_slot_custom_hostname_binding.go b/internal/services/web/parse/app_service_slot_custom_hostname_binding.go deleted file mode 100644 index d498f8a567f1..000000000000 --- a/internal/services/web/parse/app_service_slot_custom_hostname_binding.go +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type AppServiceSlotCustomHostnameBindingId struct { - SubscriptionId string - ResourceGroup string - SiteName string - SlotName string - HostNameBindingName string -} - -func NewAppServiceSlotCustomHostnameBindingID(subscriptionId, resourceGroup, siteName, slotName, hostNameBindingName string) AppServiceSlotCustomHostnameBindingId { - return AppServiceSlotCustomHostnameBindingId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - SiteName: siteName, - SlotName: slotName, - HostNameBindingName: hostNameBindingName, - } -} - -func (id AppServiceSlotCustomHostnameBindingId) String() string { - segments := []string{ - fmt.Sprintf("Host Name Binding Name %q", id.HostNameBindingName), - fmt.Sprintf("Slot Name %q", id.SlotName), - fmt.Sprintf("Site Name %q", id.SiteName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "App Service Slot Custom Hostname Binding", segmentsStr) -} - -func (id AppServiceSlotCustomHostnameBindingId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/hostNameBindings/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.SiteName, id.SlotName, id.HostNameBindingName) -} - -// AppServiceSlotCustomHostnameBindingID parses a AppServiceSlotCustomHostnameBinding ID into an AppServiceSlotCustomHostnameBindingId struct -func AppServiceSlotCustomHostnameBindingID(input string) (*AppServiceSlotCustomHostnameBindingId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an AppServiceSlotCustomHostnameBinding ID: %+v", input, err) - } - - resourceId := AppServiceSlotCustomHostnameBindingId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.SiteName, err = id.PopSegment("sites"); err != nil { - return nil, err - } - if resourceId.SlotName, err = id.PopSegment("slots"); err != nil { - return nil, err - } - if resourceId.HostNameBindingName, err = id.PopSegment("hostNameBindings"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/web/parse/app_service_slot_custom_hostname_binding_test.go b/internal/services/web/parse/app_service_slot_custom_hostname_binding_test.go deleted file mode 100644 index ac34f57f1b87..000000000000 --- a/internal/services/web/parse/app_service_slot_custom_hostname_binding_test.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = AppServiceSlotCustomHostnameBindingId{} - -func TestAppServiceSlotCustomHostnameBindingIDFormatter(t *testing.T) { - actual := NewAppServiceSlotCustomHostnameBindingID("12345678-1234-9876-4563-123456789012", "resGroup1", "site1", "slot1", "binding1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1/hostNameBindings/binding1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestAppServiceSlotCustomHostnameBindingID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AppServiceSlotCustomHostnameBindingId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Error: true, - }, - - { - // missing value for SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/", - Error: true, - }, - - { - // missing SlotName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/", - Error: true, - }, - - { - // missing value for SlotName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/", - Error: true, - }, - - { - // missing HostNameBindingName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1/", - Error: true, - }, - - { - // missing value for HostNameBindingName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1/hostNameBindings/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1/hostNameBindings/binding1", - Expected: &AppServiceSlotCustomHostnameBindingId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - SiteName: "site1", - SlotName: "slot1", - HostNameBindingName: "binding1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/SITES/SITE1/SLOTS/SLOT1/HOSTNAMEBINDINGS/BINDING1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := AppServiceSlotCustomHostnameBindingID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.SiteName != v.Expected.SiteName { - t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) - } - if actual.SlotName != v.Expected.SlotName { - t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) - } - if actual.HostNameBindingName != v.Expected.HostNameBindingName { - t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) - } - } -} diff --git a/internal/services/web/validate/app_service_slot_custom_hostname_binding_id.go b/internal/services/web/validate/app_service_slot_custom_hostname_binding_id.go deleted file mode 100644 index 3c23f5f80a34..000000000000 --- a/internal/services/web/validate/app_service_slot_custom_hostname_binding_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" -) - -func AppServiceSlotCustomHostnameBindingID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.AppServiceSlotCustomHostnameBindingID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/web/validate/app_service_slot_custom_hostname_binding_id_test.go b/internal/services/web/validate/app_service_slot_custom_hostname_binding_id_test.go deleted file mode 100644 index c00fd972e622..000000000000 --- a/internal/services/web/validate/app_service_slot_custom_hostname_binding_id_test.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestAppServiceSlotCustomHostnameBindingID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Valid: false, - }, - - { - // missing value for SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/", - Valid: false, - }, - - { - // missing SlotName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/", - Valid: false, - }, - - { - // missing value for SlotName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/", - Valid: false, - }, - - { - // missing HostNameBindingName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1/", - Valid: false, - }, - - { - // missing value for HostNameBindingName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1/hostNameBindings/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1/hostNameBindings/binding1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/SITES/SITE1/SLOTS/SLOT1/HOSTNAMEBINDINGS/BINDING1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := AppServiceSlotCustomHostnameBindingID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} From 32a6197df3ba029f42588438a52db90c8591a367 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:43:55 -0600 Subject: [PATCH 09/18] `azurerm_app_service_slot_virtual_network_swift_connection` - migrate to `go-azure-sdk` --- ...rk_and_subnet_provisioning_state_poller.go | 62 +++++ ...rtual_network_swift_connection_resource.go | 247 +++++++++--------- ..._network_swift_connection_resource_test.go | 45 ++-- 3 files changed, 210 insertions(+), 144 deletions(-) create mode 100644 internal/services/network/custompollers/virtual_network_and_subnet_provisioning_state_poller.go diff --git a/internal/services/network/custompollers/virtual_network_and_subnet_provisioning_state_poller.go b/internal/services/network/custompollers/virtual_network_and_subnet_provisioning_state_poller.go new file mode 100644 index 000000000000..7ffb7e28799f --- /dev/null +++ b/internal/services/network/custompollers/virtual_network_and_subnet_provisioning_state_poller.go @@ -0,0 +1,62 @@ +package custompollers + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/subnets" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/virtualnetworks" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + network "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/client" +) + +var _ pollers.PollerType = &virtualNetworkAndSubnetProvisioningSucceededPoller{} + +type virtualNetworkAndSubnetProvisioningSucceededPoller struct { + client *network.Client + id *commonids.SubnetId +} + +func NewVirtualNetworkAndSubnetProvisioningSucceededPoller(client *network.Client, id *commonids.SubnetId) pollers.PollerType { + return &virtualNetworkAndSubnetProvisioningSucceededPoller{ + client: client, + id: id, + } +} + +func (v virtualNetworkAndSubnetProvisioningSucceededPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { + pr := &pollers.PollResult{ + PollInterval: 10 * time.Second, + Status: pollers.PollingStatusInProgress, + } + + subnetResp, err := v.client.Subnets.Get(ctx, *v.id, subnets.DefaultGetOperationOptions()) + if err != nil { + return nil, fmt.Errorf("retrieving %s: %w", v.id, err) + } + + if subnetResp.Model == nil || subnetResp.Model.Properties == nil || subnetResp.Model.Properties.ProvisioningState == nil { + return nil, fmt.Errorf("retrieving %s: unable to determine provisioningState", v.id) + } + subnetDone := *subnetResp.Model.Properties.ProvisioningState == subnets.ProvisioningStateSucceeded + + vnetID := commonids.NewVirtualNetworkID(v.id.SubscriptionId, v.id.ResourceGroupName, v.id.VirtualNetworkName) + vnetResp, err := v.client.VirtualNetworks.Get(ctx, vnetID, virtualnetworks.DefaultGetOperationOptions()) + if err != nil { + return nil, fmt.Errorf("retrieving %s: %w", v.id, err) + } + + if vnetResp.Model == nil || vnetResp.Model.Properties == nil || vnetResp.Model.Properties.ProvisioningState == nil { + return nil, fmt.Errorf("retrieving %s: unable to determine provisioningState", vnetID) + } + vnetDone := *vnetResp.Model.Properties.ProvisioningState == virtualnetworks.ProvisioningStateSucceeded + + if subnetDone && vnetDone { + pr.Status = pollers.PollingStatusSucceeded + return pr, nil + } + + return pr, nil +} diff --git a/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go b/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go index b4cc0b4b072e..7ca3b6b6bc39 100644 --- a/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go +++ b/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go @@ -7,26 +7,27 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" - "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/subnets" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network" + networkpoller "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/custompollers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceAppServiceSlotVirtualNetworkSwiftConnection() *pluginsdk.Resource { return &pluginsdk.Resource{ - Create: resourceAppServiceSlotVirtualNetworkSwiftConnectionCreateUpdate, + Create: resourceAppServiceSlotVirtualNetworkSwiftConnectionCreate, Read: resourceAppServiceSlotVirtualNetworkSwiftConnectionRead, - Update: resourceAppServiceSlotVirtualNetworkSwiftConnectionCreateUpdate, + Update: resourceAppServiceSlotVirtualNetworkSwiftConnectionUpdate, Delete: resourceAppServiceSlotVirtualNetworkSwiftConnectionDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { @@ -46,7 +47,7 @@ func resourceAppServiceSlotVirtualNetworkSwiftConnection() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.AppServiceID, + ValidateFunc: commonids.ValidateAppServiceID, }, "subnet_id": { Type: pluginsdk.TypeString, @@ -63,103 +64,73 @@ func resourceAppServiceSlotVirtualNetworkSwiftConnection() *pluginsdk.Resource { } } -func resourceAppServiceSlotVirtualNetworkSwiftConnectionCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 - subnetClient := meta.(*clients.Client).Network.Subnets - vnetClient := meta.(*clients.Client).Network.VirtualNetworks +func resourceAppServiceSlotVirtualNetworkSwiftConnectionCreate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - appID, err := parse.AppServiceID(d.Get("app_service_id").(string)) + appID, err := commonids.ParseAppServiceID(d.Get("app_service_id").(string)) if err != nil { - return fmt.Errorf("parsing app service ID %+v", err) + return err } + subnetID, err := commonids.ParseSubnetID(d.Get("subnet_id").(string)) if err != nil { return fmt.Errorf("parsing subnet ID %+v", err) } - resourceGroup := appID.ResourceGroup - name := appID.SiteName - subnetName := subnetID.SubnetName - virtualNetworkName := subnetID.VirtualNetworkName - slotName := d.Get("slot_name").(string) - - if d.IsNewResource() { - existing, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, resourceGroup, name, slotName) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("failed checking for presence of existing App Service Slot Swift Network Connection %q (Resource Group %q)", name, resourceGroup) - } - } + appSlotID := webapps.NewSlotID(appID.SubscriptionId, appID.ResourceGroupName, appID.SiteName, d.Get("slot_name").(string)) - if existing.SwiftVirtualNetworkProperties != nil && existing.SubnetResourceID != nil && *existing.SubnetResourceID != "" { - return tf.ImportAsExistsError("azurerm_app_service_slot_virtual_network_swift_connection", *existing.ID) - } + existing, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, appSlotID) + if err != nil { + return fmt.Errorf("checking for presence of Swift Network Connection for %s: %w", appSlotID, err) } - locks.ByName(virtualNetworkName, network.VirtualNetworkResourceName) - defer locks.UnlockByName(virtualNetworkName, network.VirtualNetworkResourceName) - - locks.ByName(subnetName, network.SubnetResourceName) - defer locks.UnlockByName(subnetName, network.SubnetResourceName) + if existing.Model != nil && existing.Model.Properties != nil && pointer.From(existing.Model.Properties.SubnetResourceId) != "" { + return tf.ImportAsExistsError("azurerm_app_service_slot_virtual_network_swift_connection", pointer.From(existing.Model.Id)) + } - appServiceExists, err := client.Get(ctx, resourceGroup, name) - if err != nil { - if utils.ResponseWasNotFound(appServiceExists.Response) { - return fmt.Errorf("retrieving existing App Service %q (Resource Group %q): App Service not found in resource group", name, resourceGroup) - } - return fmt.Errorf("retrieving existing App Service %q (Resource Group %q): %s", name, resourceGroup, err) + if _, err := client.Get(ctx, *appID); err != nil { + return fmt.Errorf("retrieving %s: %w", appID, err) } - slotExists, err := client.GetSlot(ctx, resourceGroup, name, slotName) - if err != nil { - if utils.ResponseWasNotFound(slotExists.Response) { - return fmt.Errorf("retrieving existing App Service Slot %q (App Service %q / Resource Group %q): App Service not found in resource group", slotName, name, resourceGroup) - } - return fmt.Errorf("retrieving existing App Service Slot %q (App Service %q / Resource Group %q): %s", slotName, name, resourceGroup, err) + if _, err := client.GetSlot(ctx, appSlotID); err != nil { + return fmt.Errorf("retrieving %s: %w", appSlotID, err) } - connectionEnvelope := web.SwiftVirtualNetwork{ - SwiftVirtualNetworkProperties: &web.SwiftVirtualNetworkProperties{ - SubnetResourceID: pointer.To(d.Get("subnet_id").(string)), + connectionEnvelope := webapps.SwiftVirtualNetwork{ + Properties: &webapps.SwiftVirtualNetworkProperties{ + SubnetResourceId: pointer.To(subnetID.ID()), }, } - if _, err = client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, resourceGroup, name, connectionEnvelope, slotName); err != nil { - return fmt.Errorf("creating/updating App Service Slot VNet association between %q (App Service %q / Resource Group %q) and Virtual Network %q: %s", slotName, name, resourceGroup, virtualNetworkName, err) - } - timeout, _ := ctx.Deadline() + locks.ByName(subnetID.VirtualNetworkName, network.VirtualNetworkResourceName) + defer locks.UnlockByName(subnetID.VirtualNetworkName, network.VirtualNetworkResourceName) - stateConf := &pluginsdk.StateChangeConf{ - Pending: []string{string(subnets.ProvisioningStateUpdating)}, - Target: []string{string(subnets.ProvisioningStateSucceeded)}, - Refresh: network.SubnetProvisioningStateRefreshFunc(ctx, subnetClient, *subnetID), - MinTimeout: 1 * time.Minute, - Timeout: time.Until(timeout), - } - if _, err = stateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for provisioning state of subnet for App Service Slot VNet association between %q (App Service %q / Resource Group %q) and Virtual Network %q: %s", slotName, name, resourceGroup, virtualNetworkName, err) - } + locks.ByName(subnetID.SubnetName, network.SubnetResourceName) + defer locks.UnlockByName(subnetID.SubnetName, network.SubnetResourceName) - vnetId := commonids.NewVirtualNetworkID(subnetID.SubscriptionId, subnetID.ResourceGroupName, subnetID.VirtualNetworkName) - vnetStateConf := &pluginsdk.StateChangeConf{ - Pending: []string{string(subnets.ProvisioningStateUpdating)}, - Target: []string{string(subnets.ProvisioningStateSucceeded)}, - Refresh: network.VirtualNetworkProvisioningStateRefreshFunc(ctx, vnetClient, vnetId), - MinTimeout: 1 * time.Minute, - Timeout: time.Until(timeout), + if _, err = client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, appSlotID, connectionEnvelope); err != nil { + return fmt.Errorf("creating association between %s and %s: %w", appSlotID, subnetID, err) } - if _, err = vnetStateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for provisioning state of virtual network for App Service Slot VNet association between %q (App Service %q / Resource Group %q) and Virtual Network %q: %s", slotName, name, resourceGroup, virtualNetworkName, err) + + pollerType := networkpoller.NewVirtualNetworkAndSubnetProvisioningSucceededPoller(meta.(*clients.Client).Network, subnetID) + poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling for completion of association between %s and %s: %w", appSlotID, subnetID, err) } - read, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, resourceGroup, name, slotName) + read, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, appSlotID) if err != nil { - return fmt.Errorf("retrieving App Service Slot VNet association between %q (App Service %q / Resource Group %q) and Virtual Network %q: %s", slotName, name, resourceGroup, virtualNetworkName, err) + return fmt.Errorf("retrieving Swift Network Connection for %s: %w", appSlotID, err) + } + + if read.Model == nil || read.Model.Id == nil { + return fmt.Errorf("retrieving Swift Network Connection for %s: missing ID", appSlotID) } - slotSwiftVirtualNetworkId, err := parse.SlotVirtualNetworkSwiftConnectionID(*read.ID) + slotSwiftVirtualNetworkId, err := parse.SlotVirtualNetworkSwiftConnectionID(*read.Model.Id) if err != nil { return err } @@ -170,7 +141,8 @@ func resourceAppServiceSlotVirtualNetworkSwiftConnectionCreateUpdate(d *pluginsd } func resourceAppServiceSlotVirtualNetworkSwiftConnectionRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -179,48 +151,83 @@ func resourceAppServiceSlotVirtualNetworkSwiftConnectionRead(d *pluginsdk.Resour return err } - slot, err := client.GetSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) + appSlotID := webapps.NewSlotID(id.SubscriptionId, id.ResourceGroup, id.SiteName, id.SlotName) + + appID := commonids.NewAppServiceID(id.SubscriptionId, id.ResourceGroup, id.SiteName) + + existing, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, appSlotID) if err != nil { - if utils.ResponseWasNotFound(slot.Response) { + if response.WasNotFound(existing.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("retrieving existing App Service Slot %q (App Service %q / Resource Group %q): %s", id.SlotName, id.SiteName, id.ResourceGroup, err) + return fmt.Errorf("retrieving Swift Network Connection for %s: %w", appSlotID, err) } - appService, err := client.Get(ctx, id.ResourceGroup, id.SiteName) + + if existing.Model == nil || existing.Model.Properties == nil || existing.Model.Properties.SubnetResourceId == nil { + d.SetId("") + return nil + } + + subnetID, err := commonids.ParseSubnetID(*existing.Model.Properties.SubnetResourceId) if err != nil { - if utils.ResponseWasNotFound(appService.Response) { - d.SetId("") - return nil - } - return fmt.Errorf("retrieving existing App Service %q (Resource Group %q): %s", id.SiteName, id.ResourceGroup, err) + return err } - swiftVnet, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) + + d.Set("subnet_id", subnetID.ID()) + d.Set("app_service_id", appID.ID()) + d.Set("slot_name", id.SlotName) + + return nil +} + +func resourceAppServiceSlotVirtualNetworkSwiftConnectionUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Web.WebAppsClient + + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.SlotVirtualNetworkSwiftConnectionID(d.Id()) if err != nil { - if utils.ResponseWasNotFound(swiftVnet.Response) { - d.SetId("") - return nil - } - return fmt.Errorf("retrieving App Service Slot VNet association for %q (App Service %q / Resource Group %q): %s", id.SlotName, id.SiteName, id.ResourceGroup, err) + return err + } + + appSlotID := webapps.NewSlotID(id.SubscriptionId, id.ResourceGroup, id.SiteName, id.SlotName) + + existing, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, appSlotID) + if err != nil { + return fmt.Errorf("retrieving Swift Network Connection for %s: %w", appSlotID, err) } - if swiftVnet.SwiftVirtualNetworkProperties == nil { - return fmt.Errorf("retrieving virtual network properties (Slot Name %q / App Service %q / Resource Group %q): `properties` was nil", id.SlotName, id.SiteName, id.ResourceGroup) + if existing.Model == nil { + return fmt.Errorf("retrieving Swift Network Connection for %s: model was nil", appSlotID) } - props := *swiftVnet.SwiftVirtualNetworkProperties - subnetID := props.SubnetResourceID - if subnetID == nil || *subnetID == "" { - d.SetId("") - return nil + + if existing.Model.Properties == nil { + return fmt.Errorf("retrieving Swift Network Connection for %s: properties was nil", appSlotID) } - d.Set("subnet_id", subnetID) - d.Set("app_service_id", appService.ID) - d.Set("slot_name", id.SlotName) - return nil + + subnetID, err := commonids.ParseSubnetID(d.Get("subnet_id").(string)) + if err != nil { + return err + } + existing.Model.Properties.SubnetResourceId = pointer.To(subnetID.ID()) + + if _, err = client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, appSlotID, *existing.Model); err != nil { + return fmt.Errorf("updating association between %s and %s: %w", appSlotID, subnetID, err) + } + + pollerType := networkpoller.NewVirtualNetworkAndSubnetProvisioningSucceededPoller(meta.(*clients.Client).Network, subnetID) + poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling for completion of association between %s and %s: %w", appSlotID, subnetID, err) + } + + return resourceAppServiceSlotVirtualNetworkSwiftConnectionRead(d, meta) } func resourceAppServiceSlotVirtualNetworkSwiftConnectionDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() @@ -229,38 +236,32 @@ func resourceAppServiceSlotVirtualNetworkSwiftConnectionDelete(d *pluginsdk.Reso return err } - read, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) + appSlotID := webapps.NewSlotID(id.SubscriptionId, id.ResourceGroup, id.SiteName, id.SlotName) + + existing, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, appSlotID) if err != nil { - return fmt.Errorf("making read request on virtual network properties (Slot Name %q / App Service %q / Resource Group %q): %+v", id.SlotName, id.SiteName, id.ResourceGroup, err) + return fmt.Errorf("retrieving Swift Network Connection for %s: %w", appSlotID, err) } - if read.SwiftVirtualNetworkProperties == nil { - return fmt.Errorf("retrieving virtual network properties (Slot Name %q / App Service %q / Resource Group %q): `properties` was nil", id.SlotName, id.SiteName, id.ResourceGroup) - } - props := *read.SwiftVirtualNetworkProperties - subnet := props.SubnetResourceID - if subnet == nil || *subnet == "" { + + if existing.Model == nil || existing.Model.Properties == nil || existing.Model.Properties.SubnetResourceId == nil { // assume deleted + d.SetId("") return nil } - subnetID, err := commonids.ParseSubnetID(pointer.From(subnet)) + subnetID, err := commonids.ParseSubnetID(*existing.Model.Properties.SubnetResourceId) if err != nil { - return fmt.Errorf("parsing Subnet Resource ID %q", subnetID) + return err } - subnetName := subnetID.SubnetName - virtualNetworkName := subnetID.VirtualNetworkName - locks.ByName(virtualNetworkName, network.VirtualNetworkResourceName) - defer locks.UnlockByName(virtualNetworkName, network.VirtualNetworkResourceName) + locks.ByName(subnetID.VirtualNetworkName, network.VirtualNetworkResourceName) + defer locks.UnlockByName(subnetID.VirtualNetworkName, network.VirtualNetworkResourceName) - locks.ByName(subnetName, network.SubnetResourceName) - defer locks.UnlockByName(subnetName, network.SubnetResourceName) + locks.ByName(subnetID.SubnetName, network.SubnetResourceName) + defer locks.UnlockByName(subnetID.SubnetName, network.SubnetResourceName) - resp, err := client.DeleteSwiftVirtualNetworkSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) - if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting virtual network properties (Slot Name %q / App Service %q / Resource Group %q): %+v", id.SlotName, id.SiteName, id.ResourceGroup, err) - } + if _, err := client.DeleteSwiftVirtualNetworkSlot(ctx, appSlotID); err != nil { + return fmt.Errorf("deleting Swift Network Connection for %s: %w", appSlotID, err) } return nil diff --git a/internal/services/web/app_service_slot_virtual_network_swift_connection_resource_test.go b/internal/services/web/app_service_slot_virtual_network_swift_connection_resource_test.go index dc1a1361bbad..dd447a462785 100644 --- a/internal/services/web/app_service_slot_virtual_network_swift_connection_resource_test.go +++ b/internal/services/web/app_service_slot_virtual_network_swift_connection_resource_test.go @@ -7,8 +7,10 @@ import ( "context" "fmt" "testing" + "time" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" "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" @@ -172,17 +174,18 @@ func (r AppServiceSlotVirtualNetworkSwiftConnectionResource) Exists(ctx context. return pointer.To(resp.SwiftVirtualNetworkProperties != nil), nil } -func (t AppServiceSlotVirtualNetworkSwiftConnectionResource) disappears(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) error { +func (r AppServiceSlotVirtualNetworkSwiftConnectionResource) disappears(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) error { id, err := parse.SlotVirtualNetworkSwiftConnectionID(state.ID) if err != nil { return err } - resp, err := clients.Web.AppServicesClientV1.DeleteSwiftVirtualNetworkSlot(ctx, id.ResourceGroup, id.SiteName, id.SlotName) - if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting %s: %+v", id.String(), err) - } + ctx, cancel := context.WithTimeout(ctx, 30*time.Minute) + defer cancel() + + appSlotID := webapps.NewSlotID(id.SubscriptionId, id.ResourceGroup, id.SiteName, id.SlotName) + if _, err := clients.Web.WebAppsClient.DeleteSwiftVirtualNetworkSlot(ctx, appSlotID); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) } return nil @@ -195,12 +198,12 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-appservice-%d" - location = "%s" + name = "acctestRG-appservice-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctest-VNET-%d" + name = "acctest-VNET-%[1]d" address_space = ["10.0.0.0/16"] location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -242,7 +245,7 @@ resource "azurerm_subnet" "test2" { } resource "azurerm_app_service_plan" "test" { - name = "acctest-ASP-%d" + name = "acctest-ASP-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -253,20 +256,20 @@ resource "azurerm_app_service_plan" "test" { } resource "azurerm_app_service" "test" { - name = "acctest-AS-%d" + name = "acctest-AS-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name app_service_plan_id = azurerm_app_service_plan.test.id } resource "azurerm_app_service_slot" "test-staging" { - name = "acctest-AS-%d-staging" + name = "acctest-AS-%[1]d-staging" app_service_name = azurerm_app_service.test.name location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name app_service_plan_id = azurerm_app_service_plan.test.id } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary) } func (r AppServiceSlotVirtualNetworkSwiftConnectionResource) app_basic(data acceptance.TestData) string { @@ -312,12 +315,12 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-functionapp-%d" - location = "%s" + name = "acctestRG-functionapp-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctest-VNET-%d" + name = "acctest-VNET-%[1]d" address_space = ["10.0.0.0/16"] location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -359,7 +362,7 @@ resource "azurerm_subnet" "test2" { } resource "azurerm_storage_account" "test" { - name = "acctestsa%s" + name = "acctestsa%[3]s" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location account_tier = "Standard" @@ -367,7 +370,7 @@ resource "azurerm_storage_account" "test" { } resource "azurerm_app_service_plan" "test" { - name = "acctest-ASP-%d" + name = "acctest-ASP-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -378,7 +381,7 @@ resource "azurerm_app_service_plan" "test" { } resource "azurerm_function_app" "test" { - name = "acctest-FA-%d" + name = "acctest-FA-%[1]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location app_service_plan_id = azurerm_app_service_plan.test.id @@ -387,7 +390,7 @@ resource "azurerm_function_app" "test" { } resource "azurerm_function_app_slot" "test-staging" { - name = "acctest-FA-%d-staging" + name = "acctest-FA-%[1]d-staging" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location app_service_plan_id = azurerm_app_service_plan.test.id @@ -395,7 +398,7 @@ resource "azurerm_function_app_slot" "test-staging" { storage_account_name = azurerm_storage_account.test.name storage_account_access_key = azurerm_storage_account.test.primary_access_key } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary, data.RandomString) } func (r AppServiceSlotVirtualNetworkSwiftConnectionResource) function_basic(data acceptance.TestData) string { From 286b45f2d58f748e69b4bf14455479c9155e0801 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:44:22 -0600 Subject: [PATCH 10/18] `azurerm_app_service_virtual_network_swift_connection` - migrate to `go-azure-sdk` --- ...rtual_network_swift_connection_resource.go | 234 +++++++++--------- ..._network_swift_connection_resource_test.go | 67 +++-- 2 files changed, 155 insertions(+), 146 deletions(-) diff --git a/internal/services/web/app_service_virtual_network_swift_connection_resource.go b/internal/services/web/app_service_virtual_network_swift_connection_resource.go index 4d0c0afc32c9..43306ef8c41e 100644 --- a/internal/services/web/app_service_virtual_network_swift_connection_resource.go +++ b/internal/services/web/app_service_virtual_network_swift_connection_resource.go @@ -7,26 +7,27 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" - "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/subnets" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network" + networkpoller "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/custompollers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceAppServiceVirtualNetworkSwiftConnection() *pluginsdk.Resource { return &pluginsdk.Resource{ - Create: resourceAppServiceVirtualNetworkSwiftConnectionCreateUpdate, + Create: resourceAppServiceVirtualNetworkSwiftConnectionCreate, Read: resourceAppServiceVirtualNetworkSwiftConnectionRead, - Update: resourceAppServiceVirtualNetworkSwiftConnectionCreateUpdate, + Update: resourceAppServiceVirtualNetworkSwiftConnectionUpdate, Delete: resourceAppServiceVirtualNetworkSwiftConnectionDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { @@ -57,104 +58,75 @@ func resourceAppServiceVirtualNetworkSwiftConnection() *pluginsdk.Resource { } } -func resourceAppServiceVirtualNetworkSwiftConnectionCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 - subnetClient := meta.(*clients.Client).Network.Subnets - vnetClient := meta.(*clients.Client).Network.VirtualNetworks +func resourceAppServiceVirtualNetworkSwiftConnectionCreate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() - appID, err := parse.AppServiceID(d.Get("app_service_id").(string)) + appID, err := commonids.ParseAppServiceID(d.Get("app_service_id").(string)) if err != nil { - return fmt.Errorf("parsing App Service Resource ID %q", appID) + return err } subnetID, err := commonids.ParseSubnetID(d.Get("subnet_id").(string)) if err != nil { - return fmt.Errorf("parsing Subnet Resource ID %q", subnetID) + return err } - resourceGroup := appID.ResourceGroup - name := appID.SiteName - subnetName := subnetID.SubnetName - virtualNetworkName := subnetID.VirtualNetworkName - - if d.IsNewResource() { - existing, err := client.GetSwiftVirtualNetworkConnection(ctx, resourceGroup, name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("failed checking for presence of existing App Service Swift Network Connection %q (Resource Group %q)", name, resourceGroup) - } - } - - if existing.SwiftVirtualNetworkProperties != nil && existing.SubnetResourceID != nil && *existing.SubnetResourceID != "" { - return tf.ImportAsExistsError("azurerm_app_service_virtual_network_swift_connection", *existing.ID) - } + existing, err := client.GetSwiftVirtualNetworkConnection(ctx, *appID) + if err != nil { + return fmt.Errorf("checking for presence of Swift Network Connection for %s: %w", appID, err) } - locks.ByName(virtualNetworkName, network.VirtualNetworkResourceName) - defer locks.UnlockByName(virtualNetworkName, network.VirtualNetworkResourceName) + if existing.Model != nil && existing.Model.Properties != nil && pointer.From(existing.Model.Properties.SubnetResourceId) != "" { + return tf.ImportAsExistsError("azurerm_app_service_virtual_network_swift_connection", pointer.From(existing.Model.Properties.SubnetResourceId)) + } - locks.ByName(subnetName, network.SubnetResourceName) - defer locks.UnlockByName(subnetName, network.SubnetResourceName) + locks.ByName(subnetID.VirtualNetworkName, network.VirtualNetworkResourceName) + defer locks.UnlockByName(subnetID.VirtualNetworkName, network.VirtualNetworkResourceName) - exists, err := client.Get(ctx, resourceGroup, name) - if err != nil { - if utils.ResponseWasNotFound(exists.Response) { - return fmt.Errorf("retrieving existing App Service %q (Resource Group %q): App Service not found in resource group", name, resourceGroup) - } - return fmt.Errorf("retrieving existing App Service %q (Resource Group %q): %s", name, resourceGroup, err) - } + locks.ByName(subnetID.SubnetName, network.SubnetResourceName) + defer locks.UnlockByName(subnetID.SubnetName, network.SubnetResourceName) - connectionEnvelope := web.SwiftVirtualNetwork{ - SwiftVirtualNetworkProperties: &web.SwiftVirtualNetworkProperties{ - SubnetResourceID: pointer.To(d.Get("subnet_id").(string)), + connectionEnvelope := webapps.SwiftVirtualNetwork{ + Properties: &webapps.SwiftVirtualNetworkProperties{ + SubnetResourceId: pointer.To(d.Get("subnet_id").(string)), }, } - if _, err = client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx, resourceGroup, name, connectionEnvelope); err != nil { - return fmt.Errorf("creating/updating App Service VNet association between %q (Resource Group %q) and Virtual Network %q: %s", name, resourceGroup, virtualNetworkName, err) - } - - timeout, _ := ctx.Deadline() - stateConf := &pluginsdk.StateChangeConf{ - Pending: []string{string(subnets.ProvisioningStateUpdating)}, - Target: []string{string(subnets.ProvisioningStateSucceeded)}, - Refresh: network.SubnetProvisioningStateRefreshFunc(ctx, subnetClient, *subnetID), - MinTimeout: 1 * time.Minute, - Timeout: time.Until(timeout), - } - if _, err = stateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for provisioning state of subnet for App Service VNet association between %q (Resource Group %q) and Virtual Network %q: %s", name, resourceGroup, virtualNetworkName, err) + if _, err = client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx, *appID, connectionEnvelope); err != nil { + return fmt.Errorf("creating association between %s and %s: %w", appID, subnetID, err) } - vnetId := commonids.NewVirtualNetworkID(subnetID.SubscriptionId, subnetID.ResourceGroupName, subnetID.VirtualNetworkName) - vnetStateConf := &pluginsdk.StateChangeConf{ - Pending: []string{string(subnets.ProvisioningStateUpdating)}, - Target: []string{string(subnets.ProvisioningStateSucceeded)}, - Refresh: network.VirtualNetworkProvisioningStateRefreshFunc(ctx, vnetClient, vnetId), - MinTimeout: 1 * time.Minute, - Timeout: time.Until(timeout), - } - if _, err = vnetStateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for provisioning state of virtual network for App Service VNet association between %q (Resource Group %q) and Virtual Network %q: %s", name, resourceGroup, virtualNetworkName, err) + pollerType := networkpoller.NewVirtualNetworkAndSubnetProvisioningSucceededPoller(meta.(*clients.Client).Network, subnetID) + poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling for completion of association between %s and %s: %w", appID, subnetID, err) } - read, err := client.GetSwiftVirtualNetworkConnection(ctx, resourceGroup, name) + read, err := client.GetSwiftVirtualNetworkConnection(ctx, *appID) if err != nil { - return fmt.Errorf("retrieving App Service VNet association between %q (Resource Group %q) and Virtual Network %q: %s", name, resourceGroup, virtualNetworkName, err) + return fmt.Errorf("retrieving Swift Network Connection for %s: %w", appID, err) + } + + if read.Model == nil || read.Model.Id == nil { + return fmt.Errorf("retrieving Swift Network Connection for %s: missing ID", appID) } - swiftVirtualNetworkId, err := parse.VirtualNetworkSwiftConnectionID(*read.ID) + + swiftVirtualNetworkId, err := parse.VirtualNetworkSwiftConnectionID(*read.Model.Id) if err != nil { return err } + d.SetId(swiftVirtualNetworkId.ID()) return resourceAppServiceVirtualNetworkSwiftConnectionRead(d, meta) } func resourceAppServiceVirtualNetworkSwiftConnectionRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() @@ -162,40 +134,87 @@ func resourceAppServiceVirtualNetworkSwiftConnectionRead(d *pluginsdk.ResourceDa if err != nil { return err } + appID := commonids.NewAppServiceID(id.SubscriptionId, id.ResourceGroup, id.SiteName) - appService, err := client.Get(ctx, id.ResourceGroup, id.SiteName) + existing, err := client.GetSwiftVirtualNetworkConnection(ctx, appID) if err != nil { - if utils.ResponseWasNotFound(appService.Response) { + if response.WasNotFound(existing.HttpResponse) { d.SetId("") return nil } - return fmt.Errorf("retrieving existing App Service %q (Resource Group %q): %s", id.SiteName, id.ResourceGroup, err) - } - swiftVnet, err := client.GetSwiftVirtualNetworkConnection(ctx, id.ResourceGroup, id.SiteName) - if err != nil { - if utils.ResponseWasNotFound(swiftVnet.Response) { - d.SetId("") - return nil - } - return fmt.Errorf("retrieving App Service VNet association for %q (Resource Group %q): %s", id.SiteName, id.ResourceGroup, err) + return fmt.Errorf("retrieving Swift Network Connection for %s: %w", appID, err) } - if swiftVnet.SwiftVirtualNetworkProperties == nil { - return fmt.Errorf("retrieving virtual network properties (App Service %q / Resource Group %q): `properties` was nil", id.SiteName, id.ResourceGroup) - } - props := *swiftVnet.SwiftVirtualNetworkProperties - subnetID := props.SubnetResourceID - if subnetID == nil || *subnetID == "" { + if existing.Model == nil || existing.Model.Properties == nil || existing.Model.Properties.SubnetResourceId == nil { d.SetId("") return nil } - d.Set("subnet_id", subnetID) - d.Set("app_service_id", appService.ID) + + subnetID, err := commonids.ParseSubnetID(*existing.Model.Properties.SubnetResourceId) + if err != nil { + return err + } + + d.Set("subnet_id", subnetID.ID()) + d.Set("app_service_id", appID.ID()) + return nil } +func resourceAppServiceVirtualNetworkSwiftConnectionUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Web.WebAppsClient + + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.VirtualNetworkSwiftConnectionID(d.Id()) + if err != nil { + return err + } + appID := commonids.NewAppServiceID(id.SubscriptionId, id.ResourceGroup, id.SiteName) + + existing, err := client.GetSwiftVirtualNetworkConnection(ctx, appID) + if err != nil { + return fmt.Errorf("retrieving Swift Network Connection for %s: %w", appID, err) + } + + if existing.Model == nil { + return fmt.Errorf("retrieving Swift Network Connection for %s: model was nil", appID) + } + + if existing.Model.Properties == nil { + return fmt.Errorf("retrieving Swift Network Connection for %s: model was nil", appID) + } + + subnetID, err := commonids.ParseSubnetID(d.Get("subnet_id").(string)) + if err != nil { + return err + } + + locks.ByName(subnetID.VirtualNetworkName, network.VirtualNetworkResourceName) + defer locks.UnlockByName(subnetID.VirtualNetworkName, network.VirtualNetworkResourceName) + + locks.ByName(subnetID.SubnetName, network.SubnetResourceName) + defer locks.UnlockByName(subnetID.SubnetName, network.SubnetResourceName) + + existing.Model.Properties.SubnetResourceId = pointer.To(d.Get("subnet_id").(string)) + + if _, err = client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx, appID, *existing.Model); err != nil { + return fmt.Errorf("creating association between %s and %s: %w", appID, subnetID, err) + } + + pollerType := networkpoller.NewVirtualNetworkAndSubnetProvisioningSucceededPoller(meta.(*clients.Client).Network, subnetID) + poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling for completion of association between %s and %s: %w", appID, subnetID, err) + } + + return resourceAppServiceVirtualNetworkSwiftConnectionRead(d, meta) +} + func resourceAppServiceVirtualNetworkSwiftConnectionDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 + client := meta.(*clients.Client).Web.WebAppsClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() @@ -203,39 +222,32 @@ func resourceAppServiceVirtualNetworkSwiftConnectionDelete(d *pluginsdk.Resource if err != nil { return err } + appID := commonids.NewAppServiceID(id.SubscriptionId, id.ResourceGroup, id.SiteName) - read, err := client.GetSwiftVirtualNetworkConnection(ctx, id.ResourceGroup, id.SiteName) + existing, err := client.GetSwiftVirtualNetworkConnection(ctx, appID) if err != nil { - return fmt.Errorf("making read request on virtual network properties (App Service %q / Resource Group %q): %+v", id.SiteName, id.ResourceGroup, err) + return fmt.Errorf("retrieving Swift Network Connection for %s: %w", id, err) } - if read.SwiftVirtualNetworkProperties == nil { - return fmt.Errorf("retrieving virtual network properties (App Service %q / Resource Group %q): `properties` was nil", id.SiteName, id.ResourceGroup) - } - props := *read.SwiftVirtualNetworkProperties - subnet := props.SubnetResourceID - if subnet == nil || *subnet == "" { + + if existing.Model == nil || existing.Model.Properties == nil || existing.Model.Properties.SubnetResourceId == nil { // assume deleted + d.SetId("") return nil } - subnetID, err := commonids.ParseSubnetID(pointer.From(subnet)) + subnetID, err := commonids.ParseSubnetID(*existing.Model.Properties.SubnetResourceId) if err != nil { - return fmt.Errorf("parsing Subnet Resource ID %q", subnetID) + return err } - subnetName := subnetID.SubnetName - virtualNetworkName := subnetID.VirtualNetworkName - locks.ByName(virtualNetworkName, network.VirtualNetworkResourceName) - defer locks.UnlockByName(virtualNetworkName, network.VirtualNetworkResourceName) + locks.ByName(subnetID.VirtualNetworkName, network.VirtualNetworkResourceName) + defer locks.UnlockByName(subnetID.VirtualNetworkName, network.VirtualNetworkResourceName) - locks.ByName(subnetName, network.SubnetResourceName) - defer locks.UnlockByName(subnetName, network.SubnetResourceName) + locks.ByName(subnetID.SubnetName, network.SubnetResourceName) + defer locks.UnlockByName(subnetID.SubnetName, network.SubnetResourceName) - resp, err := client.DeleteSwiftVirtualNetwork(ctx, id.ResourceGroup, id.SiteName) - if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting virtual network properties (App Service %q / Resource Group %q): %+v", id.SiteName, id.ResourceGroup, err) - } + if _, err := client.DeleteSwiftVirtualNetwork(ctx, appID); err != nil { + return fmt.Errorf("deleting Swift Network Connection for %s: %w", id, err) } return nil diff --git a/internal/services/web/app_service_virtual_network_swift_connection_resource_test.go b/internal/services/web/app_service_virtual_network_swift_connection_resource_test.go index da4b703dcfcf..e0fe3cf389ce 100644 --- a/internal/services/web/app_service_virtual_network_swift_connection_resource_test.go +++ b/internal/services/web/app_service_virtual_network_swift_connection_resource_test.go @@ -7,14 +7,15 @@ import ( "context" "fmt" "testing" + "time" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "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" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type AppServiceVirtualNetworkSwiftConnectionResource struct{} @@ -94,29 +95,28 @@ func (r AppServiceVirtualNetworkSwiftConnectionResource) Exists(ctx context.Cont if err != nil { return nil, err } + appID := commonids.NewAppServiceID(id.SubscriptionId, id.ResourceGroup, id.SiteName) - resp, err := clients.Web.AppServicesClientV1.GetSwiftVirtualNetworkConnection(ctx, id.ResourceGroup, id.SiteName) + resp, err := clients.Web.WebAppsClient.GetSwiftVirtualNetworkConnection(ctx, appID) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("retrieving %s: %+v", id.String(), err) + return nil, fmt.Errorf("retrieving %s: %w", id, err) } - return pointer.To(resp.SwiftVirtualNetworkProperties != nil), nil + return pointer.To(resp.Model != nil), nil } -func (t AppServiceVirtualNetworkSwiftConnectionResource) disappears(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) error { +func (r AppServiceVirtualNetworkSwiftConnectionResource) disappears(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) error { id, err := parse.VirtualNetworkSwiftConnectionID(state.ID) if err != nil { return err } + appID := commonids.NewAppServiceID(id.SubscriptionId, id.ResourceGroup, id.SiteName) - resp, err := clients.Web.AppServicesClientV1.DeleteSwiftVirtualNetwork(ctx, id.ResourceGroup, id.SiteName) - if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting %s: %+v", id.String(), err) - } + ctx, cancel := context.WithTimeout(ctx, 30*time.Minute) + defer cancel() + + if _, err := clients.Web.WebAppsClient.DeleteSwiftVirtualNetwork(ctx, appID); err != nil { + return fmt.Errorf("deleting %s: %w", id, err) } return nil @@ -145,12 +145,12 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-appservice-%d" - location = "%s" + name = "acctestRG-appservice-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctest-VNET-%d" + name = "acctest-VNET-%[1]d" address_space = ["10.0.0.0/16"] location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -192,7 +192,7 @@ resource "azurerm_subnet" "test2" { } resource "azurerm_app_service_plan" "test" { - name = "acctest-ASP-%d" + name = "acctest-ASP-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -203,16 +203,15 @@ resource "azurerm_app_service_plan" "test" { } resource "azurerm_app_service" "test" { - name = "acctest-AS-%d" + name = "acctest-AS-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name app_service_plan_id = azurerm_app_service_plan.test.id } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary) } -func (AppServiceVirtualNetworkSwiftConnectionResource) basic(data acceptance.TestData) string { - template := AppServiceVirtualNetworkSwiftConnectionResource{}.base(data) +func (r AppServiceVirtualNetworkSwiftConnectionResource) basic(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -224,11 +223,10 @@ resource "azurerm_app_service_virtual_network_swift_connection" "test" { azurerm_subnet.test2 ] } -`, template) +`, r.base(data)) } -func (AppServiceVirtualNetworkSwiftConnectionResource) update(data acceptance.TestData) string { - template := AppServiceVirtualNetworkSwiftConnectionResource{}.base(data) +func (r AppServiceVirtualNetworkSwiftConnectionResource) update(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -236,11 +234,10 @@ resource "azurerm_app_service_virtual_network_swift_connection" "test" { app_service_id = azurerm_app_service.test.id subnet_id = azurerm_subnet.test2.id } -`, template) +`, r.base(data)) } -func (AppServiceVirtualNetworkSwiftConnectionResource) requiresImport(data acceptance.TestData) string { - template := AppServiceVirtualNetworkSwiftConnectionResource{}.basic(data) +func (r AppServiceVirtualNetworkSwiftConnectionResource) requiresImport(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -248,7 +245,7 @@ resource "azurerm_app_service_virtual_network_swift_connection" "import" { app_service_id = azurerm_app_service_virtual_network_swift_connection.test.app_service_id subnet_id = azurerm_app_service_virtual_network_swift_connection.test.subnet_id } -`, template) +`, r.basic(data)) } func (AppServiceVirtualNetworkSwiftConnectionResource) functionAppBasic(data acceptance.TestData) string { @@ -258,12 +255,12 @@ provider "azurerm" { } resource "azurerm_resource_group" "test" { - name = "acctestRG-appservice-%d" - location = "%s" + name = "acctestRG-appservice-%[1]d" + location = "%[2]s" } resource "azurerm_virtual_network" "test" { - name = "acctest-VNET-%d" + name = "acctest-VNET-%[1]d" address_space = ["10.0.0.0/16"] location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -289,7 +286,7 @@ resource "azurerm_subnet" "test" { } resource "azurerm_storage_account" "test" { - name = "acctestsa%s" + name = "acctestsa%[3]s" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location account_tier = "Standard" @@ -297,7 +294,7 @@ resource "azurerm_storage_account" "test" { } resource "azurerm_app_service_plan" "test" { - name = "acctest-ASP-%d" + name = "acctest-ASP-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -308,7 +305,7 @@ resource "azurerm_app_service_plan" "test" { } resource "azurerm_function_app" "test" { - name = "acctest-FA-%d" + name = "acctest-FA-%[1]d" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name app_service_plan_id = azurerm_app_service_plan.test.id @@ -320,5 +317,5 @@ resource "azurerm_app_service_virtual_network_swift_connection" "test" { app_service_id = azurerm_function_app.test.id subnet_id = azurerm_subnet.test.id } -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString, data.RandomInteger, data.RandomInteger) +`, data.RandomInteger, data.Locations.Primary, data.RandomString) } From acdd230c0a525a343d95ddf2e4a3e71f97acf917 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:45:04 -0600 Subject: [PATCH 11/18] `azurerm_function_app_host_keys` - migrate to `go-azure-sdk` --- .../web/function_app_host_keys_data_source.go | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/internal/services/web/function_app_host_keys_data_source.go b/internal/services/web/function_app_host_keys_data_source.go index 3e511279bddf..b7ac854851dc 100644 --- a/internal/services/web/function_app_host_keys_data_source.go +++ b/internal/services/web/function_app_host_keys_data_source.go @@ -7,12 +7,13 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceFunctionAppHostKeys() *pluginsdk.Resource { @@ -83,38 +84,41 @@ func dataSourceFunctionAppHostKeys() *pluginsdk.Resource { } func dataSourceFunctionAppHostKeysRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Web.AppServicesClientV1 - subscriptionId := meta.(*clients.Client).Account.SubscriptionId + client := meta.(*clients.Client).Web.WebAppsClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id := parse.NewFunctionAppID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + id := commonids.NewAppServiceID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) - functionSettings, err := client.Get(ctx, id.ResourceGroup, id.SiteName) + functionSettings, err := client.Get(ctx, id) if err != nil { - if utils.ResponseWasNotFound(functionSettings.Response) { + if response.WasNotFound(functionSettings.HttpResponse) { return fmt.Errorf("%s was not found", id) } - return fmt.Errorf("making Read request on %s: %+v", id, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } d.SetId(id.ID()) return pluginsdk.Retry(d.Timeout(pluginsdk.TimeoutCreate), func() *pluginsdk.RetryError { - res, err := client.ListHostKeys(ctx, id.ResourceGroup, id.SiteName) + resp, err := client.ListHostKeys(ctx, id) if err != nil { - if utils.ResponseWasNotFound(res.Response) { + if response.WasNotFound(resp.HttpResponse) { return pluginsdk.NonRetryableError(fmt.Errorf("%s was not found", id)) } - return pluginsdk.RetryableError(fmt.Errorf("making Read request on %s: %+v", id, err)) + return pluginsdk.RetryableError(fmt.Errorf("retrieving %s: %+v", id, err)) } - d.Set("primary_key", res.MasterKey) + if resp.Model == nil { + return pluginsdk.RetryableError(fmt.Errorf("retrieving %s: model was nil", id)) + } + + d.Set("primary_key", resp.Model.MasterKey) defaultFunctionKey := "" - if v, ok := res.FunctionKeys["default"]; ok { - defaultFunctionKey = *v + if v, ok := pointer.From(resp.Model.FunctionKeys)["default"]; ok { + defaultFunctionKey = v } d.Set("default_function_key", defaultFunctionKey) @@ -123,34 +127,34 @@ func dataSourceFunctionAppHostKeysRead(d *pluginsdk.ResourceData, meta interface // This block accommodates both keys. eventGridExtensionConfigKey := "" for _, key := range []string{"eventgridextensionconfig_extension", "eventgrid_extension"} { - if v, ok := res.SystemKeys[key]; ok { - eventGridExtensionConfigKey = *v + if v, ok := pointer.From(resp.Model.SystemKeys)[key]; ok { + eventGridExtensionConfigKey = v break } } d.Set("event_grid_extension_config_key", eventGridExtensionConfigKey) signalrExtensionKey := "" - if v, ok := res.SystemKeys["signalr_extension"]; ok { - signalrExtensionKey = *v + if v, ok := pointer.From(resp.Model.SystemKeys)["signalr_extension"]; ok { + signalrExtensionKey = v } d.Set("signalr_extension_key", signalrExtensionKey) durableTaskExtensionKey := "" - if v, ok := res.SystemKeys["durabletask_extension"]; ok { - durableTaskExtensionKey = *v + if v, ok := pointer.From(resp.Model.SystemKeys)["durabletask_extension"]; ok { + durableTaskExtensionKey = v } d.Set("durabletask_extension_key", durableTaskExtensionKey) webPubSubExtensionKey := "" - if v, ok := res.SystemKeys["webpubsub_extension"]; ok { - webPubSubExtensionKey = *v + if v, ok := pointer.From(resp.Model.SystemKeys)["webpubsub_extension"]; ok { + webPubSubExtensionKey = v } d.Set("webpubsub_extension_key", webPubSubExtensionKey) blobsExtensionKey := "" - if v, ok := res.SystemKeys["blobs_extension"]; ok { - blobsExtensionKey = *v + if v, ok := pointer.From(resp.Model.SystemKeys)["blobs_extension"]; ok { + blobsExtensionKey = v } d.Set("blobs_extension_key", blobsExtensionKey) From 15a8b91410a945fda3dd90a29c5779e043651f73 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 11:47:26 -0600 Subject: [PATCH 12/18] `appservice`/`logic`/`web` - old resource ID and client clean up --- .../app_service_environment_v3_resource.go | 2 +- ...pp_service_environment_v3_resource_test.go | 14 +- .../appservice/linux_function_app_resource.go | 3 +- .../appservice/linux_web_app_resource.go | 3 +- .../parse/app_service_environment.go | 117 --------- .../parse/app_service_environment_test.go | 230 ------------------ internal/services/appservice/resourceids.go | 2 - .../appservice/service_plan_resource.go | 3 +- .../validate/app_service_environment_id.go | 26 -- .../app_service_environment_id_test.go | 78 ------ .../windows_function_app_resource.go | 3 +- .../appservice/windows_web_app_resource.go | 3 +- .../windows_web_app_slot_resource.go | 3 +- .../logic/logic_app_standard_data_source.go | 3 +- .../web/parse/app_service_environment.go | 73 ------ .../web/parse/app_service_environment_test.go | 114 --------- .../services/web/parse/hostname_binding.go | 79 ------ .../web/parse/hostname_binding_test.go | 130 ---------- .../services/web/parse/public_certificate.go | 79 ------ .../web/parse/public_certificate_test.go | 130 ---------- internal/services/web/resourceids.go | 7 - .../validate/app_service_environment_id.go | 26 -- .../app_service_environment_id_test.go | 78 ------ .../web/validate/hostname_binding_id.go | 26 -- .../web/validate/hostname_binding_id_test.go | 90 ------- .../web/validate/public_certificate_id.go | 26 -- .../validate/public_certificate_id_test.go | 90 ------- 27 files changed, 14 insertions(+), 1424 deletions(-) delete mode 100644 internal/services/appservice/parse/app_service_environment.go delete mode 100644 internal/services/appservice/parse/app_service_environment_test.go delete mode 100644 internal/services/appservice/validate/app_service_environment_id.go delete mode 100644 internal/services/appservice/validate/app_service_environment_id_test.go delete mode 100644 internal/services/web/parse/app_service_environment.go delete mode 100644 internal/services/web/parse/app_service_environment_test.go delete mode 100644 internal/services/web/parse/hostname_binding.go delete mode 100644 internal/services/web/parse/hostname_binding_test.go delete mode 100644 internal/services/web/parse/public_certificate.go delete mode 100644 internal/services/web/parse/public_certificate_test.go delete mode 100644 internal/services/web/validate/app_service_environment_id.go delete mode 100644 internal/services/web/validate/app_service_environment_id_test.go delete mode 100644 internal/services/web/validate/hostname_binding_id.go delete mode 100644 internal/services/web/validate/hostname_binding_id_test.go delete mode 100644 internal/services/web/validate/public_certificate_id.go delete mode 100644 internal/services/web/validate/public_certificate_id_test.go diff --git a/internal/services/appservice/app_service_environment_v3_resource.go b/internal/services/appservice/app_service_environment_v3_resource.go index a5c144a61d20..2b85691873a8 100644 --- a/internal/services/appservice/app_service_environment_v3_resource.go +++ b/internal/services/appservice/app_service_environment_v3_resource.go @@ -435,7 +435,7 @@ func (r AppServiceEnvironmentV3Resource) Delete() sdk.ResourceFunc { } func (r AppServiceEnvironmentV3Resource) IDValidationFunc() pluginsdk.SchemaValidateFunc { - return validate.AppServiceEnvironmentID + return commonids.ValidateAppServiceEnvironmentID } func (r AppServiceEnvironmentV3Resource) Update() sdk.ResourceFunc { diff --git a/internal/services/appservice/app_service_environment_v3_resource_test.go b/internal/services/appservice/app_service_environment_v3_resource_test.go index 5a622e40d3ac..3d9d29b1a29f 100644 --- a/internal/services/appservice/app_service_environment_v3_resource_test.go +++ b/internal/services/appservice/app_service_environment_v3_resource_test.go @@ -9,12 +9,11 @@ import ( "testing" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "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" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) type AppServiceEnvironmentV3Resource struct{} @@ -170,20 +169,17 @@ func TestAccAppServiceEnvironmentV3_dedicatedHosts(t *testing.T) { } func (AppServiceEnvironmentV3Resource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.AppServiceEnvironmentID(state.ID) + id, err := commonids.ParseAppServiceEnvironmentID(state.ID) if err != nil { return nil, err } - resp, err := client.Web.AppServiceEnvironmentsClientV1.Get(ctx, id.ResourceGroup, id.HostingEnvironmentName) + resp, err := client.AppService.AppServiceEnvironmentClient.Get(ctx, *id) if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return pointer.To(false), nil - } - return nil, fmt.Errorf("retrieving App Service Environment V3 %q (Resource Group %q): %+v", id.HostingEnvironmentName, id.ResourceGroup, err) + return nil, fmt.Errorf("retrieving %s: %+v", id, err) } - return pointer.To(true), nil + return pointer.To(resp.Model != nil), nil } func (r AppServiceEnvironmentV3Resource) basic(data acceptance.TestData) string { diff --git a/internal/services/appservice/linux_function_app_resource.go b/internal/services/appservice/linux_function_app_resource.go index fbf7b7d9eada..b2980927db98 100644 --- a/internal/services/appservice/linux_function_app_resource.go +++ b/internal/services/appservice/linux_function_app_resource.go @@ -27,7 +27,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/validate" storageValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -808,7 +807,7 @@ func (r LinuxFunctionAppResource) Read() sdk.ResourceFunc { state.ServicePlanId = servicePlanId.ID() if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil { - hostingEnvId, err := parse.AppServiceEnvironmentIDInsensitively(*hostingEnv.Id) + hostingEnvId, err := commonids.ParseAppServiceEnvironmentIDInsensitively(*hostingEnv.Id) if err != nil { return err } diff --git a/internal/services/appservice/linux_web_app_resource.go b/internal/services/appservice/linux_web_app_resource.go index 83131d05c8c4..35cbab0e208f 100644 --- a/internal/services/appservice/linux_web_app_resource.go +++ b/internal/services/appservice/linux_web_app_resource.go @@ -21,7 +21,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -651,7 +650,7 @@ func (r LinuxWebAppResource) Read() sdk.ResourceFunc { state.ServicePlanId = servicePlanId.ID() if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil { - hostingEnvId, err := parse.AppServiceEnvironmentIDInsensitively(*hostingEnv.Id) + hostingEnvId, err := commonids.ParseAppServiceEnvironmentIDInsensitively(*hostingEnv.Id) if err != nil { return err } diff --git a/internal/services/appservice/parse/app_service_environment.go b/internal/services/appservice/parse/app_service_environment.go deleted file mode 100644 index 722a7e6ade1e..000000000000 --- a/internal/services/appservice/parse/app_service_environment.go +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type AppServiceEnvironmentId struct { - SubscriptionId string - ResourceGroup string - HostingEnvironmentName string -} - -func NewAppServiceEnvironmentID(subscriptionId, resourceGroup, hostingEnvironmentName string) AppServiceEnvironmentId { - return AppServiceEnvironmentId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - HostingEnvironmentName: hostingEnvironmentName, - } -} - -func (id AppServiceEnvironmentId) String() string { - segments := []string{ - fmt.Sprintf("Hosting Environment Name %q", id.HostingEnvironmentName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "App Service Environment", segmentsStr) -} - -func (id AppServiceEnvironmentId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.HostingEnvironmentName) -} - -// AppServiceEnvironmentID parses a AppServiceEnvironment ID into an AppServiceEnvironmentId struct -func AppServiceEnvironmentID(input string) (*AppServiceEnvironmentId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an AppServiceEnvironment ID: %+v", input, err) - } - - resourceId := AppServiceEnvironmentId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.HostingEnvironmentName, err = id.PopSegment("hostingEnvironments"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} - -// AppServiceEnvironmentIDInsensitively parses an AppServiceEnvironment ID into an AppServiceEnvironmentId struct, insensitively -// This should only be used to parse an ID for rewriting, the AppServiceEnvironmentID -// method should be used instead for validation etc. -// -// Whilst this may seem strange, this enables Terraform have consistent casing -// which works around issues in Core, whilst handling broken API responses. -func AppServiceEnvironmentIDInsensitively(input string) (*AppServiceEnvironmentId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := AppServiceEnvironmentId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - // find the correct casing for the 'hostingEnvironments' segment - hostingEnvironmentsKey := "hostingEnvironments" - for key := range id.Path { - if strings.EqualFold(key, hostingEnvironmentsKey) { - hostingEnvironmentsKey = key - break - } - } - if resourceId.HostingEnvironmentName, err = id.PopSegment(hostingEnvironmentsKey); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/appservice/parse/app_service_environment_test.go b/internal/services/appservice/parse/app_service_environment_test.go deleted file mode 100644 index 799f86ae19c3..000000000000 --- a/internal/services/appservice/parse/app_service_environment_test.go +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = AppServiceEnvironmentId{} - -func TestAppServiceEnvironmentIDFormatter(t *testing.T) { - actual := NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "resGroup1", "hostingEnvironment1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/hostingEnvironment1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestAppServiceEnvironmentID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AppServiceEnvironmentId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing HostingEnvironmentName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Error: true, - }, - - { - // missing value for HostingEnvironmentName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/hostingEnvironment1", - Expected: &AppServiceEnvironmentId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - HostingEnvironmentName: "hostingEnvironment1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/HOSTINGENVIRONMENTS/HOSTINGENVIRONMENT1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := AppServiceEnvironmentID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { - t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) - } - } -} - -func TestAppServiceEnvironmentIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AppServiceEnvironmentId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing HostingEnvironmentName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Error: true, - }, - - { - // missing value for HostingEnvironmentName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/hostingEnvironment1", - Expected: &AppServiceEnvironmentId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - HostingEnvironmentName: "hostingEnvironment1", - }, - }, - - { - // lower-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingenvironments/hostingEnvironment1", - Expected: &AppServiceEnvironmentId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - HostingEnvironmentName: "hostingEnvironment1", - }, - }, - - { - // upper-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/HOSTINGENVIRONMENTS/hostingEnvironment1", - Expected: &AppServiceEnvironmentId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - HostingEnvironmentName: "hostingEnvironment1", - }, - }, - - { - // mixed-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/HoStInGeNvIrOnMeNtS/hostingEnvironment1", - Expected: &AppServiceEnvironmentId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - HostingEnvironmentName: "hostingEnvironment1", - }, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := AppServiceEnvironmentIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { - t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) - } - } -} diff --git a/internal/services/appservice/resourceids.go b/internal/services/appservice/resourceids.go index 984821512a05..2711aa1e4b7d 100644 --- a/internal/services/appservice/resourceids.go +++ b/internal/services/appservice/resourceids.go @@ -3,7 +3,5 @@ package appservice -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=AppServiceEnvironment -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/hostingEnvironment1 -rewrite=true - // @tombuildsstuff: this Resource is going to need a State Migration `serverfarms` -> `serverFarms` // //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ServicePlan -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/serverfarms/farm1 -rewrite=true diff --git a/internal/services/appservice/service_plan_resource.go b/internal/services/appservice/service_plan_resource.go index da0da9b8cb48..b7a79726eb2f 100644 --- a/internal/services/appservice/service_plan_resource.go +++ b/internal/services/appservice/service_plan_resource.go @@ -21,7 +21,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/validate" - webValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -103,7 +102,7 @@ func (r ServicePlanResource) Arguments() map[string]*pluginsdk.Schema { "app_service_environment_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: webValidate.AppServiceEnvironmentID, + ValidateFunc: commonids.ValidateAppServiceEnvironmentID, }, "per_site_scaling_enabled": { diff --git a/internal/services/appservice/validate/app_service_environment_id.go b/internal/services/appservice/validate/app_service_environment_id.go deleted file mode 100644 index 680ab8bed644..000000000000 --- a/internal/services/appservice/validate/app_service_environment_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/parse" -) - -func AppServiceEnvironmentID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.AppServiceEnvironmentID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/appservice/validate/app_service_environment_id_test.go b/internal/services/appservice/validate/app_service_environment_id_test.go deleted file mode 100644 index acda15afa264..000000000000 --- a/internal/services/appservice/validate/app_service_environment_id_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestAppServiceEnvironmentID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing HostingEnvironmentName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Valid: false, - }, - - { - // missing value for HostingEnvironmentName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/hostingEnvironment1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/HOSTINGENVIRONMENTS/HOSTINGENVIRONMENT1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := AppServiceEnvironmentID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/appservice/windows_function_app_resource.go b/internal/services/appservice/windows_function_app_resource.go index 91ae5f7072ec..175f0515d822 100644 --- a/internal/services/appservice/windows_function_app_resource.go +++ b/internal/services/appservice/windows_function_app_resource.go @@ -24,7 +24,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/validate" storageValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -787,7 +786,7 @@ func (r WindowsFunctionAppResource) Read() sdk.ResourceFunc { state.PublishingDeployBasicAuthEnabled = basicAuthWebDeploy if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil { - hostingEnvId, err := parse.AppServiceEnvironmentIDInsensitively(*hostingEnv.Id) + hostingEnvId, err := commonids.ParseAppServiceEnvironmentIDInsensitively(*hostingEnv.Id) if err != nil { return err } diff --git a/internal/services/appservice/windows_web_app_resource.go b/internal/services/appservice/windows_web_app_resource.go index 1a801834f247..c516e15b7b41 100644 --- a/internal/services/appservice/windows_web_app_resource.go +++ b/internal/services/appservice/windows_web_app_resource.go @@ -22,7 +22,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -698,7 +697,7 @@ func (r WindowsWebAppResource) Read() sdk.ResourceFunc { state.ServicePlanId = serverFarmId.ID() if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil { - hostingEnvId, err := parse.AppServiceEnvironmentIDInsensitively(pointer.From(hostingEnv.Id)) + hostingEnvId, err := commonids.ParseAppServiceEnvironmentIDInsensitively(pointer.From(hostingEnv.Id)) if err != nil { return err } diff --git a/internal/services/appservice/windows_web_app_slot_resource.go b/internal/services/appservice/windows_web_app_slot_resource.go index 2766244be5db..37f20607e0f9 100644 --- a/internal/services/appservice/windows_web_app_slot_resource.go +++ b/internal/services/appservice/windows_web_app_slot_resource.go @@ -22,7 +22,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -666,7 +665,7 @@ func (r WindowsWebAppSlotResource) Read() sdk.ResourceFunc { state.VirtualNetworkImagePullEnabled = pointer.From(props.VnetImagePullEnabled) if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil { - hostingEnvId, err := parse.AppServiceEnvironmentIDInsensitively(*hostingEnv.Id) + hostingEnvId, err := commonids.ParseAppServiceEnvironmentIDInsensitively(*hostingEnv.Id) if err != nil { return err } diff --git a/internal/services/logic/logic_app_standard_data_source.go b/internal/services/logic/logic_app_standard_data_source.go index a803d390bc24..7266a3c52f01 100644 --- a/internal/services/logic/logic_app_standard_data_source.go +++ b/internal/services/logic/logic_app_standard_data_source.go @@ -206,7 +206,8 @@ func dataSourceLogicAppStandard() *pluginsdk.Resource { func dataSourceLogicAppStandardRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).AppService.WebAppsClient - subscriptionId := meta.(*clients.Client).Web.AppServicesClientV1.SubscriptionID + subscriptionId := meta.(*clients.Client).Account.SubscriptionId + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() diff --git a/internal/services/web/parse/app_service_environment.go b/internal/services/web/parse/app_service_environment.go deleted file mode 100644 index 2bb3d48c1f22..000000000000 --- a/internal/services/web/parse/app_service_environment.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type AppServiceEnvironmentId struct { - SubscriptionId string - ResourceGroup string - HostingEnvironmentName string -} - -func NewAppServiceEnvironmentID(subscriptionId, resourceGroup, hostingEnvironmentName string) AppServiceEnvironmentId { - return AppServiceEnvironmentId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - HostingEnvironmentName: hostingEnvironmentName, - } -} - -func (id AppServiceEnvironmentId) String() string { - segments := []string{ - fmt.Sprintf("Hosting Environment Name %q", id.HostingEnvironmentName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "App Service Environment", segmentsStr) -} - -func (id AppServiceEnvironmentId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.HostingEnvironmentName) -} - -// AppServiceEnvironmentID parses a AppServiceEnvironment ID into an AppServiceEnvironmentId struct -func AppServiceEnvironmentID(input string) (*AppServiceEnvironmentId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an AppServiceEnvironment ID: %+v", input, err) - } - - resourceId := AppServiceEnvironmentId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.HostingEnvironmentName, err = id.PopSegment("hostingEnvironments"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/web/parse/app_service_environment_test.go b/internal/services/web/parse/app_service_environment_test.go deleted file mode 100644 index 0c6308a3f2d2..000000000000 --- a/internal/services/web/parse/app_service_environment_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = AppServiceEnvironmentId{} - -func TestAppServiceEnvironmentIDFormatter(t *testing.T) { - actual := NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "resGroup1", "hostingEnvironment1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/hostingEnvironment1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestAppServiceEnvironmentID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *AppServiceEnvironmentId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing HostingEnvironmentName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Error: true, - }, - - { - // missing value for HostingEnvironmentName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/hostingEnvironment1", - Expected: &AppServiceEnvironmentId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - HostingEnvironmentName: "hostingEnvironment1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/HOSTINGENVIRONMENTS/HOSTINGENVIRONMENT1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := AppServiceEnvironmentID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { - t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) - } - } -} diff --git a/internal/services/web/parse/hostname_binding.go b/internal/services/web/parse/hostname_binding.go deleted file mode 100644 index 96b11b77c72c..000000000000 --- a/internal/services/web/parse/hostname_binding.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type HostnameBindingId struct { - SubscriptionId string - ResourceGroup string - SiteName string - Name string -} - -func NewHostnameBindingID(subscriptionId, resourceGroup, siteName, name string) HostnameBindingId { - return HostnameBindingId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - SiteName: siteName, - Name: name, - } -} - -func (id HostnameBindingId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Site Name %q", id.SiteName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Hostname Binding", segmentsStr) -} - -func (id HostnameBindingId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostNameBindings/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.SiteName, id.Name) -} - -// HostnameBindingID parses a HostnameBinding ID into an HostnameBindingId struct -func HostnameBindingID(input string) (*HostnameBindingId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an HostnameBinding ID: %+v", input, err) - } - - resourceId := HostnameBindingId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.SiteName, err = id.PopSegment("sites"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("hostNameBindings"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/web/parse/hostname_binding_test.go b/internal/services/web/parse/hostname_binding_test.go deleted file mode 100644 index 21e91e2e82a5..000000000000 --- a/internal/services/web/parse/hostname_binding_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = HostnameBindingId{} - -func TestHostnameBindingIDFormatter(t *testing.T) { - actual := NewHostnameBindingID("12345678-1234-9876-4563-123456789012", "mygroup1", "site1", "binding1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestHostnameBindingID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *HostnameBindingId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/", - Error: true, - }, - - { - // missing value for SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1", - Expected: &HostnameBindingId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "mygroup1", - SiteName: "site1", - Name: "binding1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/MYGROUP1/PROVIDERS/MICROSOFT.WEB/SITES/SITE1/HOSTNAMEBINDINGS/BINDING1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := HostnameBindingID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.SiteName != v.Expected.SiteName { - t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/web/parse/public_certificate.go b/internal/services/web/parse/public_certificate.go deleted file mode 100644 index b36da4acaeb1..000000000000 --- a/internal/services/web/parse/public_certificate.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "errors" - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type PublicCertificateId struct { - SubscriptionId string - ResourceGroup string - SiteName string - Name string -} - -func NewPublicCertificateID(subscriptionId, resourceGroup, siteName, name string) PublicCertificateId { - return PublicCertificateId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - SiteName: siteName, - Name: name, - } -} - -func (id PublicCertificateId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Site Name %q", id.SiteName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Public Certificate", segmentsStr) -} - -func (id PublicCertificateId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/publicCertificates/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.SiteName, id.Name) -} - -// PublicCertificateID parses a PublicCertificate ID into an PublicCertificateId struct -func PublicCertificateID(input string) (*PublicCertificateId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an PublicCertificate ID: %+v", input, err) - } - - resourceId := PublicCertificateId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, errors.New("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, errors.New("ID was missing the 'resourceGroups' element") - } - - if resourceId.SiteName, err = id.PopSegment("sites"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("publicCertificates"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/web/parse/public_certificate_test.go b/internal/services/web/parse/public_certificate_test.go deleted file mode 100644 index 019e7641f286..000000000000 --- a/internal/services/web/parse/public_certificate_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = PublicCertificateId{} - -func TestPublicCertificateIDFormatter(t *testing.T) { - actual := NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "resGroup1", "site1", "publicCertificate1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/publicCertificates/publicCertificate1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestPublicCertificateID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PublicCertificateId - }{ - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Error: true, - }, - - { - // missing value for SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/publicCertificates/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/publicCertificates/publicCertificate1", - Expected: &PublicCertificateId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - SiteName: "site1", - Name: "publicCertificate1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/SITES/SITE1/PUBLICCERTIFICATES/PUBLICCERTIFICATE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := PublicCertificateID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.SiteName != v.Expected.SiteName { - t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/web/resourceids.go b/internal/services/web/resourceids.go index 789ad9e4b16e..c762b8e357cd 100644 --- a/internal/services/web/resourceids.go +++ b/internal/services/web/resourceids.go @@ -4,18 +4,11 @@ package web //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=AppService -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=AppServiceEnvironment -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/hostingEnvironment1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=AppServiceSlot -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=AppServiceSlotCustomHostnameBinding -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1/hostNameBindings/binding1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Certificate -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/certificate1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=CertificateOrder -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.CertificateRegistration/certificateOrders/order1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=CertificateOrderOld -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificateOrders/order1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=FunctionApp -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=FunctionAppSlot -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=HostnameBinding -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=HybridConnection -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/hybridConnectionNamespaces/hybridConnectionNamespace1/relays/relay1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ManagedCertificate -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/customhost.contoso.com -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=PublicCertificate -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/publicCertificates/publicCertificate1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SlotVirtualNetworkSwiftConnection -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/slots/slot1/config/virtualNetwork //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StaticSite -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Web/staticSites/my-static-site1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StaticSiteCustomDomain -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Web/staticSites/my-static-site1/customDomains/name.contoso.com diff --git a/internal/services/web/validate/app_service_environment_id.go b/internal/services/web/validate/app_service_environment_id.go deleted file mode 100644 index d79c463df2a8..000000000000 --- a/internal/services/web/validate/app_service_environment_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" -) - -func AppServiceEnvironmentID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.AppServiceEnvironmentID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/web/validate/app_service_environment_id_test.go b/internal/services/web/validate/app_service_environment_id_test.go deleted file mode 100644 index acda15afa264..000000000000 --- a/internal/services/web/validate/app_service_environment_id_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestAppServiceEnvironmentID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing HostingEnvironmentName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Valid: false, - }, - - { - // missing value for HostingEnvironmentName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/hostingEnvironments/hostingEnvironment1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/HOSTINGENVIRONMENTS/HOSTINGENVIRONMENT1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := AppServiceEnvironmentID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/web/validate/hostname_binding_id.go b/internal/services/web/validate/hostname_binding_id.go deleted file mode 100644 index 15d62203b23a..000000000000 --- a/internal/services/web/validate/hostname_binding_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" -) - -func HostnameBindingID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.HostnameBindingID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/web/validate/hostname_binding_id_test.go b/internal/services/web/validate/hostname_binding_id_test.go deleted file mode 100644 index 0e403a46ded9..000000000000 --- a/internal/services/web/validate/hostname_binding_id_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestHostnameBindingID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/", - Valid: false, - }, - - { - // missing value for SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/mygroup1/providers/Microsoft.Web/sites/site1/hostNameBindings/binding1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/MYGROUP1/PROVIDERS/MICROSOFT.WEB/SITES/SITE1/HOSTNAMEBINDINGS/BINDING1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := HostnameBindingID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/web/validate/public_certificate_id.go b/internal/services/web/validate/public_certificate_id.go deleted file mode 100644 index 14a2ae99a95b..000000000000 --- a/internal/services/web/validate/public_certificate_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/parse" -) - -func PublicCertificateID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.PublicCertificateID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/web/validate/public_certificate_id_test.go b/internal/services/web/validate/public_certificate_id_test.go deleted file mode 100644 index f3aea96806a6..000000000000 --- a/internal/services/web/validate/public_certificate_id_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright IBM Corp. 2014, 2025 -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestPublicCertificateID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/", - Valid: false, - }, - - { - // missing value for SiteName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/publicCertificates/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/publicCertificates/publicCertificate1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/SITES/SITE1/PUBLICCERTIFICATES/PUBLICCERTIFICATE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := PublicCertificateID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} From 6c68aa91ac3218ee773c9672ef6f043815d0254f Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 12:45:53 -0600 Subject: [PATCH 13/18] dependencies: `go-azure-sdk` - upgrade to `v0.20260318.1180614` --- .../appservicecertificateorders/README.md | 381 ++++++++++++++++++ .../appservicecertificateorders/client.go | 26 ++ .../appservicecertificateorders/constants.go | 355 ++++++++++++++++ .../id_certificate.go | 139 +++++++ .../id_certificateorder.go | 130 ++++++ .../method_createorupdate.go | 75 ++++ .../method_createorupdatecertificate.go | 75 ++++ .../method_delete.go | 47 +++ .../method_deletecertificate.go | 47 +++ .../appservicecertificateorders/method_get.go | 53 +++ .../method_getcertificate.go | 53 +++ .../method_list.go | 106 +++++ .../method_listbyresourcegroup.go | 106 +++++ .../method_listcertificates.go | 105 +++++ .../method_reissue.go | 51 +++ .../method_renew.go | 51 +++ .../method_resendemail.go | 47 +++ .../method_resendrequestemails.go | 51 +++ .../method_retrievecertificateactions.go | 54 +++ .../method_retrievecertificateemailhistory.go | 54 +++ .../method_retrievesiteseal.go | 58 +++ .../method_update.go | 57 +++ .../method_updatecertificate.go | 57 +++ .../method_validatepurchaseinformation.go | 52 +++ .../method_verifydomainownership.go | 47 +++ .../model_appservicecertificate.go | 10 + .../model_appservicecertificateorder.go | 14 + ...appservicecertificateorderpatchresource.go | 12 + ...certificateorderpatchresourceproperties.go | 69 ++++ ...el_appservicecertificateorderproperties.go | 69 ++++ ...odel_appservicecertificatepatchresource.go | 12 + .../model_appservicecertificateresource.go | 14 + .../model_certificatedetails.go | 46 +++ .../model_certificateemail.go | 27 ++ .../model_certificateorderaction.go | 27 ++ .../model_certificateordercontact.go | 11 + .../model_nameidentifier.go | 8 + .../model_reissuecertificateorderrequest.go | 12 + ...eissuecertificateorderrequestproperties.go | 11 + .../model_renewcertificateorderrequest.go | 12 + ..._renewcertificateorderrequestproperties.go | 10 + .../model_siteseal.go | 8 + .../model_sitesealrequest.go | 9 + .../appservicecertificateorders/predicates.go | 70 ++++ .../appservicecertificateorders/version.go | 10 + .../web/2023-12-01/certificates/README.md | 125 ++++++ .../web/2023-12-01/certificates/client.go | 26 ++ .../web/2023-12-01/certificates/constants.go | 78 ++++ .../2023-12-01/certificates/id_certificate.go | 130 ++++++ .../certificates/method_createorupdate.go | 75 ++++ .../2023-12-01/certificates/method_delete.go | 47 +++ .../web/2023-12-01/certificates/method_get.go | 53 +++ .../2023-12-01/certificates/method_list.go | 135 +++++++ .../method_listbyresourcegroup.go | 106 +++++ .../2023-12-01/certificates/method_update.go | 57 +++ .../certificates/model_certificate.go | 14 + .../model_certificatepatchresource.go | 13 + ...odel_certificatepatchresourceproperties.go | 58 +++ .../model_certificateproperties.go | 58 +++ .../model_hostingenvironmentprofile.go | 10 + .../web/2023-12-01/certificates/predicates.go | 37 ++ .../web/2023-12-01/certificates/version.go | 10 + vendor/modules.txt | 2 + 63 files changed, 3772 insertions(+) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/id_certificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/id_certificateorder.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_createorupdatecertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_deletecertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_getcertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_listcertificates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_reissue.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_renew.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_resendemail.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_resendrequestemails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievecertificateactions.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievecertificateemailhistory.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievesiteseal.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_updatecertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_validatepurchaseinformation.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_verifydomainownership.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorder.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificatepatchresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificatedetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateemail.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateorderaction.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateordercontact.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_nameidentifier.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_siteseal.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_sitesealrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/id_certificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_listbyresourcegroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificatepatchresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificatepatchresourceproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificateproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_hostingenvironmentprofile.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/version.go diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/README.md new file mode 100644 index 000000000000..5f50ba677e5c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/README.md @@ -0,0 +1,381 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders` Documentation + +The `appservicecertificateorders` SDK allows for interaction with Azure Resource Manager `certificateregistration` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders" +``` + + +### Client Initialization + +```go +client := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.AppServiceCertificateOrder{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.CreateOrUpdateCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +payload := appservicecertificateorders.AppServiceCertificateResource{ + // ... +} + + +if err := client.CreateOrUpdateCertificateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Delete` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.DeleteCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +read, err := client.DeleteCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Get` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.GetCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +read, err := client.GetCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ListCertificates` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +// alternatively `client.ListCertificates(ctx, id)` can be used to do batched pagination +items, err := client.ListCertificatesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Reissue` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.ReissueCertificateOrderRequest{ + // ... +} + + +read, err := client.Reissue(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Renew` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.RenewCertificateOrderRequest{ + // ... +} + + +read, err := client.Renew(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ResendEmail` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.ResendEmail(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ResendRequestEmails` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.NameIdentifier{ + // ... +} + + +read, err := client.ResendRequestEmails(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveCertificateActions` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.RetrieveCertificateActions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveCertificateEmailHistory` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.RetrieveCertificateEmailHistory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveSiteSeal` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.SiteSealRequest{ + // ... +} + + +read, err := client.RetrieveSiteSeal(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Update` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.AppServiceCertificateOrderPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.UpdateCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +payload := appservicecertificateorders.AppServiceCertificatePatchResource{ + // ... +} + + +read, err := client.UpdateCertificate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ValidatePurchaseInformation` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := appservicecertificateorders.AppServiceCertificateOrder{ + // ... +} + + +read, err := client.ValidatePurchaseInformation(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.VerifyDomainOwnership` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.VerifyDomainOwnership(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/client.go new file mode 100644 index 000000000000..a4c0860883ec --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/client.go @@ -0,0 +1,26 @@ +package appservicecertificateorders + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrdersClient struct { + Client *resourcemanager.Client +} + +func NewAppServiceCertificateOrdersClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServiceCertificateOrdersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "appservicecertificateorders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServiceCertificateOrdersClient: %+v", err) + } + + return &AppServiceCertificateOrdersClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/constants.go new file mode 100644 index 000000000000..7fd04266697e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/constants.go @@ -0,0 +1,355 @@ +package appservicecertificateorders + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderActionType string + +const ( + CertificateOrderActionTypeCertificateExpirationWarning CertificateOrderActionType = "CertificateExpirationWarning" + CertificateOrderActionTypeCertificateExpired CertificateOrderActionType = "CertificateExpired" + CertificateOrderActionTypeCertificateIssued CertificateOrderActionType = "CertificateIssued" + CertificateOrderActionTypeCertificateOrderCanceled CertificateOrderActionType = "CertificateOrderCanceled" + CertificateOrderActionTypeCertificateOrderCreated CertificateOrderActionType = "CertificateOrderCreated" + CertificateOrderActionTypeCertificateRevoked CertificateOrderActionType = "CertificateRevoked" + CertificateOrderActionTypeDomainValidationComplete CertificateOrderActionType = "DomainValidationComplete" + CertificateOrderActionTypeFraudCleared CertificateOrderActionType = "FraudCleared" + CertificateOrderActionTypeFraudDetected CertificateOrderActionType = "FraudDetected" + CertificateOrderActionTypeFraudDocumentationRequired CertificateOrderActionType = "FraudDocumentationRequired" + CertificateOrderActionTypeOrgNameChange CertificateOrderActionType = "OrgNameChange" + CertificateOrderActionTypeOrgValidationComplete CertificateOrderActionType = "OrgValidationComplete" + CertificateOrderActionTypeSanDrop CertificateOrderActionType = "SanDrop" + CertificateOrderActionTypeUnknown CertificateOrderActionType = "Unknown" +) + +func PossibleValuesForCertificateOrderActionType() []string { + return []string{ + string(CertificateOrderActionTypeCertificateExpirationWarning), + string(CertificateOrderActionTypeCertificateExpired), + string(CertificateOrderActionTypeCertificateIssued), + string(CertificateOrderActionTypeCertificateOrderCanceled), + string(CertificateOrderActionTypeCertificateOrderCreated), + string(CertificateOrderActionTypeCertificateRevoked), + string(CertificateOrderActionTypeDomainValidationComplete), + string(CertificateOrderActionTypeFraudCleared), + string(CertificateOrderActionTypeFraudDetected), + string(CertificateOrderActionTypeFraudDocumentationRequired), + string(CertificateOrderActionTypeOrgNameChange), + string(CertificateOrderActionTypeOrgValidationComplete), + string(CertificateOrderActionTypeSanDrop), + string(CertificateOrderActionTypeUnknown), + } +} + +func (s *CertificateOrderActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateOrderActionType(input string) (*CertificateOrderActionType, error) { + vals := map[string]CertificateOrderActionType{ + "certificateexpirationwarning": CertificateOrderActionTypeCertificateExpirationWarning, + "certificateexpired": CertificateOrderActionTypeCertificateExpired, + "certificateissued": CertificateOrderActionTypeCertificateIssued, + "certificateordercanceled": CertificateOrderActionTypeCertificateOrderCanceled, + "certificateordercreated": CertificateOrderActionTypeCertificateOrderCreated, + "certificaterevoked": CertificateOrderActionTypeCertificateRevoked, + "domainvalidationcomplete": CertificateOrderActionTypeDomainValidationComplete, + "fraudcleared": CertificateOrderActionTypeFraudCleared, + "frauddetected": CertificateOrderActionTypeFraudDetected, + "frauddocumentationrequired": CertificateOrderActionTypeFraudDocumentationRequired, + "orgnamechange": CertificateOrderActionTypeOrgNameChange, + "orgvalidationcomplete": CertificateOrderActionTypeOrgValidationComplete, + "sandrop": CertificateOrderActionTypeSanDrop, + "unknown": CertificateOrderActionTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateOrderActionType(input) + return &out, nil +} + +type CertificateOrderStatus string + +const ( + CertificateOrderStatusCanceled CertificateOrderStatus = "Canceled" + CertificateOrderStatusDenied CertificateOrderStatus = "Denied" + CertificateOrderStatusExpired CertificateOrderStatus = "Expired" + CertificateOrderStatusIssued CertificateOrderStatus = "Issued" + CertificateOrderStatusNotSubmitted CertificateOrderStatus = "NotSubmitted" + CertificateOrderStatusPendingRekey CertificateOrderStatus = "PendingRekey" + CertificateOrderStatusPendingissuance CertificateOrderStatus = "Pendingissuance" + CertificateOrderStatusPendingrevocation CertificateOrderStatus = "Pendingrevocation" + CertificateOrderStatusRevoked CertificateOrderStatus = "Revoked" + CertificateOrderStatusUnused CertificateOrderStatus = "Unused" +) + +func PossibleValuesForCertificateOrderStatus() []string { + return []string{ + string(CertificateOrderStatusCanceled), + string(CertificateOrderStatusDenied), + string(CertificateOrderStatusExpired), + string(CertificateOrderStatusIssued), + string(CertificateOrderStatusNotSubmitted), + string(CertificateOrderStatusPendingRekey), + string(CertificateOrderStatusPendingissuance), + string(CertificateOrderStatusPendingrevocation), + string(CertificateOrderStatusRevoked), + string(CertificateOrderStatusUnused), + } +} + +func (s *CertificateOrderStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateOrderStatus(input string) (*CertificateOrderStatus, error) { + vals := map[string]CertificateOrderStatus{ + "canceled": CertificateOrderStatusCanceled, + "denied": CertificateOrderStatusDenied, + "expired": CertificateOrderStatusExpired, + "issued": CertificateOrderStatusIssued, + "notsubmitted": CertificateOrderStatusNotSubmitted, + "pendingrekey": CertificateOrderStatusPendingRekey, + "pendingissuance": CertificateOrderStatusPendingissuance, + "pendingrevocation": CertificateOrderStatusPendingrevocation, + "revoked": CertificateOrderStatusRevoked, + "unused": CertificateOrderStatusUnused, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateOrderStatus(input) + return &out, nil +} + +type CertificateProductType string + +const ( + CertificateProductTypeStandardDomainValidatedSsl CertificateProductType = "StandardDomainValidatedSsl" + CertificateProductTypeStandardDomainValidatedWildCardSsl CertificateProductType = "StandardDomainValidatedWildCardSsl" +) + +func PossibleValuesForCertificateProductType() []string { + return []string{ + string(CertificateProductTypeStandardDomainValidatedSsl), + string(CertificateProductTypeStandardDomainValidatedWildCardSsl), + } +} + +func (s *CertificateProductType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProductType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProductType(input string) (*CertificateProductType, error) { + vals := map[string]CertificateProductType{ + "standarddomainvalidatedssl": CertificateProductTypeStandardDomainValidatedSsl, + "standarddomainvalidatedwildcardssl": CertificateProductTypeStandardDomainValidatedWildCardSsl, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProductType(input) + return &out, nil +} + +type KeyVaultSecretStatus string + +const ( + KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault KeyVaultSecretStatus = "AzureServiceUnauthorizedToAccessKeyVault" + KeyVaultSecretStatusCertificateOrderFailed KeyVaultSecretStatus = "CertificateOrderFailed" + KeyVaultSecretStatusExternalPrivateKey KeyVaultSecretStatus = "ExternalPrivateKey" + KeyVaultSecretStatusInitialized KeyVaultSecretStatus = "Initialized" + KeyVaultSecretStatusKeyVaultDoesNotExist KeyVaultSecretStatus = "KeyVaultDoesNotExist" + KeyVaultSecretStatusKeyVaultSecretDoesNotExist KeyVaultSecretStatus = "KeyVaultSecretDoesNotExist" + KeyVaultSecretStatusOperationNotPermittedOnKeyVault KeyVaultSecretStatus = "OperationNotPermittedOnKeyVault" + KeyVaultSecretStatusSucceeded KeyVaultSecretStatus = "Succeeded" + KeyVaultSecretStatusUnknown KeyVaultSecretStatus = "Unknown" + KeyVaultSecretStatusUnknownError KeyVaultSecretStatus = "UnknownError" + KeyVaultSecretStatusWaitingOnCertificateOrder KeyVaultSecretStatus = "WaitingOnCertificateOrder" +) + +func PossibleValuesForKeyVaultSecretStatus() []string { + return []string{ + string(KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault), + string(KeyVaultSecretStatusCertificateOrderFailed), + string(KeyVaultSecretStatusExternalPrivateKey), + string(KeyVaultSecretStatusInitialized), + string(KeyVaultSecretStatusKeyVaultDoesNotExist), + string(KeyVaultSecretStatusKeyVaultSecretDoesNotExist), + string(KeyVaultSecretStatusOperationNotPermittedOnKeyVault), + string(KeyVaultSecretStatusSucceeded), + string(KeyVaultSecretStatusUnknown), + string(KeyVaultSecretStatusUnknownError), + string(KeyVaultSecretStatusWaitingOnCertificateOrder), + } +} + +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { + vals := map[string]KeyVaultSecretStatus{ + "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, + "certificateorderfailed": KeyVaultSecretStatusCertificateOrderFailed, + "externalprivatekey": KeyVaultSecretStatusExternalPrivateKey, + "initialized": KeyVaultSecretStatusInitialized, + "keyvaultdoesnotexist": KeyVaultSecretStatusKeyVaultDoesNotExist, + "keyvaultsecretdoesnotexist": KeyVaultSecretStatusKeyVaultSecretDoesNotExist, + "operationnotpermittedonkeyvault": KeyVaultSecretStatusOperationNotPermittedOnKeyVault, + "succeeded": KeyVaultSecretStatusSucceeded, + "unknown": KeyVaultSecretStatusUnknown, + "unknownerror": KeyVaultSecretStatusUnknownError, + "waitingoncertificateorder": KeyVaultSecretStatusWaitingOnCertificateOrder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSecretStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResourceNotRenewableReason string + +const ( + ResourceNotRenewableReasonExpirationNotInRenewalTimeRange ResourceNotRenewableReason = "ExpirationNotInRenewalTimeRange" + ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal ResourceNotRenewableReason = "RegistrationStatusNotSupportedForRenewal" + ResourceNotRenewableReasonSubscriptionNotActive ResourceNotRenewableReason = "SubscriptionNotActive" +) + +func PossibleValuesForResourceNotRenewableReason() []string { + return []string{ + string(ResourceNotRenewableReasonExpirationNotInRenewalTimeRange), + string(ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal), + string(ResourceNotRenewableReasonSubscriptionNotActive), + } +} + +func (s *ResourceNotRenewableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceNotRenewableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceNotRenewableReason(input string) (*ResourceNotRenewableReason, error) { + vals := map[string]ResourceNotRenewableReason{ + "expirationnotinrenewaltimerange": ResourceNotRenewableReasonExpirationNotInRenewalTimeRange, + "registrationstatusnotsupportedforrenewal": ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal, + "subscriptionnotactive": ResourceNotRenewableReasonSubscriptionNotActive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceNotRenewableReason(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/id_certificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/id_certificate.go new file mode 100644 index 000000000000..52d3ae3dfc5b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/id_certificate.go @@ -0,0 +1,139 @@ +package appservicecertificateorders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, certificateOrderName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + CertificateName: certificateName, + } +} + +// ParseCertificateID parses 'input' into a CertificateId +func ParseCertificateID(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateIDInsensitively parses 'input' case-insensitively into a CertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateIDInsensitively(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate ID +func (id CertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderName"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateName"), + } +} + +// String returns a human-readable description of this Certificate ID +func (id CertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/id_certificateorder.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/id_certificateorder.go new file mode 100644 index 000000000000..5b7400058950 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/id_certificateorder.go @@ -0,0 +1,130 @@ +package appservicecertificateorders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateOrderId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderId{} + +// CertificateOrderId is a struct representing the Resource ID for a Certificate Order +type CertificateOrderId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string +} + +// NewCertificateOrderID returns a new CertificateOrderId struct +func NewCertificateOrderID(subscriptionId string, resourceGroupName string, certificateOrderName string) CertificateOrderId { + return CertificateOrderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + } +} + +// ParseCertificateOrderID parses 'input' into a CertificateOrderId +func ParseCertificateOrderID(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderIDInsensitively parses 'input' case-insensitively into a CertificateOrderId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderIDInsensitively(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + return nil +} + +// ValidateCertificateOrderID checks that 'input' can be parsed as a Certificate Order ID +func ValidateCertificateOrderID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateOrderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order ID +func (id CertificateOrderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order ID +func (id CertificateOrderId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderName"), + } +} + +// String returns a human-readable description of this Certificate Order ID +func (id CertificateOrderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + } + return fmt.Sprintf("Certificate Order (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_createorupdate.go new file mode 100644 index 000000000000..0ee50f716941 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_createorupdate.go @@ -0,0 +1,75 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// CreateOrUpdate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdate(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AppServiceCertificateOrdersClient) CreateOrUpdateThenPoll(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_createorupdatecertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_createorupdatecertificate.go new file mode 100644 index 000000000000..f8d50a20ddcb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_createorupdatecertificate.go @@ -0,0 +1,75 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateCertificateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// CreateOrUpdateCertificate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificateResource) (result CreateOrUpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateCertificateThenPoll performs CreateOrUpdateCertificate then polls until it's completed +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificateThenPoll(ctx context.Context, id CertificateId, input AppServiceCertificateResource) error { + result, err := c.CreateOrUpdateCertificate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateCertificate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateCertificate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_delete.go new file mode 100644 index 000000000000..f8f40a08c11d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_delete.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AppServiceCertificateOrdersClient) Delete(ctx context.Context, id CertificateOrderId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_deletecertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_deletecertificate.go new file mode 100644 index 000000000000..1bd00712f787 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_deletecertificate.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteCertificate ... +func (c AppServiceCertificateOrdersClient) DeleteCertificate(ctx context.Context, id CertificateId) (result DeleteCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_get.go new file mode 100644 index 000000000000..452a170346a4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_get.go @@ -0,0 +1,53 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// Get ... +func (c AppServiceCertificateOrdersClient) Get(ctx context.Context, id CertificateOrderId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateOrder + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_getcertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_getcertificate.go new file mode 100644 index 000000000000..0418d2893491 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_getcertificate.go @@ -0,0 +1,53 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// GetCertificate ... +func (c AppServiceCertificateOrdersClient) GetCertificate(ctx context.Context, id CertificateId) (result GetCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_list.go new file mode 100644 index 000000000000..dc2a1437f6de --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_list.go @@ -0,0 +1,106 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateOrder +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateOrder +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AppServiceCertificateOrdersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateOrder `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceCertificateOrderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_listbyresourcegroup.go new file mode 100644 index 000000000000..e800bd4359eb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateOrder +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateOrder +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AppServiceCertificateOrdersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateOrder `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceCertificateOrderOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_listcertificates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_listcertificates.go new file mode 100644 index 000000000000..04a478191c0b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_listcertificates.go @@ -0,0 +1,105 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListCertificatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateResource +} + +type ListCertificatesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateResource +} + +type ListCertificatesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCertificatesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListCertificates ... +func (c AppServiceCertificateOrdersClient) ListCertificates(ctx context.Context, id CertificateOrderId) (result ListCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCertificatesCustomPager{}, + Path: fmt.Sprintf("%s/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCertificatesComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListCertificatesComplete(ctx context.Context, id CertificateOrderId) (ListCertificatesCompleteResult, error) { + return c.ListCertificatesCompleteMatchingPredicate(ctx, id, AppServiceCertificateResourceOperationPredicate{}) +} + +// ListCertificatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCertificatesCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate AppServiceCertificateResourceOperationPredicate) (result ListCertificatesCompleteResult, err error) { + items := make([]AppServiceCertificateResource, 0) + + resp, err := c.ListCertificates(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCertificatesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_reissue.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_reissue.go new file mode 100644 index 000000000000..91b863f81f7e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_reissue.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Reissue ... +func (c AppServiceCertificateOrdersClient) Reissue(ctx context.Context, id CertificateOrderId, input ReissueCertificateOrderRequest) (result ReissueOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reissue", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_renew.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_renew.go new file mode 100644 index 000000000000..0d15451ed17f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_renew.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Renew ... +func (c AppServiceCertificateOrdersClient) Renew(ctx context.Context, id CertificateOrderId, input RenewCertificateOrderRequest) (result RenewOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renew", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_resendemail.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_resendemail.go new file mode 100644 index 000000000000..49de4389c594 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_resendemail.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResendEmailOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendEmail ... +func (c AppServiceCertificateOrdersClient) ResendEmail(ctx context.Context, id CertificateOrderId) (result ResendEmailOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendEmail", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_resendrequestemails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_resendrequestemails.go new file mode 100644 index 000000000000..e758b4dd7068 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_resendrequestemails.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResendRequestEmailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendRequestEmails ... +func (c AppServiceCertificateOrdersClient) ResendRequestEmails(ctx context.Context, id CertificateOrderId, input NameIdentifier) (result ResendRequestEmailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendRequestEmails", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievecertificateactions.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievecertificateactions.go new file mode 100644 index 000000000000..51a8af70e7ff --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievecertificateactions.go @@ -0,0 +1,54 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetrieveCertificateActionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateOrderAction +} + +// RetrieveCertificateActions ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateActions(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateActionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveCertificateActions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []CertificateOrderAction + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievecertificateemailhistory.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievecertificateemailhistory.go new file mode 100644 index 000000000000..84feccdb8042 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievecertificateemailhistory.go @@ -0,0 +1,54 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetrieveCertificateEmailHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateEmail +} + +// RetrieveCertificateEmailHistory ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateEmailHistory(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateEmailHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveEmailHistory", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []CertificateEmail + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievesiteseal.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievesiteseal.go new file mode 100644 index 000000000000..160d1b5010b3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_retrievesiteseal.go @@ -0,0 +1,58 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetrieveSiteSealOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSeal +} + +// RetrieveSiteSeal ... +func (c AppServiceCertificateOrdersClient) RetrieveSiteSeal(ctx context.Context, id CertificateOrderId, input SiteSealRequest) (result RetrieveSiteSealOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveSiteSeal", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSeal + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_update.go new file mode 100644 index 000000000000..cebc44fbccc0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_update.go @@ -0,0 +1,57 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// Update ... +func (c AppServiceCertificateOrdersClient) Update(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrderPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateOrder + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_updatecertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_updatecertificate.go new file mode 100644 index 000000000000..8ebfd637ea56 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_updatecertificate.go @@ -0,0 +1,57 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// UpdateCertificate ... +func (c AppServiceCertificateOrdersClient) UpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificatePatchResource) (result UpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_validatepurchaseinformation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_validatepurchaseinformation.go new file mode 100644 index 000000000000..1a4c9a08f692 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_validatepurchaseinformation.go @@ -0,0 +1,52 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidatePurchaseInformationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ValidatePurchaseInformation ... +func (c AppServiceCertificateOrdersClient) ValidatePurchaseInformation(ctx context.Context, id commonids.SubscriptionId, input AppServiceCertificateOrder) (result ValidatePurchaseInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/validateCertificateRegistrationInformation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_verifydomainownership.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_verifydomainownership.go new file mode 100644 index 000000000000..413d50089946 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/method_verifydomainownership.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifyDomainOwnershipOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// VerifyDomainOwnership ... +func (c AppServiceCertificateOrdersClient) VerifyDomainOwnership(ctx context.Context, id CertificateOrderId) (result VerifyDomainOwnershipOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/verifyDomainOwnership", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificate.go new file mode 100644 index 000000000000..5572932e2570 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificate.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificate struct { + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + ProvisioningState *KeyVaultSecretStatus `json:"provisioningState,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorder.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorder.go new file mode 100644 index 000000000000..3f171abb6db2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorder.go @@ -0,0 +1,14 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrder struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificateOrderProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go new file mode 100644 index 000000000000..f0b6b7d477df --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificateOrderPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go new file mode 100644 index 000000000000..4657e81b440a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go @@ -0,0 +1,69 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderPatchResourceProperties struct { + AppServiceCertificateNotRenewableReasons *[]ResourceNotRenewableReason `json:"appServiceCertificateNotRenewableReasons,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Certificates *map[string]AppServiceCertificate `json:"certificates,omitempty"` + Contact *CertificateOrderContact `json:"contact,omitempty"` + Csr *string `json:"csr,omitempty"` + DistinguishedName *string `json:"distinguishedName,omitempty"` + DomainVerificationToken *string `json:"domainVerificationToken,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + Intermediate *CertificateDetails `json:"intermediate,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` + LastCertificateIssuanceTime *string `json:"lastCertificateIssuanceTime,omitempty"` + NextAutoRenewalTimeStamp *string `json:"nextAutoRenewalTimeStamp,omitempty"` + ProductType CertificateProductType `json:"productType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Root *CertificateDetails `json:"root,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignedCertificate *CertificateDetails `json:"signedCertificate,omitempty"` + Status *CertificateOrderStatus `json:"status,omitempty"` + ValidityInYears *int64 `json:"validityInYears,omitempty"` +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetLastCertificateIssuanceTimeAsTime() (*time.Time, error) { + if o.LastCertificateIssuanceTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCertificateIssuanceTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetLastCertificateIssuanceTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCertificateIssuanceTime = &formatted +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetNextAutoRenewalTimeStampAsTime() (*time.Time, error) { + if o.NextAutoRenewalTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextAutoRenewalTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetNextAutoRenewalTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextAutoRenewalTimeStamp = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderproperties.go new file mode 100644 index 000000000000..9b30d4ae973c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateorderproperties.go @@ -0,0 +1,69 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderProperties struct { + AppServiceCertificateNotRenewableReasons *[]ResourceNotRenewableReason `json:"appServiceCertificateNotRenewableReasons,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Certificates *map[string]AppServiceCertificate `json:"certificates,omitempty"` + Contact *CertificateOrderContact `json:"contact,omitempty"` + Csr *string `json:"csr,omitempty"` + DistinguishedName *string `json:"distinguishedName,omitempty"` + DomainVerificationToken *string `json:"domainVerificationToken,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + Intermediate *CertificateDetails `json:"intermediate,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` + LastCertificateIssuanceTime *string `json:"lastCertificateIssuanceTime,omitempty"` + NextAutoRenewalTimeStamp *string `json:"nextAutoRenewalTimeStamp,omitempty"` + ProductType CertificateProductType `json:"productType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Root *CertificateDetails `json:"root,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignedCertificate *CertificateDetails `json:"signedCertificate,omitempty"` + Status *CertificateOrderStatus `json:"status,omitempty"` + ValidityInYears *int64 `json:"validityInYears,omitempty"` +} + +func (o *AppServiceCertificateOrderProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *AppServiceCertificateOrderProperties) GetLastCertificateIssuanceTimeAsTime() (*time.Time, error) { + if o.LastCertificateIssuanceTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCertificateIssuanceTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetLastCertificateIssuanceTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCertificateIssuanceTime = &formatted +} + +func (o *AppServiceCertificateOrderProperties) GetNextAutoRenewalTimeStampAsTime() (*time.Time, error) { + if o.NextAutoRenewalTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextAutoRenewalTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetNextAutoRenewalTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextAutoRenewalTimeStamp = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificatepatchresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificatepatchresource.go new file mode 100644 index 000000000000..8f8d91b6c870 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificatepatchresource.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificatePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificate `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateresource.go new file mode 100644 index 000000000000..7cd601e38f72 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_appservicecertificateresource.go @@ -0,0 +1,14 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificate `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificatedetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificatedetails.go new file mode 100644 index 000000000000..6905351a7c5f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificatedetails.go @@ -0,0 +1,46 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateDetails struct { + Issuer *string `json:"issuer,omitempty"` + NotAfter *string `json:"notAfter,omitempty"` + NotBefore *string `json:"notBefore,omitempty"` + RawData *string `json:"rawData,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignatureAlgorithm *string `json:"signatureAlgorithm,omitempty"` + Subject *string `json:"subject,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Version *int64 `json:"version,omitempty"` +} + +func (o *CertificateDetails) GetNotAfterAsTime() (*time.Time, error) { + if o.NotAfter == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotAfter, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateDetails) SetNotAfterAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotAfter = &formatted +} + +func (o *CertificateDetails) GetNotBeforeAsTime() (*time.Time, error) { + if o.NotBefore == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotBefore, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateDetails) SetNotBeforeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotBefore = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateemail.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateemail.go new file mode 100644 index 000000000000..27ec4e4d6f2c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateemail.go @@ -0,0 +1,27 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateEmail struct { + EmailId *string `json:"emailId,omitempty"` + TimeStamp *string `json:"timeStamp,omitempty"` +} + +func (o *CertificateEmail) GetTimeStampAsTime() (*time.Time, error) { + if o.TimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateEmail) SetTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeStamp = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateorderaction.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateorderaction.go new file mode 100644 index 000000000000..5a7f75ca6644 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateorderaction.go @@ -0,0 +1,27 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderAction struct { + ActionType *CertificateOrderActionType `json:"actionType,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` +} + +func (o *CertificateOrderAction) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateOrderAction) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateordercontact.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateordercontact.go new file mode 100644 index 000000000000..65e867d21029 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_certificateordercontact.go @@ -0,0 +1,11 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderContact struct { + Email *string `json:"email,omitempty"` + NameFirst *string `json:"nameFirst,omitempty"` + NameLast *string `json:"nameLast,omitempty"` + Phone *string `json:"phone,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_nameidentifier.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_nameidentifier.go new file mode 100644 index 000000000000..72477ac557df --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_nameidentifier.go @@ -0,0 +1,8 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequest.go new file mode 100644 index 000000000000..15d4fec95725 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequest.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueCertificateOrderRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReissueCertificateOrderRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go new file mode 100644 index 000000000000..edcc06283c9b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go @@ -0,0 +1,11 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueCertificateOrderRequestProperties struct { + Csr *string `json:"csr,omitempty"` + DelayExistingRevokeInHours *int64 `json:"delayExistingRevokeInHours,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequest.go new file mode 100644 index 000000000000..cacc0bada974 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequest.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOrderRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RenewCertificateOrderRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go new file mode 100644 index 000000000000..161c783b54e5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOrderRequestProperties struct { + Csr *string `json:"csr,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_siteseal.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_siteseal.go new file mode 100644 index 000000000000..64f302c54e8b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_siteseal.go @@ -0,0 +1,8 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSeal struct { + Html string `json:"html"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_sitesealrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_sitesealrequest.go new file mode 100644 index 000000000000..ed81319016d8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/model_sitesealrequest.go @@ -0,0 +1,9 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSealRequest struct { + LightTheme *bool `json:"lightTheme,omitempty"` + Locale *string `json:"locale,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/predicates.go new file mode 100644 index 000000000000..e7457040d0bd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/predicates.go @@ -0,0 +1,70 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceCertificateOrderOperationPredicate) Matches(input AppServiceCertificateOrder) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type AppServiceCertificateResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceCertificateResourceOperationPredicate) Matches(input AppServiceCertificateResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/version.go new file mode 100644 index 000000000000..5f031a717f64 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders/version.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-12-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/appservicecertificateorders/2023-12-01" +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/README.md new file mode 100644 index 000000000000..7dee868671a8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/README.md @@ -0,0 +1,125 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates` Documentation + +The `certificates` SDK allows for interaction with Azure Resource Manager `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" +``` + + +### Client Initialization + +```go +client := certificates.NewCertificatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificatesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +payload := certificates.Certificate{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CertificatesClient.Delete` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.Get` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, certificates.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, certificates.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificatesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificatesClient.Update` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +payload := certificates.CertificatePatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/client.go new file mode 100644 index 000000000000..f045f1b92657 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/client.go @@ -0,0 +1,26 @@ +package certificates + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatesClient struct { + Client *resourcemanager.Client +} + +func NewCertificatesClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificatesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "certificates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificatesClient: %+v", err) + } + + return &CertificatesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/constants.go new file mode 100644 index 000000000000..afe3445c7e67 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/constants.go @@ -0,0 +1,78 @@ +package certificates + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultSecretStatus string + +const ( + KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault KeyVaultSecretStatus = "AzureServiceUnauthorizedToAccessKeyVault" + KeyVaultSecretStatusCertificateOrderFailed KeyVaultSecretStatus = "CertificateOrderFailed" + KeyVaultSecretStatusExternalPrivateKey KeyVaultSecretStatus = "ExternalPrivateKey" + KeyVaultSecretStatusInitialized KeyVaultSecretStatus = "Initialized" + KeyVaultSecretStatusKeyVaultDoesNotExist KeyVaultSecretStatus = "KeyVaultDoesNotExist" + KeyVaultSecretStatusKeyVaultSecretDoesNotExist KeyVaultSecretStatus = "KeyVaultSecretDoesNotExist" + KeyVaultSecretStatusOperationNotPermittedOnKeyVault KeyVaultSecretStatus = "OperationNotPermittedOnKeyVault" + KeyVaultSecretStatusSucceeded KeyVaultSecretStatus = "Succeeded" + KeyVaultSecretStatusUnknown KeyVaultSecretStatus = "Unknown" + KeyVaultSecretStatusUnknownError KeyVaultSecretStatus = "UnknownError" + KeyVaultSecretStatusWaitingOnCertificateOrder KeyVaultSecretStatus = "WaitingOnCertificateOrder" +) + +func PossibleValuesForKeyVaultSecretStatus() []string { + return []string{ + string(KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault), + string(KeyVaultSecretStatusCertificateOrderFailed), + string(KeyVaultSecretStatusExternalPrivateKey), + string(KeyVaultSecretStatusInitialized), + string(KeyVaultSecretStatusKeyVaultDoesNotExist), + string(KeyVaultSecretStatusKeyVaultSecretDoesNotExist), + string(KeyVaultSecretStatusOperationNotPermittedOnKeyVault), + string(KeyVaultSecretStatusSucceeded), + string(KeyVaultSecretStatusUnknown), + string(KeyVaultSecretStatusUnknownError), + string(KeyVaultSecretStatusWaitingOnCertificateOrder), + } +} + +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { + vals := map[string]KeyVaultSecretStatus{ + "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, + "certificateorderfailed": KeyVaultSecretStatusCertificateOrderFailed, + "externalprivatekey": KeyVaultSecretStatusExternalPrivateKey, + "initialized": KeyVaultSecretStatusInitialized, + "keyvaultdoesnotexist": KeyVaultSecretStatusKeyVaultDoesNotExist, + "keyvaultsecretdoesnotexist": KeyVaultSecretStatusKeyVaultSecretDoesNotExist, + "operationnotpermittedonkeyvault": KeyVaultSecretStatusOperationNotPermittedOnKeyVault, + "succeeded": KeyVaultSecretStatusSucceeded, + "unknown": KeyVaultSecretStatusUnknown, + "unknownerror": KeyVaultSecretStatusUnknownError, + "waitingoncertificateorder": KeyVaultSecretStatusWaitingOnCertificateOrder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSecretStatus(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/id_certificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/id_certificate.go new file mode 100644 index 000000000000..3ef853c576d9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/id_certificate.go @@ -0,0 +1,130 @@ +package certificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateName: certificateName, + } +} + +// ParseCertificateID parses 'input' into a CertificateId +func ParseCertificateID(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateIDInsensitively parses 'input' case-insensitively into a CertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateIDInsensitively(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate ID +func (id CertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateName"), + } +} + +// String returns a human-readable description of this Certificate ID +func (id CertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_createorupdate.go new file mode 100644 index 000000000000..1291b415345f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_createorupdate.go @@ -0,0 +1,75 @@ +package certificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CreateOrUpdate ... +func (c CertificatesClient) CreateOrUpdate(ctx context.Context, id CertificateId, input Certificate) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c CertificatesClient) CreateOrUpdateThenPoll(ctx context.Context, id CertificateId, input Certificate) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_delete.go new file mode 100644 index 000000000000..6f676ff9031f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_delete.go @@ -0,0 +1,47 @@ +package certificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CertificatesClient) Delete(ctx context.Context, id CertificateId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_get.go new file mode 100644 index 000000000000..50817117dad3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_get.go @@ -0,0 +1,53 @@ +package certificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Get ... +func (c CertificatesClient) Get(ctx context.Context, id CertificateId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_list.go new file mode 100644 index 000000000000..b9bba8df1772 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_list.go @@ -0,0 +1,135 @@ +package certificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c CertificatesClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c CertificatesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, CertificateOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate CertificateOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_listbyresourcegroup.go new file mode 100644 index 000000000000..94e8fdd644ab --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package certificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c CertificatesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c CertificatesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CertificateOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_update.go new file mode 100644 index 000000000000..e0cf13140fe7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/method_update.go @@ -0,0 +1,57 @@ +package certificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Update ... +func (c CertificatesClient) Update(ctx context.Context, id CertificateId, input CertificatePatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificate.go new file mode 100644 index 000000000000..354c3cbb53b1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificate.go @@ -0,0 +1,14 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CertificateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificatepatchresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificatepatchresource.go new file mode 100644 index 000000000000..438896e4c0df --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificatepatchresource.go @@ -0,0 +1,13 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CertificatePatchResourceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificatepatchresourceproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificatepatchresourceproperties.go new file mode 100644 index 000000000000..a3aec635456f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificatepatchresourceproperties.go @@ -0,0 +1,58 @@ +package certificates + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatchResourceProperties struct { + CanonicalName *string `json:"canonicalName,omitempty"` + CerBlob *string `json:"cerBlob,omitempty"` + DomainValidationMethod *string `json:"domainValidationMethod,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + KeyVaultSecretStatus *KeyVaultSecretStatus `json:"keyVaultSecretStatus,omitempty"` + Password *string `json:"password,omitempty"` + PfxBlob *string `json:"pfxBlob,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SelfLink *string `json:"selfLink,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +func (o *CertificatePatchResourceProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificatePatchResourceProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificatePatchResourceProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificatePatchResourceProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificateproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificateproperties.go new file mode 100644 index 000000000000..0d950ddcd121 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_certificateproperties.go @@ -0,0 +1,58 @@ +package certificates + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProperties struct { + CanonicalName *string `json:"canonicalName,omitempty"` + CerBlob *string `json:"cerBlob,omitempty"` + DomainValidationMethod *string `json:"domainValidationMethod,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + KeyVaultSecretStatus *KeyVaultSecretStatus `json:"keyVaultSecretStatus,omitempty"` + Password *string `json:"password,omitempty"` + PfxBlob *string `json:"pfxBlob,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SelfLink *string `json:"selfLink,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +func (o *CertificateProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificateProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_hostingenvironmentprofile.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_hostingenvironmentprofile.go new file mode 100644 index 000000000000..33ed6c863f87 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/predicates.go new file mode 100644 index 000000000000..6a9b6eaebc65 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/predicates.go @@ -0,0 +1,37 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p CertificateOperationPredicate) Matches(input Certificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/version.go new file mode 100644 index 000000000000..f30e59c6c06b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates/version.go @@ -0,0 +1,10 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-12-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/certificates/2023-12-01" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index ba2782fe8149..a9dd896c2974 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -357,6 +357,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-02-01/securitypolici github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2024-09-01/rules github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2025-04-15/afdcustomdomains github.com/hashicorp/go-azure-sdk/resource-manager/cdn/2025-06-01/afdendpoints +github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01 github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/capabilities github.com/hashicorp/go-azure-sdk/resource-manager/chaosstudio/2023-11-01/capabilitytypes @@ -1235,6 +1236,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/appserviceenvi github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/resourceproviders github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/staticsites github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceplans +github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps github.com/hashicorp/go-azure-sdk/resource-manager/webpubsub/2024-03-01 github.com/hashicorp/go-azure-sdk/resource-manager/webpubsub/2024-03-01/webpubsub From a510e301bcc566c0634a69fc0bf7faf810e62735 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 13:00:35 -0600 Subject: [PATCH 14/18] minor improvement and removal of redundant SetId calls --- ..._slot_virtual_network_swift_connection_resource.go | 1 - ...rvice_virtual_network_swift_connection_resource.go | 1 - .../web/function_app_host_keys_data_source.go | 11 ++++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go b/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go index 7ca3b6b6bc39..547c07815f95 100644 --- a/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go +++ b/internal/services/web/app_service_slot_virtual_network_swift_connection_resource.go @@ -245,7 +245,6 @@ func resourceAppServiceSlotVirtualNetworkSwiftConnectionDelete(d *pluginsdk.Reso if existing.Model == nil || existing.Model.Properties == nil || existing.Model.Properties.SubnetResourceId == nil { // assume deleted - d.SetId("") return nil } diff --git a/internal/services/web/app_service_virtual_network_swift_connection_resource.go b/internal/services/web/app_service_virtual_network_swift_connection_resource.go index 43306ef8c41e..06d972f34d86 100644 --- a/internal/services/web/app_service_virtual_network_swift_connection_resource.go +++ b/internal/services/web/app_service_virtual_network_swift_connection_resource.go @@ -231,7 +231,6 @@ func resourceAppServiceVirtualNetworkSwiftConnectionDelete(d *pluginsdk.Resource if existing.Model == nil || existing.Model.Properties == nil || existing.Model.Properties.SubnetResourceId == nil { // assume deleted - d.SetId("") return nil } diff --git a/internal/services/web/function_app_host_keys_data_source.go b/internal/services/web/function_app_host_keys_data_source.go index b7ac854851dc..d11c6e74413b 100644 --- a/internal/services/web/function_app_host_keys_data_source.go +++ b/internal/services/web/function_app_host_keys_data_source.go @@ -122,12 +122,13 @@ func dataSourceFunctionAppHostKeysRead(d *pluginsdk.ResourceData, meta interface } d.Set("default_function_key", defaultFunctionKey) + systemKeys := pointer.From(resp.Model.SystemKeys) // The name of the EventGrid System Key has changed from version 1.x to version 2.x: // https://learn.microsoft.com/en-us/azure/azure-functions/event-grid-how-tos?tabs=v2%2Cportal#system-key // This block accommodates both keys. eventGridExtensionConfigKey := "" for _, key := range []string{"eventgridextensionconfig_extension", "eventgrid_extension"} { - if v, ok := pointer.From(resp.Model.SystemKeys)[key]; ok { + if v, ok := systemKeys[key]; ok { eventGridExtensionConfigKey = v break } @@ -135,25 +136,25 @@ func dataSourceFunctionAppHostKeysRead(d *pluginsdk.ResourceData, meta interface d.Set("event_grid_extension_config_key", eventGridExtensionConfigKey) signalrExtensionKey := "" - if v, ok := pointer.From(resp.Model.SystemKeys)["signalr_extension"]; ok { + if v, ok := systemKeys["signalr_extension"]; ok { signalrExtensionKey = v } d.Set("signalr_extension_key", signalrExtensionKey) durableTaskExtensionKey := "" - if v, ok := pointer.From(resp.Model.SystemKeys)["durabletask_extension"]; ok { + if v, ok := systemKeys["durabletask_extension"]; ok { durableTaskExtensionKey = v } d.Set("durabletask_extension_key", durableTaskExtensionKey) webPubSubExtensionKey := "" - if v, ok := pointer.From(resp.Model.SystemKeys)["webpubsub_extension"]; ok { + if v, ok := systemKeys["webpubsub_extension"]; ok { webPubSubExtensionKey = v } d.Set("webpubsub_extension_key", webPubSubExtensionKey) blobsExtensionKey := "" - if v, ok := pointer.From(resp.Model.SystemKeys)["blobs_extension"]; ok { + if v, ok := systemKeys["blobs_extension"]; ok { blobsExtensionKey = v } d.Set("blobs_extension_key", blobsExtensionKey) From 24f54cda2d8bc82e8793bf94bcafc8885011a7e9 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Wed, 18 Mar 2026 13:47:56 -0600 Subject: [PATCH 15/18] linting --- .../web/app_service_custom_hostname_binding_resource.go | 2 +- website/docs/d/app_service_certificate.html.markdown | 6 ++++++ website/docs/d/app_service_certificate_order.html.markdown | 6 ++++++ website/docs/d/function_app_host_keys.html.markdown | 6 ++++++ website/docs/r/app_service_certificate.html.markdown | 6 ++++++ .../docs/r/app_service_certificate_binding.html.markdown | 6 ++++++ website/docs/r/app_service_certificate_order.html.markdown | 6 ++++++ .../r/app_service_custom_hostname_binding.html.markdown | 6 ++++++ .../docs/r/app_service_managed_certificate.html.markdown | 6 ++++++ .../app_service_slot_custom_hostname_binding.html.markdown | 6 ++++++ ...vice_slot_virtual_network_swift_connection.html.markdown | 6 ++++++ ...p_service_virtual_network_swift_connection.html.markdown | 6 ++++++ 12 files changed, 67 insertions(+), 1 deletion(-) diff --git a/internal/services/web/app_service_custom_hostname_binding_resource.go b/internal/services/web/app_service_custom_hostname_binding_resource.go index b07cb0097657..17cd4300fcbe 100644 --- a/internal/services/web/app_service_custom_hostname_binding_resource.go +++ b/internal/services/web/app_service_custom_hostname_binding_resource.go @@ -163,7 +163,7 @@ func resourceAppServiceCustomHostnameBindingRead(d *pluginsdk.ResourceData, meta if model := resp.Model; model != nil { if props := model.Properties; props != nil { - d.Set("ssl_state", props.SslState) + d.Set("ssl_state", pointer.FromEnum(props.SslState)) d.Set("thumbprint", props.Thumbprint) d.Set("virtual_ip", props.VirtualIP) } diff --git a/website/docs/d/app_service_certificate.html.markdown b/website/docs/d/app_service_certificate.html.markdown index b65ea7055d80..d386c1864c9c 100644 --- a/website/docs/d/app_service_certificate.html.markdown +++ b/website/docs/d/app_service_certificate.html.markdown @@ -57,3 +57,9 @@ The following attributes are exported: The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions: * `read` - (Defaults to 5 minutes) Used when retrieving the App Service Certificate. + +## API Providers + +This data source uses the following Azure API Providers: + +* `Microsoft.Web` - 2023-12-01 diff --git a/website/docs/d/app_service_certificate_order.html.markdown b/website/docs/d/app_service_certificate_order.html.markdown index 0020fc1ef5c3..cd5505811aca 100644 --- a/website/docs/d/app_service_certificate_order.html.markdown +++ b/website/docs/d/app_service_certificate_order.html.markdown @@ -82,3 +82,9 @@ output "certificate_order_id" { The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions: * `read` - (Defaults to 5 minutes) Used when retrieving the App Service Certificate Order. + +## API Providers + +This data source uses the following Azure API Providers: + +* `Microsoft.CertificateRegistration` - 2023-12-01 diff --git a/website/docs/d/function_app_host_keys.html.markdown b/website/docs/d/function_app_host_keys.html.markdown index 19499f28d1df..61003cfba89c 100644 --- a/website/docs/d/function_app_host_keys.html.markdown +++ b/website/docs/d/function_app_host_keys.html.markdown @@ -52,3 +52,9 @@ In addition to the Arguments listed above - the following Attributes are exporte The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions: * `read` - (Defaults to 5 minutes) Used when retrieving the Function App Host Keys + +## API Providers + +This data source uses the following Azure API Providers: + +* `Microsoft.Web` - 2023-12-01 diff --git a/website/docs/r/app_service_certificate.html.markdown b/website/docs/r/app_service_certificate.html.markdown index 7739e7b06452..e54f53f56a47 100644 --- a/website/docs/r/app_service_certificate.html.markdown +++ b/website/docs/r/app_service_certificate.html.markdown @@ -106,3 +106,9 @@ App Service Certificates can be imported using the `resource id`, e.g. ```shell terraform import azurerm_app_service_certificate.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/certificates/certificate1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.Web` - 2023-12-01 diff --git a/website/docs/r/app_service_certificate_binding.html.markdown b/website/docs/r/app_service_certificate_binding.html.markdown index fbf0de0a4642..36e5a8e9e574 100644 --- a/website/docs/r/app_service_certificate_binding.html.markdown +++ b/website/docs/r/app_service_certificate_binding.html.markdown @@ -120,3 +120,9 @@ App Service Certificate Bindings can be imported using the `hostname_binding_id` ```shell terraform import azurerm_app_service_certificate_binding.example "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/sites/instance1/hostNameBindings/mywebsite.com|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/certificates/mywebsite.com" ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.Web` - 2023-12-01 diff --git a/website/docs/r/app_service_certificate_order.html.markdown b/website/docs/r/app_service_certificate_order.html.markdown index 38e909be41fe..fc11c38bcf7c 100644 --- a/website/docs/r/app_service_certificate_order.html.markdown +++ b/website/docs/r/app_service_certificate_order.html.markdown @@ -106,3 +106,9 @@ App Service Certificate Orders can be imported using the `resource id`, e.g. ```shell terraform import azurerm_app_service_certificate_order.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.CertificateRegistration/certificateOrders/certificateorder1 ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.CertificateRegistration` - 2023-12-01 diff --git a/website/docs/r/app_service_custom_hostname_binding.html.markdown b/website/docs/r/app_service_custom_hostname_binding.html.markdown index cd75d2446851..138688d28f54 100644 --- a/website/docs/r/app_service_custom_hostname_binding.html.markdown +++ b/website/docs/r/app_service_custom_hostname_binding.html.markdown @@ -93,3 +93,9 @@ App Service Custom Hostname Bindings can be imported using the `resource id`, e. ```shell terraform import azurerm_app_service_custom_hostname_binding.mywebsite /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/sites/instance1/hostNameBindings/mywebsite.com ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.Web` - 2023-12-01 diff --git a/website/docs/r/app_service_managed_certificate.html.markdown b/website/docs/r/app_service_managed_certificate.html.markdown index c53eee286ed0..9f4602d42b63 100644 --- a/website/docs/r/app_service_managed_certificate.html.markdown +++ b/website/docs/r/app_service_managed_certificate.html.markdown @@ -132,3 +132,9 @@ App Service Managed Certificates can be imported using the `resource id`, e.g. ```shell terraform import azurerm_app_service_managed_certificate.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resGroup1/providers/Microsoft.Web/certificates/customhost.contoso.com ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.Web` - 2023-12-01 diff --git a/website/docs/r/app_service_slot_custom_hostname_binding.html.markdown b/website/docs/r/app_service_slot_custom_hostname_binding.html.markdown index e854fb6435e4..18038a59baa5 100644 --- a/website/docs/r/app_service_slot_custom_hostname_binding.html.markdown +++ b/website/docs/r/app_service_slot_custom_hostname_binding.html.markdown @@ -85,3 +85,9 @@ App Service Custom Hostname Bindings can be imported using the `resource id`, e. ```shell terraform import azurerm_app_service_slot_custom_hostname_binding.mywebsite /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/sites/instance1/slots/staging/hostNameBindings/mywebsite.com ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.Web` - 2023-12-01 diff --git a/website/docs/r/app_service_slot_virtual_network_swift_connection.html.markdown b/website/docs/r/app_service_slot_virtual_network_swift_connection.html.markdown index 9fef7c3cfffd..ac0e86603664 100644 --- a/website/docs/r/app_service_slot_virtual_network_swift_connection.html.markdown +++ b/website/docs/r/app_service_slot_virtual_network_swift_connection.html.markdown @@ -107,3 +107,9 @@ App Service Slot Virtual Network Associations can be imported using the `resourc ```shell terraform import azurerm_app_service_slot_virtual_network_swift_connection.myassociation /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/sites/instance1/slots/staging/config/virtualNetwork ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.Web` - 2023-12-01 diff --git a/website/docs/r/app_service_virtual_network_swift_connection.html.markdown b/website/docs/r/app_service_virtual_network_swift_connection.html.markdown index 2bc294439425..499edc9ea1e0 100644 --- a/website/docs/r/app_service_virtual_network_swift_connection.html.markdown +++ b/website/docs/r/app_service_virtual_network_swift_connection.html.markdown @@ -182,3 +182,9 @@ App Service Virtual Network Associations can be imported using the `resource id` ```shell terraform import azurerm_app_service_virtual_network_swift_connection.myassociation /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/sites/instance1/config/virtualNetwork ``` + +## API Providers + +This resource uses the following Azure API Providers: + +* `Microsoft.Web` - 2023-12-01 From 9d7313446167ea4f82aba26195fd1faf7d10c6d2 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Fri, 20 Mar 2026 10:45:57 -0600 Subject: [PATCH 16/18] tests: fix minor issues --- .../web/app_service_certificate_resource.go | 9 +- .../app_service_certificate_resource_test.go | 267 +++++------------- ...ervice_custom_hostname_binding_resource.go | 8 +- ...e_custom_hostname_binding_resource_test.go | 236 ++++++++-------- ...rvice_managed_certificate_resource_test.go | 10 +- 5 files changed, 209 insertions(+), 321 deletions(-) diff --git a/internal/services/web/app_service_certificate_resource.go b/internal/services/web/app_service_certificate_resource.go index b145af876fcc..71b74b0a4065 100644 --- a/internal/services/web/app_service_certificate_resource.go +++ b/internal/services/web/app_service_certificate_resource.go @@ -4,7 +4,6 @@ package web import ( - "encoding/base64" "fmt" "time" @@ -172,11 +171,7 @@ func resourceAppServiceCertificateCreate(d *pluginsdk.ResourceData, meta interfa } if v := d.Get("pfx_blob").(string); v != "" { - decodedPfxBlob, err := base64.StdEncoding.DecodeString(v) - if err != nil { - return fmt.Errorf("decoding PFX blob: %+v", err) - } - certificate.Properties.PfxBlob = pointer.To(string(decodedPfxBlob)) + certificate.Properties.PfxBlob = pointer.To(v) } if v := d.Get("key_vault_secret_id").(string); v != "" { @@ -288,7 +283,7 @@ func resourceAppServiceCertificateRead(d *pluginsdk.ResourceData, meta interface if err != nil { return err } - d.Set("server_farm_id", sfID.ID()) + d.Set("app_service_plan_id", sfID.ID()) } } } diff --git a/internal/services/web/app_service_certificate_resource_test.go b/internal/services/web/app_service_certificate_resource_test.go index 1bc4e8f4858e..9fa64075a8c1 100644 --- a/internal/services/web/app_service_certificate_resource_test.go +++ b/internal/services/web/app_service_certificate_resource_test.go @@ -94,7 +94,20 @@ func TestAccAppServiceCertificate_KeyVaultIdVersionless(t *testing.T) { }) } -// TODO: add test with `app_service_plan_id` set +func TestAccAppServiceCertificate_AppServiceID(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_app_service_certificate", "test") + r := AppServiceCertificateResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.pfxWithServicePlan(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("pfx_blob", "password", "app_service_plan_id"), + }) +} func (r AppServiceCertificateResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := certificates.ParseCertificateID(state.ID) @@ -115,137 +128,78 @@ provider "azurerm" { features {} } -resource "azurerm_resource_group" "test" { - name = "acctestwebcert%[1]d" - location = "%[2]s" -} +%[1]s resource "azurerm_app_service_certificate" "test" { - name = "acctest%[1]d" + name = "acctest%[2]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location pfx_blob = filebase64("testdata/app_service_certificate.pfx") password = "terraform" } -`, data.RandomInteger, data.Locations.Primary) +`, r.template(data), data.RandomInteger) } -func (r AppServiceCertificateResource) pfxNoPassword(data acceptance.TestData) string { +func (r AppServiceCertificateResource) pfxWithServicePlan(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} } -resource "azurerm_resource_group" "test" { - name = "acctestwebcert%[1]d" - location = "%[2]s" +%[1]s + +resource "azurerm_service_plan" "test" { + name = "acctest-SP-%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + sku_name = "B1" + os_type = "Linux" } + resource "azurerm_app_service_certificate" "test" { - name = "acctest%[1]d" + name = "acctest%[2]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location - pfx_blob = filebase64("testdata/app_service_certificate_nopassword.pfx") + app_service_plan_id = azurerm_service_plan.test.id + pfx_blob = filebase64("testdata/app_service_certificate.pfx") + password = "terraform" } -`, data.RandomInteger, data.Locations.Primary) +`, r.template(data), data.RandomInteger) } -func (r AppServiceCertificateResource) keyVault(data acceptance.TestData) string { +func (r AppServiceCertificateResource) pfxNoPassword(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} } -provider "azuread" {} - -data "azurerm_client_config" "test" {} +%[1]s -data "azuread_service_principal" "test" { - display_name = "Microsoft Azure App Service" +resource "azurerm_app_service_certificate" "test" { + name = "acctest%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + pfx_blob = filebase64("testdata/app_service_certificate_nopassword.pfx") } - -resource "azurerm_resource_group" "test" { - name = "acctestwebcert%[1]d" - location = "%[2]s" +`, r.template(data), data.RandomInteger) } -resource "azurerm_key_vault" "test" { - name = "acctest%[3]s" - location = azurerm_resource_group.test.location - resource_group_name = azurerm_resource_group.test.name - - tenant_id = data.azurerm_client_config.test.tenant_id - - sku_name = "standard" - - access_policy { - tenant_id = data.azurerm_client_config.test.tenant_id - object_id = data.azurerm_client_config.test.object_id - - secret_permissions = [ - "Delete", - "Get", - "Purge", - "Set", - ] - - certificate_permissions = [ - "Create", - "Delete", - "Get", - "Purge", - "Import", - ] - } - - access_policy { - tenant_id = data.azurerm_client_config.test.tenant_id - object_id = data.azuread_service_principal.test.object_id - - secret_permissions = [ - "Get", - ] - - certificate_permissions = [ - "Get", - ] - } +func (r AppServiceCertificateResource) keyVault(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} } -resource "azurerm_key_vault_certificate" "test" { - name = "acctest%[1]d" - key_vault_id = azurerm_key_vault.test.id - - certificate { - contents = filebase64("testdata/app_service_certificate.pfx") - password = "terraform" - } - - certificate_policy { - issuer_parameters { - name = "Self" - } - - key_properties { - exportable = true - key_size = 2048 - key_type = "RSA" - reuse_key = false - } - - secret_properties { - content_type = "application/x-pkcs12" - } - } -} +%[1]s resource "azurerm_app_service_certificate" "test" { - name = "acctest%[1]d" + name = "acctest%[2]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location key_vault_secret_id = azurerm_key_vault_certificate.test.id } -`, data.RandomInteger, data.Locations.Primary, data.RandomString) +`, r.keyVaultTemplate(data), data.RandomInteger) } func (r AppServiceCertificateResource) keyVaultId(data acceptance.TestData) string { @@ -254,97 +208,16 @@ provider "azurerm" { features {} } -provider "azuread" {} - -data "azurerm_client_config" "test" {} - -data "azuread_service_principal" "test" { - display_name = "Microsoft Azure App Service" -} - -resource "azurerm_resource_group" "test" { - name = "acctestwebcert%[1]d" - location = "%[2]s" -} - -resource "azurerm_key_vault" "test" { - name = "acctest%[3]s" - location = azurerm_resource_group.test.location - resource_group_name = azurerm_resource_group.test.name - - tenant_id = data.azurerm_client_config.test.tenant_id - - sku_name = "standard" - - access_policy { - tenant_id = data.azurerm_client_config.test.tenant_id - object_id = data.azurerm_client_config.test.object_id - - secret_permissions = [ - "Delete", - "Get", - "Purge", - "Set", - ] - - certificate_permissions = [ - "Create", - "Delete", - "Get", - "Purge", - "Import", - ] - } - - access_policy { - tenant_id = data.azurerm_client_config.test.tenant_id - object_id = data.azuread_service_principal.test.object_id - - secret_permissions = [ - "Get", - ] - - certificate_permissions = [ - "Get", - ] - } -} - -resource "azurerm_key_vault_certificate" "test" { - name = "acctest%[1]d" - key_vault_id = azurerm_key_vault.test.id - - certificate { - contents = filebase64("testdata/app_service_certificate.pfx") - password = "terraform" - } - - certificate_policy { - issuer_parameters { - name = "Self" - } - - key_properties { - exportable = true - key_size = 2048 - key_type = "RSA" - reuse_key = false - } - - secret_properties { - content_type = "application/x-pkcs12" - } - } -} +%[1]s resource "azurerm_app_service_certificate" "test" { - name = "acctest%[1]d" + name = "acctest%[2]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location key_vault_id = azurerm_key_vault.test.id key_vault_secret_id = azurerm_key_vault_certificate.test.id } -`, data.RandomInteger, data.Locations.Primary, data.RandomString) +`, r.keyVaultTemplate(data), data.RandomInteger) } func (r AppServiceCertificateResource) keyVaultIdVersionless(data acceptance.TestData) string { @@ -353,21 +226,32 @@ provider "azurerm" { features {} } +%[1]s + +resource "azurerm_app_service_certificate" "test" { + name = "acctest%[2]d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + key_vault_id = azurerm_key_vault.test.id + key_vault_secret_id = azurerm_key_vault_certificate.test.versionless_secret_id +} +`, r.keyVaultTemplate(data), data.RandomInteger) +} + +func (r AppServiceCertificateResource) keyVaultTemplate(data acceptance.TestData) string { + return fmt.Sprintf(` provider "azuread" {} +%[1]s + data "azurerm_client_config" "test" {} data "azuread_service_principal" "test" { display_name = "Microsoft Azure App Service" } -resource "azurerm_resource_group" "test" { - name = "acctestwebcert%[1]d" - location = "%[2]s" -} - resource "azurerm_key_vault" "test" { - name = "acctest%[3]s" + name = "acctest%[2]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name @@ -410,7 +294,7 @@ resource "azurerm_key_vault" "test" { } resource "azurerm_key_vault_certificate" "test" { - name = "acctest%[1]d" + name = "acctest%[3]d" key_vault_id = azurerm_key_vault.test.id certificate { @@ -435,13 +319,14 @@ resource "azurerm_key_vault_certificate" "test" { } } } +`, r.template(data), data.RandomString, data.RandomInteger) +} -resource "azurerm_app_service_certificate" "test" { - name = "acctest%[1]d" - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location - key_vault_id = azurerm_key_vault.test.id - key_vault_secret_id = azurerm_key_vault_certificate.test.versionless_secret_id +func (r AppServiceCertificateResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestwebcert%[1]d" + location = "%[2]s" } -`, data.RandomInteger, data.Locations.Primary, data.RandomString) +`, data.RandomInteger, data.Locations.Primary) } diff --git a/internal/services/web/app_service_custom_hostname_binding_resource.go b/internal/services/web/app_service_custom_hostname_binding_resource.go index 17cd4300fcbe..a0f267e84761 100644 --- a/internal/services/web/app_service_custom_hostname_binding_resource.go +++ b/internal/services/web/app_service_custom_hostname_binding_resource.go @@ -93,8 +93,8 @@ func resourceAppServiceCustomHostnameBindingCreate(d *pluginsdk.ResourceData, me id := webapps.NewHostNameBindingID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("app_service_name").(string), d.Get("hostname").(string)) - locks.ByName(id.HostNameBindingName, appServiceCustomHostnameBindingResourceName) - defer locks.UnlockByName(id.HostNameBindingName, appServiceCustomHostnameBindingResourceName) + locks.ByName(id.SiteName, appServiceCustomHostnameBindingResourceName) + defer locks.UnlockByName(id.SiteName, appServiceCustomHostnameBindingResourceName) existing, err := client.GetHostNameBinding(ctx, id) if !response.WasNotFound(existing.HttpResponse) { @@ -183,8 +183,8 @@ func resourceAppServiceCustomHostnameBindingDelete(d *pluginsdk.ResourceData, me return err } - locks.ByName(id.HostNameBindingName, appServiceCustomHostnameBindingResourceName) - defer locks.UnlockByName(id.HostNameBindingName, appServiceCustomHostnameBindingResourceName) + locks.ByName(id.SiteName, appServiceCustomHostnameBindingResourceName) + defer locks.UnlockByName(id.SiteName, appServiceCustomHostnameBindingResourceName) resp, err := client.DeleteHostNameBinding(ctx, *id) if err != nil { diff --git a/internal/services/web/app_service_custom_hostname_binding_resource_test.go b/internal/services/web/app_service_custom_hostname_binding_resource_test.go index 4c1f45c37582..518df19ef1b3 100644 --- a/internal/services/web/app_service_custom_hostname_binding_resource_test.go +++ b/internal/services/web/app_service_custom_hostname_binding_resource_test.go @@ -19,50 +19,18 @@ import ( type ServiceCustomHostnameBindingResource struct{} -func TestAccAppServiceCustomHostnameBinding(t *testing.T) { - appServiceEnvVariable := "ARM_TEST_APP_SERVICE" - appServiceEnv := os.Getenv(appServiceEnvVariable) - if appServiceEnv == "" { - t.Skipf("Skipping as %q is not specified", appServiceEnvVariable) +func TestAccAppServiceCustomHostnameBinding_basic(t *testing.T) { + if os.Getenv("ARM_TEST_DNS_ZONE") == "" || os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") == "" { + t.Skip("Skipping as ARM_TEST_DNS_ZONE and/or ARM_TEST_DATA_RESOURCE_GROUP are not specified") + return } - domainEnvVariable := "ARM_TEST_DOMAIN" - domainEnv := os.Getenv(domainEnvVariable) - if domainEnv == "" { - t.Skipf("Skipping as %q is not specified", domainEnvVariable) - } - - // NOTE: this is a combined test rather than separate split out tests due to - // the app service name being shared (so the tests don't conflict with each other) - testCases := map[string]map[string]func(t *testing.T, appServiceEnv, domainEnv string){ - "basic": { - "basic": testAccAppServiceCustomHostnameBinding_basic, - "multiple": testAccAppServiceCustomHostnameBinding_multiple, - "requiresImport": testAccAppServiceCustomHostnameBinding_requiresImport, - "ssl": testAccAppServiceCustomHostnameBinding_ssl, - }, - } - - for group, m := range testCases { - m := m - t.Run(group, func(t *testing.T) { - for name, tc := range m { - tc := tc - t.Run(name, func(t *testing.T) { - tc(t, appServiceEnv, domainEnv) - }) - } - }) - } -} - -func testAccAppServiceCustomHostnameBinding_basic(t *testing.T, appServiceEnv, domainEnv string) { data := acceptance.BuildTestData(t, "azurerm_app_service_custom_hostname_binding", "test") r := ServiceCustomHostnameBindingResource{} - data.ResourceSequentialTest(t, r, []acceptance.TestStep{ + data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.basicConfig(data, appServiceEnv, domainEnv), + Config: r.basicConfig(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -71,36 +39,40 @@ func testAccAppServiceCustomHostnameBinding_basic(t *testing.T, appServiceEnv, d }) } -func testAccAppServiceCustomHostnameBinding_requiresImport(t *testing.T, appServiceEnv, domainEnv string) { +func TestAccAppServiceCustomHostnameBinding_requiresImport(t *testing.T) { + if os.Getenv("ARM_TEST_DNS_ZONE") == "" || os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") == "" { + t.Skip("Skipping as ARM_TEST_DNS_ZONE and/or ARM_TEST_DATA_RESOURCE_GROUP are not specified") + return + } + data := acceptance.BuildTestData(t, "azurerm_app_service_custom_hostname_binding", "test") r := ServiceCustomHostnameBindingResource{} - data.ResourceSequentialTest(t, r, []acceptance.TestStep{ + data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.basicConfig(data, appServiceEnv, domainEnv), + Config: r.basicConfig(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), }, data.RequiresImportErrorStep(func(data acceptance.TestData) string { - return r.requiresImport(data, appServiceEnv, domainEnv) + return r.requiresImport(data) }), }) } -func testAccAppServiceCustomHostnameBinding_multiple(t *testing.T, appServiceEnv, domainEnv string) { - altDomainEnvVariable := "ARM_ALT_TEST_DOMAIN" - altDomainEnv := os.Getenv(altDomainEnvVariable) - if altDomainEnv == "" { - t.Skipf("Skipping as %q is not specified", altDomainEnvVariable) +func TestAccAppServiceCustomHostnameBinding_multiple(t *testing.T) { + if os.Getenv("ARM_TEST_DNS_ZONE") == "" || os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") == "" { + t.Skip("Skipping as ARM_TEST_DNS_ZONE and/or ARM_TEST_DATA_RESOURCE_GROUP are not specified") + return } data := acceptance.BuildTestData(t, "azurerm_app_service_custom_hostname_binding", "test") r := ServiceCustomHostnameBindingResource{} - data.ResourceSequentialTest(t, r, []acceptance.TestStep{ + data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.multipleConfig(data, appServiceEnv, domainEnv, altDomainEnv), + Config: r.multipleConfig(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -108,13 +80,18 @@ func testAccAppServiceCustomHostnameBinding_multiple(t *testing.T, appServiceEnv }) } -func testAccAppServiceCustomHostnameBinding_ssl(t *testing.T, appServiceEnv, domainEnv string) { +func TestAccAppServiceCustomHostnameBinding_ssl(t *testing.T) { + if os.Getenv("ARM_TEST_DNS_ZONE") == "" || os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP") == "" { + t.Skip("Skipping as ARM_TEST_DNS_ZONE and/or ARM_TEST_DATA_RESOURCE_GROUP are not specified") + return + } + data := acceptance.BuildTestData(t, "azurerm_app_service_custom_hostname_binding", "test") r := ServiceCustomHostnameBindingResource{} - data.ResourceSequentialTest(t, r, []acceptance.TestStep{ + data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.sslConfig(data, appServiceEnv, domainEnv), + Config: r.sslConfig(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -137,101 +114,77 @@ func (r ServiceCustomHostnameBindingResource) Exists(ctx context.Context, client return pointer.To(resp.Model != nil), nil } -func (ServiceCustomHostnameBindingResource) basicConfig(data acceptance.TestData, appServiceName string, domain string) string { +func (r ServiceCustomHostnameBindingResource) basicConfig(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} } -resource "azurerm_resource_group" "test" { - name = "acctestRG-%[1]d" - location = "%[2]s" -} - -resource "azurerm_app_service_plan" "test" { - name = "acctestASP-%[1]d" - location = azurerm_resource_group.test.location - resource_group_name = azurerm_resource_group.test.name - - sku { - tier = "Standard" - size = "S1" - } -} - -resource "azurerm_app_service" "test" { - name = "%[3]s" - location = azurerm_resource_group.test.location - resource_group_name = azurerm_resource_group.test.name - app_service_plan_id = azurerm_app_service_plan.test.id -} +%[1]s resource "azurerm_app_service_custom_hostname_binding" "test" { - hostname = "%[4]s" + hostname = trimsuffix(azurerm_dns_cname_record.test.fqdn, ".") app_service_name = azurerm_app_service.test.name resource_group_name = azurerm_resource_group.test.name } -`, data.RandomInteger, data.Locations.Primary, appServiceName, domain) +`, r.template(data)) } -func (r ServiceCustomHostnameBindingResource) requiresImport(data acceptance.TestData, appServiceName string, domain string) string { +func (r ServiceCustomHostnameBindingResource) requiresImport(data acceptance.TestData) string { return fmt.Sprintf(` %s resource "azurerm_app_service_custom_hostname_binding" "import" { - hostname = azurerm_app_service_custom_hostname_binding.test.name + hostname = azurerm_app_service_custom_hostname_binding.test.hostname app_service_name = azurerm_app_service_custom_hostname_binding.test.app_service_name resource_group_name = azurerm_app_service_custom_hostname_binding.test.resource_group_name } -`, r.basicConfig(data, appServiceName, domain)) +`, r.basicConfig(data)) } -func (r ServiceCustomHostnameBindingResource) multipleConfig(data acceptance.TestData, appServiceName, domain, altDomain string) string { +func (r ServiceCustomHostnameBindingResource) multipleConfig(data acceptance.TestData) string { return fmt.Sprintf(` -%s +%[1]s + +resource "azurerm_dns_cname_record" "test2" { + name = "%[2]s" + zone_name = data.azurerm_dns_zone.test.name + resource_group_name = data.azurerm_dns_zone.test.resource_group_name + ttl = 300 + record = azurerm_app_service.test.default_site_hostname +} + +resource "azurerm_dns_txt_record" "test2" { + name = join(".", ["asuid", "%[2]s"]) + zone_name = data.azurerm_dns_zone.test.name + resource_group_name = data.azurerm_dns_zone.test.resource_group_name + ttl = 300 + + record { + value = azurerm_app_service.test.custom_domain_verification_id + } +} resource "azurerm_app_service_custom_hostname_binding" "test2" { - hostname = "%s" + hostname = trimsuffix(azurerm_dns_cname_record.test2.fqdn, ".") app_service_name = azurerm_app_service.test.name resource_group_name = azurerm_resource_group.test.name } -`, r.basicConfig(data, appServiceName, domain), altDomain) +`, r.basicConfig(data), data.RandomStringOfLength(7)) } -func (r ServiceCustomHostnameBindingResource) sslConfig(data acceptance.TestData, appServiceName, domain string) string { +func (r ServiceCustomHostnameBindingResource) sslConfig(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} } -resource "azurerm_resource_group" "test" { - name = "acctestRG-%[1]d" - location = "%[2]s" -} - -resource "azurerm_app_service_plan" "test" { - name = "acctestASP-%[1]d" - location = azurerm_resource_group.test.location - resource_group_name = azurerm_resource_group.test.name - - sku { - tier = "Standard" - size = "S1" - } -} - -resource "azurerm_app_service" "test" { - name = "%[3]s" - location = azurerm_resource_group.test.location - resource_group_name = azurerm_resource_group.test.name - app_service_plan_id = azurerm_app_service_plan.test.id -} +%[1]s -data "azurerm_client_config" "test" { -} +data "azurerm_client_config" "test" {} resource "azurerm_key_vault" "test" { - name = "acctest-%[4]s" + name = "acct-%[3]s" location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name tenant_id = data.azurerm_client_config.test.tenant_id @@ -241,12 +194,12 @@ resource "azurerm_key_vault" "test" { tenant_id = data.azurerm_client_config.test.tenant_id object_id = data.azurerm_client_config.test.object_id secret_permissions = ["Delete", "Get", "Set"] - certificate_permissions = ["Create", "Delete", "Get", "Import"] + certificate_permissions = ["Create", "Delete", "Get", "Import", "Purge"] } } resource "azurerm_key_vault_certificate" "test" { - name = "acct-%[1]d" + name = "acctest-%[2]d" key_vault_id = azurerm_key_vault.test.id certificate_policy { @@ -273,7 +226,7 @@ resource "azurerm_key_vault_certificate" "test" { "keyEncipherment", ] - subject = "CN=%[5]s" + subject = "CN=${trimsuffix(azurerm_dns_cname_record.test.fqdn, ".")}" validity_in_months = 12 } } @@ -285,18 +238,69 @@ data "azurerm_key_vault_secret" "test" { } resource "azurerm_app_service_certificate" "test" { - name = "acctestCert-%[1]d" + name = "acctestCert-%[2]d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location pfx_blob = data.azurerm_key_vault_secret.test.value } resource "azurerm_app_service_custom_hostname_binding" "test" { - hostname = "%[5]s" + hostname = trimsuffix(azurerm_dns_cname_record.test.fqdn, ".") app_service_name = azurerm_app_service.test.name resource_group_name = azurerm_resource_group.test.name ssl_state = "SniEnabled" thumbprint = azurerm_app_service_certificate.test.thumbprint } -`, data.RandomInteger, data.Locations.Primary, appServiceName, data.RandomString, domain) +`, r.template(data), data.RandomInteger, data.RandomString) +} + +func (r ServiceCustomHostnameBindingResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%[1]d" + location = "%[2]s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + sku { + tier = "Standard" + size = "S1" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + app_service_plan_id = azurerm_app_service_plan.test.id +} + +data "azurerm_dns_zone" "test" { + name = "%[3]s" + resource_group_name = "%[4]s" +} + +resource "azurerm_dns_cname_record" "test" { + name = "%[5]s" + zone_name = data.azurerm_dns_zone.test.name + resource_group_name = data.azurerm_dns_zone.test.resource_group_name + ttl = 300 + record = azurerm_app_service.test.default_site_hostname +} + +resource "azurerm_dns_txt_record" "test" { + name = join(".", ["asuid", "%[5]s"]) + zone_name = data.azurerm_dns_zone.test.name + resource_group_name = data.azurerm_dns_zone.test.resource_group_name + ttl = 300 + + record { + value = azurerm_app_service.test.custom_domain_verification_id + } +} +`, data.RandomInteger, data.Locations.Primary, os.Getenv("ARM_TEST_DNS_ZONE"), os.Getenv("ARM_TEST_DATA_RESOURCE_GROUP"), data.RandomString) } diff --git a/internal/services/web/app_service_managed_certificate_resource_test.go b/internal/services/web/app_service_managed_certificate_resource_test.go index 8e8ed0f4e810..95a502f6a664 100644 --- a/internal/services/web/app_service_managed_certificate_resource_test.go +++ b/internal/services/web/app_service_managed_certificate_resource_test.go @@ -35,6 +35,7 @@ func TestAccAppServiceManagedCertificate_basicLinux(t *testing.T) { check.That(data.ResourceName).ExistsInAzure(r), ), }, + data.ImportStep("custom_hostname_binding_id"), }) } @@ -74,6 +75,7 @@ func TestAccAppServiceManagedCertificate_completeLinux(t *testing.T) { check.That(data.ResourceName).ExistsInAzure(r), ), }, + data.ImportStep("custom_hostname_binding_id"), }) } @@ -93,27 +95,28 @@ func TestAccAppServiceManagedCertificate_updateLinux(t *testing.T) { check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.ImportStep(), + data.ImportStep("custom_hostname_binding_id"), { Config: r.completeLinux(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.ImportStep(), + data.ImportStep("custom_hostname_binding_id"), { Config: r.updateLinux(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.ImportStep(), + data.ImportStep("custom_hostname_binding_id"), { Config: r.basicLinux(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), }, + data.ImportStep("custom_hostname_binding_id"), }) } @@ -133,6 +136,7 @@ func TestAccAppServiceManagedCertificate_basicWindows(t *testing.T) { check.That(data.ResourceName).ExistsInAzure(r), ), }, + data.ImportStep("custom_hostname_binding_id"), }) } From 1a20b071449a3d13c7839d73c2a458df7bb2ba12 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Fri, 20 Mar 2026 11:26:06 -0600 Subject: [PATCH 17/18] linting --- .../web/app_service_custom_hostname_binding_resource_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/services/web/app_service_custom_hostname_binding_resource_test.go b/internal/services/web/app_service_custom_hostname_binding_resource_test.go index 518df19ef1b3..92e7f8fb4af2 100644 --- a/internal/services/web/app_service_custom_hostname_binding_resource_test.go +++ b/internal/services/web/app_service_custom_hostname_binding_resource_test.go @@ -55,9 +55,7 @@ func TestAccAppServiceCustomHostnameBinding_requiresImport(t *testing.T) { check.That(data.ResourceName).ExistsInAzure(r), ), }, - data.RequiresImportErrorStep(func(data acceptance.TestData) string { - return r.requiresImport(data) - }), + data.RequiresImportErrorStep(r.requiresImport), }) } From d8f9a8bf9e2a90c9f7bff92d024eec3e63c851b8 Mon Sep 17 00:00:00 2001 From: sreallymatt <106555974+sreallymatt@users.noreply.github.com> Date: Mon, 27 Apr 2026 14:10:09 -0600 Subject: [PATCH 18/18] resolve comments --- .../app_service_certificate_order_resource.go | 15 ++++++++----- .../web/app_service_certificate_resource.go | 9 ++++---- ...pp_service_managed_certificate_resource.go | 22 +++++++++++-------- ...e_slot_custom_hostname_binding_resource.go | 10 ++++++--- ...rtual_network_swift_connection_resource.go | 2 ++ .../web/function_app_host_keys_data_source.go | 1 + 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/internal/services/web/app_service_certificate_order_resource.go b/internal/services/web/app_service_certificate_order_resource.go index a79b1aa516b0..0a880b814ae0 100644 --- a/internal/services/web/app_service_certificate_order_resource.go +++ b/internal/services/web/app_service_certificate_order_resource.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/go-azure-sdk/resource-manager/certificateregistration/2023-12-01/appservicecertificateorders" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -18,7 +19,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceAppServiceCertificateOrder() *pluginsdk.Resource { @@ -185,10 +185,13 @@ func resourceAppServiceCertificateOrderCreate(d *pluginsdk.ResourceData, meta in id := appservicecertificateorders.NewCertificateOrderID(meta.(*clients.Client).Account.SubscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) existing, err := client.Get(ctx, id) - if !response.WasNotFound(existing.HttpResponse) { - if err != nil { + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %s", id, err) } + } + + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_app_service_certificate_order", id.ID()) } @@ -202,7 +205,7 @@ func resourceAppServiceCertificateOrderCreate(d *pluginsdk.ResourceData, meta in ValidityInYears: pointer.To(int64(d.Get("validity_in_years").(int))), }, Location: location.Normalize(d.Get("location").(string)), - Tags: utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})), + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } if err := client.CreateOrUpdateThenPoll(ctx, id, certificateOrder); err != nil { @@ -240,7 +243,7 @@ func resourceAppServiceCertificateOrderRead(d *pluginsdk.ResourceData, meta inte if model := resp.Model; model != nil { d.Set("location", location.Normalize(model.Location)) - d.Set("tags", model.Tags) + d.Set("tags", tags.Flatten(model.Tags)) if props := model.Properties; props != nil { d.Set("auto_renew", props.AutoRenew) @@ -323,7 +326,7 @@ func resourceAppServiceCertificateOrderUpdate(d *pluginsdk.ResourceData, meta in } if d.HasChange("tags") { - existing.Model.Tags = utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})) + existing.Model.Tags = tags.Expand(d.Get("tags").(map[string]interface{})) } if err := client.CreateOrUpdateThenPoll(ctx, *id, *existing.Model); err != nil { diff --git a/internal/services/web/app_service_certificate_resource.go b/internal/services/web/app_service_certificate_resource.go index 71b74b0a4065..6969544a0e24 100644 --- a/internal/services/web/app_service_certificate_resource.go +++ b/internal/services/web/app_service_certificate_resource.go @@ -7,6 +7,8 @@ import ( "fmt" "time" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" @@ -20,7 +22,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceAppServiceCertificate() *pluginsdk.Resource { @@ -163,7 +164,7 @@ func resourceAppServiceCertificateCreate(d *pluginsdk.ResourceData, meta interfa Password: pointer.To(d.Get("password").(string)), }, Location: location.Normalize(d.Get("location").(string)), - Tags: utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})), + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } if v := d.Get("app_service_plan_id").(string); v != "" { @@ -226,7 +227,7 @@ func resourceAppServiceCertificateUpdate(d *pluginsdk.ResourceData, meta interfa return fmt.Errorf("retrieving %s: `model` was nil", id) } - existing.Model.Tags = utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})) + existing.Model.Tags = tags.Expand(d.Get("tags").(map[string]interface{})) if _, err := client.CreateOrUpdate(ctx, id, *existing.Model); err != nil { return fmt.Errorf("updating %s: %s", id, err) @@ -265,7 +266,7 @@ func resourceAppServiceCertificateRead(d *pluginsdk.ResourceData, meta interface d.Set("subject_name", props.SubjectName) d.Set("host_names", props.HostNames) d.Set("issuer", props.Issuer) - d.Set("tags", model.Tags) + d.Set("tags", tags.Flatten(model.Tags)) d.Set("issue_date", props.IssueDate) d.Set("expiration_date", props.ExpirationDate) d.Set("thumbprint", props.Thumbprint) diff --git a/internal/services/web/app_service_managed_certificate_resource.go b/internal/services/web/app_service_managed_certificate_resource.go index 6ea787959821..4ef0ca59461a 100644 --- a/internal/services/web/app_service_managed_certificate_resource.go +++ b/internal/services/web/app_service_managed_certificate_resource.go @@ -8,6 +8,9 @@ import ( "net/http" "time" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" @@ -16,13 +19,11 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" - "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/custompollers" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceAppServiceManagedCertificate() *pluginsdk.Resource { @@ -149,10 +150,13 @@ func resourceAppServiceManagedCertificateCreate(d *pluginsdk.ResourceData, meta id := certificates.NewCertificateID(subscriptionID, appServicePlanID.ResourceGroupName, chbID.HostNameBindingName) existing, err := client.Get(ctx, id) - if !response.WasNotFound(existing.HttpResponse) { - if err != nil { + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %w", id, err) } + } + + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_app_service_managed_certificate", id.ID()) } @@ -183,11 +187,11 @@ func resourceAppServiceManagedCertificateCreate(d *pluginsdk.ResourceData, meta // An API issue prevents setting tags using the PUT operation, so we'll patch them in after // https://github.com/Azure/azure-rest-api-specs/issues/14529 - tags := certificates.CertificatePatchResource{ - Tags: utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})), + t := certificates.CertificatePatchResource{ + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } - if _, err := client.Update(ctx, id, tags); err != nil { + if _, err := client.Update(ctx, id, t); err != nil { return fmt.Errorf("creating `tags` for %s: %w", id, err) } @@ -215,7 +219,7 @@ func resourceAppServiceManagedCertificateRead(d *pluginsdk.ResourceData, meta in } if model := resp.Model; model != nil { - d.Set("tags", model.Tags) + d.Set("tags", tags.Flatten(model.Tags)) if props := model.Properties; props != nil { d.Set("canonical_name", props.CanonicalName) d.Set("friendly_name", props.FriendlyName) @@ -247,7 +251,7 @@ func resourceAppServiceManagedCertificateUpdate(d *pluginsdk.ResourceData, meta } payload := certificates.CertificatePatchResource{ - Tags: utils.ExpandPtrMapStringString(d.Get("tags").(map[string]interface{})), + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } if _, err := client.Update(ctx, *id, payload); err != nil { diff --git a/internal/services/web/app_service_slot_custom_hostname_binding_resource.go b/internal/services/web/app_service_slot_custom_hostname_binding_resource.go index 722292d87aa3..620da5c619ff 100644 --- a/internal/services/web/app_service_slot_custom_hostname_binding_resource.go +++ b/internal/services/web/app_service_slot_custom_hostname_binding_resource.go @@ -7,10 +7,11 @@ import ( "fmt" "time" + "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" - "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -97,10 +98,13 @@ func resourceAppServiceSlotCustomHostnameBindingCreate(d *pluginsdk.ResourceData defer locks.UnlockByName(id.HostNameBindingName, appServiceSlotCustomHostnameBindingResourceName) existing, err := client.GetHostNameBindingSlot(ctx, id) - if !response.WasNotFound(existing.HttpResponse) { - if err != nil { + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %+v", id, err) } + } + + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_app_service_slot_custom_hostname_binding", id.ID()) } diff --git a/internal/services/web/app_service_virtual_network_swift_connection_resource.go b/internal/services/web/app_service_virtual_network_swift_connection_resource.go index 06d972f34d86..ffd772e08eee 100644 --- a/internal/services/web/app_service_virtual_network_swift_connection_resource.go +++ b/internal/services/web/app_service_virtual_network_swift_connection_resource.go @@ -5,6 +5,7 @@ package web import ( "fmt" + "log" "time" "github.com/hashicorp/go-azure-helpers/lang/pointer" @@ -139,6 +140,7 @@ func resourceAppServiceVirtualNetworkSwiftConnectionRead(d *pluginsdk.ResourceDa existing, err := client.GetSwiftVirtualNetworkConnection(ctx, appID) if err != nil { if response.WasNotFound(existing.HttpResponse) { + log.Printf("[INFO] %s was not found - removing from state", id) d.SetId("") return nil } diff --git a/internal/services/web/function_app_host_keys_data_source.go b/internal/services/web/function_app_host_keys_data_source.go index d11c6e74413b..244d9f6534f7 100644 --- a/internal/services/web/function_app_host_keys_data_source.go +++ b/internal/services/web/function_app_host_keys_data_source.go @@ -100,6 +100,7 @@ func dataSourceFunctionAppHostKeysRead(d *pluginsdk.ResourceData, meta interface d.SetId(id.ID()) + // TODO: Remove this retry return pluginsdk.Retry(d.Timeout(pluginsdk.TimeoutCreate), func() *pluginsdk.RetryError { resp, err := client.ListHostKeys(ctx, id) if err != nil {