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

azurerm_windows_web_app,azurerm_windows_web_app_slot, azurerm_windows_function_app, azurerm_windows_function_app_slot, azurerm_linux_web_app,azurerm_linux_web_app_slot, azurerm_linux_function_app, azurerm_linux_function_app_slot - add hosting_environment_id property #20471

Merged
merged 7 commits into from
Apr 20, 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
11 changes: 11 additions & 0 deletions internal/services/appservice/linux_function_app_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"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"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
Expand Down Expand Up @@ -52,6 +53,7 @@ type LinuxFunctionAppDataSourceModel struct {

CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
DefaultHostname string `tfschema:"default_hostname"`
HostingEnvId string `tfschema:"hosting_environment_id"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
OutboundIPAddressList []string `tfschema:"outbound_ip_address_list"`
Expand Down Expand Up @@ -193,6 +195,11 @@ func (d LinuxFunctionAppDataSource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"kind": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -323,6 +330,10 @@ func (d LinuxFunctionAppDataSource) Read() sdk.ResourceFunc {
DefaultHostname: utils.NormalizeNilableString(functionApp.DefaultHostName),
}

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
state.HostingEnvId = pointer.From(hostingEnv.ID)
}

if v := props.OutboundIPAddresses; v != nil {
state.OutboundIPAddresses = *v
state.OutboundIPAddressList = strings.Split(*v, ",")
Expand Down
11 changes: 11 additions & 0 deletions internal/services/appservice/linux_function_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"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"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
Expand Down Expand Up @@ -61,6 +62,7 @@ type LinuxFunctionAppModel struct {
// Computed
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
DefaultHostname string `tfschema:"default_hostname"`
HostingEnvId string `tfschema:"hosting_environment_id"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
OutboundIPAddressList []string `tfschema:"outbound_ip_address_list"`
Expand Down Expand Up @@ -276,6 +278,11 @@ func (r LinuxFunctionAppResource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"kind": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -639,6 +646,10 @@ func (r LinuxFunctionAppResource) Read() sdk.ResourceFunc {
DefaultHostname: utils.NormalizeNilableString(props.DefaultHostName),
}

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
state.HostingEnvId = pointer.From(hostingEnv.ID)
}

if v := props.OutboundIPAddresses; v != nil {
state.OutboundIPAddresses = *v
state.OutboundIPAddressList = strings.Split(*v, ",")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type LinuxFunctionAppSlotModel struct {
Tags map[string]string `tfschema:"tags"`
VirtualNetworkSubnetID string `tfschema:"virtual_network_subnet_id"`
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
HostingEnvId string `tfschema:"hosting_environment_id"`
DefaultHostname string `tfschema:"default_hostname"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
Expand Down Expand Up @@ -267,6 +268,11 @@ func (r LinuxFunctionAppSlotResource) Attributes() map[string]*pluginsdk.Schema
Computed: true,
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"kind": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -636,6 +642,10 @@ func (r LinuxFunctionAppSlotResource) Read() sdk.ResourceFunc {
DefaultHostname: pointer.From(props.DefaultHostName),
}

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
state.HostingEnvId = pointer.From(hostingEnv.ID)
}

functionApp, err := client.Get(ctx, id.ResourceGroup, id.SiteName)
if err != nil {
return fmt.Errorf("reading parent Function App for Linux %s: %+v", *id, err)
Expand Down
10 changes: 10 additions & 0 deletions internal/services/appservice/linux_web_app_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
Expand Down Expand Up @@ -43,6 +44,7 @@ type LinuxWebAppDataSourceModel struct {
ConnectionStrings []helpers.ConnectionString `tfschema:"connection_string"`
Tags map[string]string `tfschema:"tags"`
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
HostingEnvId string `tfschema:"hosting_environment_id"`
DefaultHostname string `tfschema:"default_hostname"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
Expand Down Expand Up @@ -135,6 +137,11 @@ func (r LinuxWebAppDataSource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
Expand Down Expand Up @@ -319,6 +326,9 @@ func (r LinuxWebAppDataSource) Read() sdk.ResourceFunc {
webApp.OutboundIPAddressList = strings.Split(webApp.OutboundIPAddresses, ",")
webApp.PossibleOutboundIPAddresses = utils.NormalizeNilableString(props.PossibleOutboundIPAddresses)
webApp.PossibleOutboundIPAddressList = strings.Split(webApp.PossibleOutboundIPAddresses, ",")
if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
webApp.HostingEnvId = pointer.From(hostingEnv.ID)
}
if subnetId := utils.NormalizeNilableString(props.VirtualNetworkSubnetID); subnetId != "" {
webApp.VirtualNetworkSubnetID = subnetId
}
Expand Down
10 changes: 10 additions & 0 deletions internal/services/appservice/linux_web_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type LinuxWebAppModel struct {
ZipDeployFile string `tfschema:"zip_deploy_file"`
Tags map[string]string `tfschema:"tags"`
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
HostingEnvId string `tfschema:"hosting_environment_id"`
DefaultHostname string `tfschema:"default_hostname"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
Expand Down Expand Up @@ -191,6 +192,11 @@ func (r LinuxWebAppResource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"kind": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -540,6 +546,10 @@ func (r LinuxWebAppResource) Read() sdk.ResourceFunc {
Tags: tags.ToTypedObject(webApp.Tags),
}

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
state.HostingEnvId = pointer.From(hostingEnv.ID)
}

if subnetId := pointer.From(props.VirtualNetworkSubnetID); subnetId != "" {
state.VirtualNetworkSubnetID = subnetId
}
Expand Down
10 changes: 10 additions & 0 deletions internal/services/appservice/linux_web_app_slot_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type LinuxWebAppSlotModel struct {
Tags map[string]string `tfschema:"tags"`
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
DefaultHostname string `tfschema:"default_hostname"`
HostingEnvId string `tfschema:"hosting_environment_id"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
OutboundIPAddressList []string `tfschema:"outbound_ip_address_list"`
Expand Down Expand Up @@ -198,6 +199,11 @@ func (r LinuxWebAppSlotResource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"kind": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -512,6 +518,10 @@ func (r LinuxWebAppSlotResource) Read() sdk.ResourceFunc {
Tags: tags.ToTypedObject(webAppSlot.Tags),
}

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
state.HostingEnvId = pointer.From(hostingEnv.ID)
}

webApp, err := client.Get(ctx, id.ResourceGroup, id.SiteName)
if err != nil {
return fmt.Errorf("reading parent Web App for Linux %s: %+v", *id, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"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"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
Expand Down Expand Up @@ -52,6 +53,7 @@ type WindowsFunctionAppDataSourceModel struct {

CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
DefaultHostname string `tfschema:"default_hostname"`
HostingEnvId string `tfschema:"hosting_environment_id"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
OutboundIPAddressList []string `tfschema:"outbound_ip_address_list"`
Expand Down Expand Up @@ -184,6 +186,11 @@ func (d WindowsFunctionAppDataSource) Attributes() map[string]*pluginsdk.Schema
Computed: true,
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"kind": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -273,6 +280,10 @@ func (d WindowsFunctionAppDataSource) Read() sdk.ResourceFunc {
functionApp.DefaultHostname = utils.NormalizeNilableString(props.DefaultHostName)
functionApp.VirtualNetworkSubnetId = utils.NormalizeNilableString(props.VirtualNetworkSubnetID)

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
functionApp.HostingEnvId = pointer.From(hostingEnv.ID)
}

if v := props.OutboundIPAddresses; v != nil {
functionApp.OutboundIPAddresses = *v
functionApp.OutboundIPAddressList = strings.Split(*v, ",")
Expand Down
10 changes: 10 additions & 0 deletions internal/services/appservice/windows_function_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type WindowsFunctionAppModel struct {

// Computed
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
HostingEnvId string `tfschema:"hosting_environment_id"`
DefaultHostname string `tfschema:"default_hostname"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
Expand Down Expand Up @@ -277,6 +278,11 @@ func (r WindowsFunctionAppResource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"kind": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -639,6 +645,10 @@ func (r WindowsFunctionAppResource) Read() sdk.ResourceFunc {
DefaultHostname: utils.NormalizeNilableString(props.DefaultHostName),
}

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
state.HostingEnvId = pointer.From(hostingEnv.ID)
}

if v := props.OutboundIPAddresses; v != nil {
state.OutboundIPAddresses = *v
state.OutboundIPAddressList = strings.Split(*v, ",")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type WindowsFunctionAppSlotModel struct {
SiteConfig []helpers.SiteConfigWindowsFunctionAppSlot `tfschema:"site_config"`
Tags map[string]string `tfschema:"tags"`
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
HostingEnvId string `tfschema:"hosting_environment_id"`
DefaultHostname string `tfschema:"default_hostname"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
Expand Down Expand Up @@ -269,6 +270,11 @@ func (r WindowsFunctionAppSlotResource) Attributes() map[string]*pluginsdk.Schem
Description: "The default hostname of the Windows Function App Slot.",
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"kind": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -644,6 +650,10 @@ func (r WindowsFunctionAppSlotResource) Read() sdk.ResourceFunc {
DefaultHostname: pointer.From(props.DefaultHostName),
}

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
state.HostingEnvId = pointer.From(hostingEnv.ID)
}

functionApp, err := client.Get(ctx, id.ResourceGroup, id.SiteName)
if err != nil {
return fmt.Errorf("reading parent Function App for Linux %s: %+v", *id, err)
Expand Down
10 changes: 10 additions & 0 deletions internal/services/appservice/windows_web_app_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
Expand Down Expand Up @@ -40,6 +41,7 @@ type WindowsWebAppDataSourceModel struct {
StorageAccounts []helpers.StorageAccount `tfschema:"storage_account"`
ConnectionStrings []helpers.ConnectionString `tfschema:"connection_string"`
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
HostingEnvId string `tfschema:"hosting_environment_id"`
DefaultHostname string `tfschema:"default_hostname"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
Expand Down Expand Up @@ -130,6 +132,11 @@ func (d WindowsWebAppDataSource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
Expand Down Expand Up @@ -314,6 +321,9 @@ func (d WindowsWebAppDataSource) Read() sdk.ResourceFunc {
if subnetId := utils.NormalizeNilableString(props.VirtualNetworkSubnetID); subnetId != "" {
webApp.VirtualNetworkSubnetID = subnetId
}
if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
webApp.HostingEnvId = pointer.From(hostingEnv.ID)
}
}

webApp.AuthSettings = helpers.FlattenAuthSettings(auth)
Expand Down
10 changes: 10 additions & 0 deletions internal/services/appservice/windows_web_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type WindowsWebAppModel struct {
StorageAccounts []helpers.StorageAccount `tfschema:"storage_account"`
ConnectionStrings []helpers.ConnectionString `tfschema:"connection_string"`
CustomDomainVerificationId string `tfschema:"custom_domain_verification_id"`
HostingEnvId string `tfschema:"hosting_environment_id"`
DefaultHostname string `tfschema:"default_hostname"`
Kind string `tfschema:"kind"`
OutboundIPAddresses string `tfschema:"outbound_ip_addresses"`
Expand Down Expand Up @@ -190,6 +191,11 @@ func (r WindowsWebAppResource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},

"hosting_environment_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"kind": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -570,6 +576,10 @@ func (r WindowsWebAppResource) Read() sdk.ResourceFunc {
Tags: tags.ToTypedObject(webApp.Tags),
}

if hostingEnv := props.HostingEnvironmentProfile; hostingEnv != nil {
state.HostingEnvId = pointer.From(hostingEnv.ID)
}

if subnetId := pointer.From(props.VirtualNetworkSubnetID); subnetId != "" {
state.VirtualNetworkSubnetID = subnetId
}
Expand Down
Loading