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

change sku tier to not force new #17577

Merged
merged 7 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion internal/services/firewall/firewall_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func resourceFirewall() *pluginsdk.Resource {
"sku_tier": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ForceNew: false,
diklatze marked this conversation as resolved.
Show resolved Hide resolved
ValidateFunc: validation.StringInSlice([]string{
string(network.AzureFirewallSkuTierPremium),
string(network.AzureFirewallSkuTierStandard),
Expand Down
78 changes: 78 additions & 0 deletions internal/services/firewall/firewall_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"testing"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-08-01/network"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -194,6 +195,31 @@ func TestAccFirewall_withZones(t *testing.T) {
})
}

func TestAccFirewall_skuTier(t *testing.T) {
diklatze marked this conversation as resolved.
Show resolved Hide resolved
data := acceptance.BuildTestData(t, "azurerm_firewall", "test")
r := FirewallResource{}
skuTier := string(network.AzureFirewallSkuTierStandard)
skuTierUpdate := string(network.AzureFirewallSkuTierPremium)
diklatze marked this conversation as resolved.
Show resolved Hide resolved

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 +790,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