Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app_service - API update to 2022-09-01 #22352

Merged
merged 9 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/services/appservice/client/client.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package client

import (
"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type Client struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"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/utils"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type FunctionAppActiveSlotResource struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"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"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type FunctionAppFunctionResource struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/relay/2017-04-01/hybridconnections"
"github.com/hashicorp/go-azure-sdk/resource-manager/relay/2017-04-01/namespaces"
Expand All @@ -18,6 +17,7 @@ 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/utils"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type FunctionAppHybridConnectionResource struct{}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/appservice/helpers/auth_v2_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"strings"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"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"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type AuthV2Settings struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/services/appservice/helpers/auto_heal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"strconv"
"strings"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"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"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type AutoHealSettingWindows struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/Azure/go-autorest/autorest/date"
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type VirtualApplication struct {
Expand Down
9 changes: 9 additions & 0 deletions internal/services/appservice/helpers/enums.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package helpers

// publicNetworkAccess Enums are missing in api-specs
// https://github.com/Azure/azure-rest-api-specs/issues/24680

const (
PublicNetworkAccessEnabled string = "Enabled"
PublicNetworkAccessDisabled string = "Disabled"
)
jackofallops marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"strconv"
"strings"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
apimValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/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/utils"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

const (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"sort"
"testing"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/helpers"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

func TestMergeUserAppSettings(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"strconv"
"strings"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
apimValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/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/utils"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type SiteConfigWindowsFunctionAppSlot struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"strconv"
"strings"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type SiteConfigLinux struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/services/appservice/helpers/publish_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"os"
"time"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions internal/services/appservice/helpers/shared_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"fmt"
"strings"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"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"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type IpRestriction struct {
Expand Down Expand Up @@ -272,7 +272,7 @@ func CorsSettingsSchema() *pluginsdk.Schema {
"allowed_origins": {
Type: pluginsdk.TypeSet,
Optional: true,
//MinItems: 1,
MinItems: 1,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"strconv"
"strings"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
apimValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type SiteConfigLinuxWebAppSlot struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"strconv"
"strings"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type SiteConfigWindows struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/services/appservice/identity.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package appservice

import (
"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/resourcemanager/identity"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

func expandIdentity(input []interface{}) (*web.ManagedServiceIdentity, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
Expand All @@ -18,6 +17,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type LinuxFunctionAppDataSource struct{}
Expand Down Expand Up @@ -48,6 +48,7 @@ type LinuxFunctionAppDataSourceModel struct {
FunctionExtensionsVersion string `tfschema:"functions_extension_version"`
ForceDisableContentShare bool `tfschema:"content_share_force_disabled"`
HttpsOnly bool `tfschema:"https_only"`
PublicNetworkAccess bool `tfschema:"public_network_access_enabled"`
SiteConfig []helpers.SiteConfigLinuxFunctionApp `tfschema:"site_config"`
StickySettings []helpers.StickySettings `tfschema:"sticky_settings"`
Tags map[string]string `tfschema:"tags"`
Expand Down Expand Up @@ -241,6 +242,11 @@ func (d LinuxFunctionAppDataSource) Attributes() map[string]*pluginsdk.Schema {
},
},

"public_network_access_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},

"usage": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -350,6 +356,7 @@ func (d LinuxFunctionAppDataSource) Read() sdk.ResourceFunc {
CustomDomainVerificationId: utils.NormalizeNilableString(props.CustomDomainVerificationID),
DefaultHostname: utils.NormalizeNilableString(functionApp.DefaultHostName),
Usage: string(props.UsageState),
PublicNetworkAccess: !strings.EqualFold(pointer.From(props.PublicNetworkAccess), helpers.PublicNetworkAccessDisabled),
}

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestAccLinuxFunctionAppDataSource_standardComplete(t *testing.T) {
check.That(data.ResourceName).Key("possible_outbound_ip_addresses").MatchesRegex(ipListRegex),
check.That(data.ResourceName).Key("possible_outbound_ip_address_list.#").Exists(),
check.That(data.ResourceName).Key("default_hostname").HasValue(fmt.Sprintf("acctest-lfa-%d.azurewebsites.net", data.RandomInteger)),
check.That(data.ResourceName).Key("public_network_access_enabled").HasValue("true"),
),
},
})
Expand Down
32 changes: 31 additions & 1 deletion internal/services/appservice/linux_function_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-03-01/web" // nolint: staticcheck
"github.com/google/uuid"
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
Expand All @@ -23,6 +22,7 @@ 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/utils"
"github.com/tombuildsstuff/kermit/sdk/web/2022-09-01/web"
)

type LinuxFunctionAppResource struct{}
Expand Down Expand Up @@ -54,6 +54,7 @@ type LinuxFunctionAppModel struct {
ForceDisableContentShare bool `tfschema:"content_share_force_disabled"`
HttpsOnly bool `tfschema:"https_only"`
KeyVaultReferenceIdentityID string `tfschema:"key_vault_reference_identity_id"`
PublicNetworkAccess bool `tfschema:"public_network_access_enabled"`
SiteConfig []helpers.SiteConfigLinuxFunctionApp `tfschema:"site_config"`
StorageAccounts []helpers.StorageAccount `tfschema:"storage_account"`
Tags map[string]string `tfschema:"tags"`
Expand Down Expand Up @@ -252,6 +253,12 @@ func (r LinuxFunctionAppResource) Arguments() map[string]*pluginsdk.Schema {
Description: "The User Assigned Identity to use for Key Vault access.",
},

"public_network_access_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: true,
},

"site_config": helpers.SiteConfigSchemaLinuxFunctionApp(),

"sticky_settings": helpers.StickySettingsSchema(),
Expand Down Expand Up @@ -491,9 +498,19 @@ func (r LinuxFunctionAppResource) Create() sdk.ResourceFunc {
ClientCertEnabled: utils.Bool(functionApp.ClientCertEnabled),
ClientCertMode: web.ClientCertMode(functionApp.ClientCertMode),
DailyMemoryTimeQuota: utils.Int32(int32(functionApp.DailyMemoryTimeQuota)), // TODO - Investigate, setting appears silently ignored on Linux Function Apps?
VnetRouteAllEnabled: siteConfig.VnetRouteAllEnabled,
},
}

pna := helpers.PublicNetworkAccessEnabled
if !functionApp.PublicNetworkAccess {
pna = helpers.PublicNetworkAccessDisabled
}

// (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681
siteEnvelope.PublicNetworkAccess = pointer.To(pna)
siteEnvelope.SiteConfig.PublicNetworkAccess = siteEnvelope.PublicNetworkAccess

if functionApp.KeyVaultReferenceIdentityID != "" {
siteEnvelope.SiteProperties.KeyVaultReferenceIdentity = utils.String(functionApp.KeyVaultReferenceIdentityID)
}
Expand Down Expand Up @@ -688,6 +705,7 @@ func (r LinuxFunctionAppResource) Read() sdk.ResourceFunc {
KeyVaultReferenceIdentityID: utils.NormalizeNilableString(props.KeyVaultReferenceIdentity),
CustomDomainVerificationId: utils.NormalizeNilableString(props.CustomDomainVerificationID),
DefaultHostname: utils.NormalizeNilableString(props.DefaultHostName),
PublicNetworkAccess: !strings.EqualFold(pointer.From(props.PublicNetworkAccess), helpers.PublicNetworkAccessDisabled),
}

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
Expand Down Expand Up @@ -964,6 +982,7 @@ func (r LinuxFunctionAppResource) Update() sdk.ResourceFunc {

if metadata.ResourceData.HasChange("site_config") {
existing.SiteConfig = siteConfig
existing.VnetRouteAllEnabled = siteConfig.VnetRouteAllEnabled
}

if metadata.ResourceData.HasChange("site_config.0.application_stack") {
Expand All @@ -972,6 +991,17 @@ func (r LinuxFunctionAppResource) Update() sdk.ResourceFunc {

existing.SiteConfig.AppSettings = helpers.MergeUserAppSettings(siteConfig.AppSettings, state.AppSettings)

if metadata.ResourceData.HasChange("public_network_access_enabled") {
pna := helpers.PublicNetworkAccessEnabled
if !state.PublicNetworkAccess {
pna = helpers.PublicNetworkAccessDisabled
}

// (@jackofallops) - Values appear to need to be set in both SiteProperties and SiteConfig for now? https://github.com/Azure/azure-rest-api-specs/issues/24681
existing.PublicNetworkAccess = pointer.To(pna)
existing.SiteConfig.PublicNetworkAccess = existing.PublicNetworkAccess
}

updateFuture, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.SiteName, existing)
if err != nil {
return fmt.Errorf("updating Linux %s: %+v", id, err)
Expand Down
Loading