Skip to content

Commit

Permalink
appservice - deprecate azurerm_app_service_environment resource a…
Browse files Browse the repository at this point in the history
…nd data source (#26848)

skip tests

conditionally remove `azurerm_app_service_environment` resource and data source for 4.0 as it's no longer possible to create or manage these and existing instances will be terminated.
  • Loading branch information
jackofallops authored Jul 29, 2024
1 parent 423ce22 commit e0d6f88
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 10 deletions.
4 changes: 2 additions & 2 deletions internal/services/web/app_service_environment_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (

func dataSourceAppServiceEnvironment() *pluginsdk.Resource {
return &pluginsdk.Resource{
Read: dataSourceAppServiceEnvironmentRead,

Read: dataSourceAppServiceEnvironmentRead,
DeprecationMessage: "This data source is deprecated due to the [retirement of v1 and v2 App Service Environments](https://azure.microsoft.com/en-gb/updates/app-service-environment-v1-and-v2-retirement-announcement/) and will be removed inv4.0 of the provider. Please use `azurerm_app_service_environment_v3` instead.",
Timeouts: &pluginsdk.ResourceTimeout{
Read: pluginsdk.DefaultTimeout(5 * time.Minute),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 AppServiceEnvironmentDataSource struct{}

func TestAccDataSourceAppServiceEnvironment_basic(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("skipping as removed in 4.0")
}
data := acceptance.BuildTestData(t, "data.azurerm_app_service_environment", "test")

data.DataSourceTest(t, []acceptance.TestStep{
Expand Down
9 changes: 5 additions & 4 deletions internal/services/web/app_service_environment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ const (

func resourceAppServiceEnvironment() *pluginsdk.Resource {
return &pluginsdk.Resource{
Create: resourceAppServiceEnvironmentCreate,
Read: resourceAppServiceEnvironmentRead,
Update: resourceAppServiceEnvironmentUpdate,
Delete: resourceAppServiceEnvironmentDelete,
DeprecationMessage: "This resource is deprecated due to the [retirement of v1 and v2 App Service Environments](https://azure.microsoft.com/en-gb/updates/app-service-environment-v1-and-v2-retirement-announcement/) and will be removed inv4.0 of the provider. Please use `azurerm_app_service_environment_v3` instead.",
Create: resourceAppServiceEnvironmentCreate,
Read: resourceAppServiceEnvironmentRead,
Update: resourceAppServiceEnvironmentUpdate,
Delete: resourceAppServiceEnvironmentDelete,
Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error {
_, err := parse.AppServiceEnvironmentID(id)
return err
Expand Down
28 changes: 28 additions & 0 deletions internal/services/web/app_service_environment_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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"
Expand All @@ -19,6 +20,9 @@ import (
type AppServiceEnvironmentResource struct{}

func TestAccAppServiceEnvironment_basic(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("skipping as removed in 4.0")
}
data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test")
r := AppServiceEnvironmentResource{}

Expand All @@ -36,6 +40,9 @@ func TestAccAppServiceEnvironment_basic(t *testing.T) {
}

func TestAccAppServiceEnvironment_requiresImport(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("skipping as removed in 4.0")
}
data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test")
r := AppServiceEnvironmentResource{}

Expand All @@ -51,6 +58,9 @@ func TestAccAppServiceEnvironment_requiresImport(t *testing.T) {
}

func TestAccAppServiceEnvironment_update(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("skipping as removed in 4.0")
}
data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test")
r := AppServiceEnvironmentResource{}

Expand All @@ -76,6 +86,9 @@ func TestAccAppServiceEnvironment_update(t *testing.T) {
}

func TestAccAppServiceEnvironment_tierAndScaleFactor(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("skipping as removed in 4.0")
}
data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test")
r := AppServiceEnvironmentResource{}

Expand All @@ -93,6 +106,9 @@ func TestAccAppServiceEnvironment_tierAndScaleFactor(t *testing.T) {
}

func TestAccAppServiceEnvironment_withAppServicePlan(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("skipping as removed in 4.0")
}
data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test")
aspData := acceptance.BuildTestData(t, "azurerm_app_service_plan", "test")
r := AppServiceEnvironmentResource{}
Expand All @@ -112,6 +128,9 @@ func TestAccAppServiceEnvironment_withAppServicePlan(t *testing.T) {
}

func TestAccAppServiceEnvironment_dedicatedResourceGroup(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("skipping as removed in 4.0")
}
data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test")
r := AppServiceEnvironmentResource{}

Expand All @@ -127,6 +146,9 @@ func TestAccAppServiceEnvironment_dedicatedResourceGroup(t *testing.T) {
}

func TestAccAppServiceEnvironment_withCertificatePfx(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("skipping as removed in 4.0")
}
data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test")
r := AppServiceEnvironmentResource{}

Expand All @@ -142,6 +164,9 @@ func TestAccAppServiceEnvironment_withCertificatePfx(t *testing.T) {
}

func TestAccAppServiceEnvironment_internalLoadBalancer(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("skipping as removed in 4.0")
}
data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test")
r := AppServiceEnvironmentResource{}

Expand All @@ -158,6 +183,9 @@ func TestAccAppServiceEnvironment_internalLoadBalancer(t *testing.T) {
}

func TestAccAppServiceEnvironment_clusterSettings(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("skipping as removed in 4.0")
}
data := acceptance.BuildTestData(t, "azurerm_app_service_environment", "test")
r := AppServiceEnvironmentResource{}

Expand Down
17 changes: 13 additions & 4 deletions internal/services/web/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package web

import (
"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"
)
Expand All @@ -24,26 +25,28 @@ func (r Registration) WebsiteCategories() []string {

// SupportedDataSources returns the supported Data Sources supported by this Service
func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource {
return map[string]*pluginsdk.Resource{
datasources := map[string]*pluginsdk.Resource{
"azurerm_app_service": dataSourceAppService(),
"azurerm_app_service_certificate_order": dataSourceAppServiceCertificateOrder(),
"azurerm_app_service_environment": dataSourceAppServiceEnvironment(),
"azurerm_app_service_certificate": dataSourceAppServiceCertificate(),
"azurerm_app_service_plan": dataSourceAppServicePlan(),
"azurerm_function_app": dataSourceFunctionApp(),
"azurerm_function_app_host_keys": dataSourceFunctionAppHostKeys(),
}
if !features.FourPointOhBeta() {
datasources["azurerm_app_service_environment"] = dataSourceAppServiceEnvironment()
}
return datasources
}

// SupportedResources returns the supported Resources supported by this Service
func (r Registration) SupportedResources() map[string]*pluginsdk.Resource {
return 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_environment": resourceAppServiceEnvironment(),
"azurerm_app_service_hybrid_connection": resourceAppServiceHybridConnection(),
"azurerm_app_service_managed_certificate": resourceAppServiceManagedCertificate(),
"azurerm_app_service_plan": resourceAppServicePlan(),
Expand All @@ -59,6 +62,12 @@ func (r Registration) SupportedResources() map[string]*pluginsdk.Resource {
"azurerm_static_site": resourceStaticSite(),
"azurerm_static_site_custom_domain": resourceStaticSiteCustomDomain(),
}

if !features.FourPointOhBeta() {
resources["azurerm_app_service_environment"] = resourceAppServiceEnvironment()
}

return resources
}

func (r Registration) DataSources() []sdk.DataSource {
Expand Down

0 comments on commit e0d6f88

Please sign in to comment.