Skip to content

Commit

Permalink
azurerm_windows_web_app,azurerm_windows_web_app_slot, `azurerm_wi…
Browse files Browse the repository at this point in the history
…ndows_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)
  • Loading branch information
xiaxyi authored Apr 20, 2023
1 parent c4b10af commit 5ce58f2
Show file tree
Hide file tree
Showing 24 changed files with 146 additions and 0 deletions.
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 @@ -53,6 +54,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 @@ -196,6 +198,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 @@ -331,6 +338,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
10 changes: 10 additions & 0 deletions internal/services/appservice/linux_function_app_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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 @@ -289,6 +290,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 @@ -685,6 +691,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
10 changes: 10 additions & 0 deletions internal/services/appservice/linux_function_app_slot_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,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 @@ -270,6 +271,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 @@ -654,6 +660,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
11 changes: 11 additions & 0 deletions internal/services/appservice/windows_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 @@ -53,6 +54,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 @@ -187,6 +189,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 @@ -276,6 +283,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 @@ -63,6 +63,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 @@ -289,6 +290,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 @@ -682,6 +688,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
10 changes: 10 additions & 0 deletions internal/services/appservice/windows_function_app_slot_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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 @@ -272,6 +273,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 @@ -662,6 +668,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 Windows %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

0 comments on commit 5ce58f2

Please sign in to comment.