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_logic_app_standard - add support for site_config.0.public_network_access_enabled #24257

Merged
merged 2 commits into from
Dec 18, 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
22 changes: 22 additions & 0 deletions internal/services/logic/logic_app_standard_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import (
"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/resourcemanager/commonids"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/identity"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/appservice/helpers"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/logic/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/logic/validate"
storageValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate"
Expand Down Expand Up @@ -868,6 +870,12 @@ func schemaLogicAppStandardSiteConfig() *pluginsdk.Schema {
Computed: true,
},

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

"auto_swap_slot_name": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -1115,6 +1123,12 @@ func flattenLogicAppStandardSiteConfig(input *web.SiteConfig) []interface{} {
}
result["vnet_route_all_enabled"] = vnetRouteAllEnabled

publicNetworkAccessEnabled := true
if input.PublicNetworkAccess != nil {
publicNetworkAccessEnabled = !strings.EqualFold(pointer.From(input.PublicNetworkAccess), helpers.PublicNetworkAccessDisabled)
}
result["public_network_access_enabled"] = publicNetworkAccessEnabled

results = append(results, result)
return results
}
Expand Down Expand Up @@ -1342,6 +1356,14 @@ func expandLogicAppStandardSiteConfig(d *pluginsdk.ResourceData) (web.SiteConfig
siteConfig.VnetRouteAllEnabled = utils.Bool(v.(bool))
}

if v, ok := config["public_network_access_enabled"]; ok {
pna := helpers.PublicNetworkAccessEnabled
if !v.(bool) {
pna = helpers.PublicNetworkAccessDisabled
}
siteConfig.PublicNetworkAccess = pointer.To(pna)
}

return siteConfig, nil
}

Expand Down
47 changes: 47 additions & 0 deletions internal/services/logic/logic_app_standard_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,30 @@ func TestAccLogicAppStandard_vNetIntegrationUpdate(t *testing.T) {
})
}

func TestAccLogicAppStandard_publicNetworkAccessEnabled(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_logic_app_standard", "test")
r := LogicAppStandardResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.publicNetworkAccessEnabled(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("site_config.0.public_network_access_enabled").HasValue("false"),
),
},
data.ImportStep(),
{
Config: r.publicNetworkAccessEnabled(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("site_config.0.public_network_access_enabled").HasValue("true"),
),
},
data.ImportStep(),
})
}

func (r LogicAppStandardResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.LogicAppStandardID(state.ID)
if err != nil {
Expand Down Expand Up @@ -2174,3 +2198,26 @@ resource "azurerm_logic_app_standard" "test" {

`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r LogicAppStandardResource) publicNetworkAccessEnabled(data acceptance.TestData, enabled bool) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

%s

resource "azurerm_logic_app_standard" "test" {
name = "acctest-%d-func"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
app_service_plan_id = azurerm_app_service_plan.test.id
storage_account_name = azurerm_storage_account.test.name
storage_account_access_key = azurerm_storage_account.test.primary_access_key

site_config {
public_network_access_enabled = %t
}
}
`, r.template(data), data.RandomInteger, enabled)
}
2 changes: 2 additions & 0 deletions website/docs/r/logic_app_standard.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ The `site_config` block supports the following:

* `pre_warmed_instance_count` - (Optional) The number of pre-warmed instances for this Logic App Only affects apps on the Premium plan.

* `public_network_access_enabled` - (Optional) Is public network access enabled? Defaults to `true`.

* `runtime_scale_monitoring_enabled` - (Optional) Should Runtime Scale Monitoring be enabled?. Only applicable to apps on the Premium plan. Defaults to `false`.

* `use_32_bit_worker_process` - (Optional) Should the Logic App run in 32 bit mode, rather than 64 bit mode? Defaults to `true`.
Expand Down
Loading