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

azurem_logic_app_standard - support for scm_ip_restriction, scm_use_main_ip_restriction scm_min_tls_version scm_type #18853

Merged
merged 2 commits into from
Oct 24, 2022
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
8 changes: 8 additions & 0 deletions internal/services/logic/logic_app_standard_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ func flattenLogicAppStandardDataSourceSiteConfig(input *web.SiteConfig) []interf

result["ip_restriction"] = flattenLogicAppStandardIpRestriction(input.IPSecurityRestrictions)

result["scm_type"] = string(input.ScmType)
result["scm_min_tls_version"] = string(input.ScmMinTLSVersion)
result["scm_ip_restriction"] = flattenLogicAppStandardIpRestriction(input.ScmIPSecurityRestrictions)

if input.ScmIPSecurityRestrictionsUseMain != nil {
result["scm_use_main_ip_restriction"] = *input.ScmIPSecurityRestrictionsUseMain
}

result["min_tls_version"] = string(input.MinTLSVersion)
result["ftps_state"] = string(input.FtpsState)

Expand Down
71 changes: 71 additions & 0 deletions internal/services/logic/logic_app_standard_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,47 @@ func schemaLogicAppStandardSiteConfig() *pluginsdk.Schema {
ValidateFunc: validation.IntBetween(0, 20),
},

"scm_ip_restriction": schemaLogicAppStandardIpRestriction(),

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

"scm_min_tls_version": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
string(web.SupportedTLSVersionsOneFullStopZero),
string(web.SupportedTLSVersionsOneFullStopOne),
string(web.SupportedTLSVersionsOneFullStopTwo),
}, false),
},

"scm_type": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
string(web.ScmTypeBitbucketGit),
string(web.ScmTypeBitbucketHg),
string(web.ScmTypeCodePlexGit),
string(web.ScmTypeCodePlexHg),
string(web.ScmTypeDropbox),
string(web.ScmTypeExternalGit),
string(web.ScmTypeExternalHg),
string(web.ScmTypeGitHub),
string(web.ScmTypeLocalGit),
string(web.ScmTypeNone),
string(web.ScmTypeOneDrive),
string(web.ScmTypeTfs),
string(web.ScmTypeVSO),
string(web.ScmTypeVSTSRM),
}, false),
},

"use_32_bit_worker_process": {
Type: pluginsdk.TypeBool,
Optional: true,
Expand Down Expand Up @@ -1009,6 +1050,15 @@ func flattenLogicAppStandardSiteConfig(input *web.SiteConfig) []interface{} {

result["ip_restriction"] = flattenLogicAppStandardIpRestriction(input.IPSecurityRestrictions)

result["scm_ip_restriction"] = flattenLogicAppStandardIpRestriction(input.ScmIPSecurityRestrictions)

if input.ScmIPSecurityRestrictionsUseMain != nil {
result["scm_use_main_ip_restriction"] = *input.ScmIPSecurityRestrictionsUseMain
}

result["scm_type"] = string(input.ScmType)
result["scm_min_tls_version"] = string(input.ScmMinTLSVersion)

result["min_tls_version"] = string(input.MinTLSVersion)
result["ftps_state"] = string(input.FtpsState)

Expand Down Expand Up @@ -1213,6 +1263,27 @@ func expandLogicAppStandardSiteConfig(d *pluginsdk.ResourceData) (web.SiteConfig
siteConfig.IPSecurityRestrictions = &restrictions
}

if v, ok := config["scm_ip_restriction"]; ok {
scmIPSecurityRestrictions := v.([]interface{})
scmRestrictions, err := expandLogicAppStandardIpRestriction(scmIPSecurityRestrictions)
if err != nil {
return siteConfig, err
}
siteConfig.ScmIPSecurityRestrictions = &scmRestrictions
}

if v, ok := config["scm_use_main_ip_restriction"]; ok {
siteConfig.ScmIPSecurityRestrictionsUseMain = utils.Bool(v.(bool))
}

if v, ok := config["scm_min_tls_version"]; ok {
siteConfig.ScmMinTLSVersion = web.SupportedTLSVersions(v.(string))
}

if v, ok := config["scm_type"]; ok {
siteConfig.ScmType = web.ScmType(v.(string))
}

if v, ok := config["min_tls_version"]; ok {
siteConfig.MinTLSVersion = web.SupportedTLSVersions(v.(string))
}
Expand Down
157 changes: 157 additions & 0 deletions internal/services/logic/logic_app_standard_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,66 @@ func TestAccLogicAppStandard_manyIpRestrictions(t *testing.T) {
})
}

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

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.scmType(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

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

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.scmUseMainIpRestriction(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

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

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.scmIpRestriction(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

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

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.scmMinTlsVersion(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccLogicAppStandard_updateStorageAccountKey(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_logic_app_standard", "test")
r := LogicAppStandardResource{}
Expand Down Expand Up @@ -1521,6 +1581,103 @@ resource "azurerm_logic_app_standard" "test" {
`, r.template(data), data.RandomInteger)
}

func (r LogicAppStandardResource) scmType(data acceptance.TestData) 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 {
scm_type = "LocalGit"
}
}
`, r.template(data), data.RandomInteger)
}

func (r LogicAppStandardResource) scmUseMainIpRestriction(data acceptance.TestData) 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 {
ip_restriction {
ip_address = "10.10.10.10/32"
}
scm_use_main_ip_restriction = true
}
}
`, r.template(data), data.RandomInteger)
}

func (r LogicAppStandardResource) scmIpRestriction(data acceptance.TestData) 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 {
ip_restriction {
ip_address = "10.10.10.10/32"
}
}
}
`, r.template(data), data.RandomInteger)
}

func (r LogicAppStandardResource) scmMinTlsVersion(data acceptance.TestData) 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 {
scm_min_tls_version = 1.2
}
}
`, r.template(data), data.RandomInteger)
}

func (r LogicAppStandardResource) updateStorageAccountKey(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
30 changes: 30 additions & 0 deletions website/docs/r/logic_app_standard.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ The following arguments are supported:

-> **NOTE** User has to explicitly set `ip_restriction` to empty slice (`[]`) to remove it.

* `scm_ip_restriction` - A [List of objects](/docs/configuration/attr-as-blocks.html) representing SCM IP restrictions as defined below.

-> **NOTE** User has to explicitly set `scm_ip_restriction` to empty slice (`[]`) to remove it.

* `scm_use_main_ip_restriction` - (Optional) Should the Logic App `ip_restriction` configuration be used for the SCM too. Defaults to `false`.

* `scm_min_tls_version` - (Optional) Configures the minimum version of TLS required for SSL requests to the SCM site.

* `scm_type` - The type of Source Control used by the Logic App in use by the Windows Function App. Defaults to `None`. Possible values are: `BitbucketGit`, `BitbucketHg`, `CodePlexGit`, `CodePlexHg`, `Dropbox`, `ExternalGit`, `ExternalHg`, `GitHub`, `LocalGit`, `None`, `OneDrive`, `Tfs`, `VSO`, and `VSTSRM`

* `linux_fx_version` - (Optional) Linux App Framework and version for the AppService, e.g. `DOCKER|(golang:latest)`. Setting this value will also set the `kind` of application deployed to `functionapp,linux,container,workflowapp`

* `min_tls_version` - (Optional) The minimum supported TLS version for the Logic App Possible values are `1.0`, `1.1`, and `1.2`. Defaults to `1.2` for new Logic Apps.
Expand Down Expand Up @@ -248,6 +258,26 @@ A `ip_restriction` block supports the following:

---

A `scm_ip_restriction` block supports the following:

* `ip_address` - (Optional) The IP Address used for this IP Restriction in CIDR notation.

* `service_tag` - (Optional) The Service Tag used for this IP Restriction.

* `virtual_network_subnet_id` - (Optional) The Virtual Network Subnet ID used for this IP Restriction.

-> **NOTE:** One of either `ip_address`, `service_tag` or `virtual_network_subnet_id` must be specified

* `name` - (Optional) The name for this IP Restriction.

* `priority` - (Optional) The priority for this IP Restriction. Restrictions are enforced in priority order. By default, the priority is set to 65000 if not specified.

* `action` - (Optional) Does this restriction `Allow` or `Deny` access for this IP range. Defaults to `Allow`.

* `headers` - (Optional) The headers for this specific `ip_restriction` as defined below.

---

A `headers` block supports the following:

* `x_azure_fdid` - (Optional) A list of allowed Azure FrontDoor IDs in UUID notation with a maximum of 8.
Expand Down