Skip to content

Commit

Permalink
change sku tier to not force new (#17577)
Browse files Browse the repository at this point in the history
* change sku tier to ot force new

* add test

* Update internal/services/firewall/firewall_resource.go

Co-authored-by: kt <[email protected]>

* Update internal/services/firewall/firewall_resource_test.go

Co-authored-by: kt <[email protected]>

* add cost and upadated doc

* add quotes to around sku value in test config

Co-authored-by: Dikla Tzemah Weyl <[email protected]>
Co-authored-by: kt <[email protected]>
Co-authored-by: Steph <[email protected]>
  • Loading branch information
4 people authored Aug 2, 2022
1 parent b6f38c0 commit bb74eca
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
1 change: 0 additions & 1 deletion internal/services/firewall/firewall_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func resourceFirewall() *pluginsdk.Resource {
"sku_tier": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(network.AzureFirewallSkuTierPremium),
string(network.AzureFirewallSkuTierStandard),
Expand Down
80 changes: 80 additions & 0 deletions internal/services/firewall/firewall_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (

type FirewallResource struct{}

const premium = "Premium"
const standard = "Standard"

func TestAccFirewall_basic(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_firewall", "test")
r := FirewallResource{}
Expand Down Expand Up @@ -194,6 +197,31 @@ func TestAccFirewall_withZones(t *testing.T) {
})
}

func TestAccFirewall_skuTierUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_firewall", "test")
r := FirewallResource{}
skuTier := standard
skuTierUpdate := premium

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.withSkuTier(data, skuTier),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("sku_tier").HasValue("Standard"),
),
},
{
Config: r.withSkuTier(data, skuTierUpdate),
Check: acceptance.ComposeTestCheckFunc(

check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("sku_tier").HasValue("Premium"),
),
},
})
}

func TestAccFirewall_withoutZone(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_firewall", "test")
r := FirewallResource{}
Expand Down Expand Up @@ -764,6 +792,58 @@ resource "azurerm_firewall" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}

func (FirewallResource) withSkuTier(data acceptance.TestData, skuTier string) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-fw-%d"
location = "%s"
}
resource "azurerm_virtual_network" "test" {
name = "acctestvirtnet%d"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_subnet" "test" {
name = "AzureFirewallSubnet"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.1.0/24"]
}
resource "azurerm_public_ip" "test" {
name = "acctestpip%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
allocation_method = "Static"
sku = "Standard"
zones = []
}
resource "azurerm_firewall" "test" {
name = "acctestfirewall%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku_name = "AZFW_VNet"
sku_tier = "%s"
ip_configuration {
name = "configuration"
subnet_id = azurerm_subnet.test.id
public_ip_address_id = azurerm_public_ip.test.id
}
zones = []
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, skuTier)
}

func (FirewallResource) withZones(data acceptance.TestData, zones []string) string {
zoneString := strings.Join(zones, ",")
return fmt.Sprintf(`
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/firewall.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The following arguments are supported:

* `sku_name` - (Required) SKU name of the Firewall. Possible values are `AZFW_Hub` and `AZFW_VNet`. Changing this forces a new resource to be created.

* `sku_tier` - (Required) SKU tier of the Firewall. Possible values are `Premium` and `Standard`. Changing this forces a new resource to be created.
* `sku_tier` - (Required) SKU tier of the Firewall. Possible values are `Premium` and `Standard`.

* `firewall_policy_id` - (Optional) The ID of the Firewall Policy applied to this Firewall.

Expand Down

0 comments on commit bb74eca

Please sign in to comment.