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

Bug Fix: azurerm_subnet - added computed support delegations.0.actions #5484

Merged
merged 2 commits into from
Jan 23, 2020
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
6 changes: 4 additions & 2 deletions azurerm/internal/services/network/resource_arm_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ func resourceArmSubnet() *schema.Resource {
}, false),
},
"actions": {
Type: schema.TypeList,
Optional: true,
Type: schema.TypeList,
Optional: true,
Computed: true,
ConfigMode: schema.SchemaConfigModeAttr,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,25 @@ func TestAccAzureRMSubnet_delegation(t *testing.T) {
})
}

func TestAccAzureRMSubnet_delegationComputedActions(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_subnet", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMSubnetDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMSubnet_delegationComputedActions(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMSubnetExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "delegation.#", "1"),
),
},
},
})
}

func TestAccAzureRMSubnet_routeTableUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_subnet", "test")

Expand Down Expand Up @@ -472,6 +491,37 @@ resource "azurerm_subnet" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMSubnet_delegationComputedActions(data acceptance.TestData) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%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 = "acctestsubnet%d"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.2.0/24"

delegation {
name = "acctestdelegation"

service_delegation {
name = "Microsoft.Sql/managedInstances"
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMSubnet_routeTable(data acceptance.TestData) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/subnet.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ A `service_delegation` block supports the following:

* `actions` - (Optional) A list of Actions which should be delegated. This list is specific to the service to delegate to. Possible values include `Microsoft.Network/networkinterfaces/*`, `Microsoft.Network/virtualNetworks/subnets/action`, `Microsoft.Network/virtualNetworks/subnets/join/action`, `Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action` and `Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action`.

-> **NOTE:** Azure may add default actions depending on the service delegation name and they can't be changed.

## Attributes Reference

The following attributes are exported:
Expand Down