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_virtual_hub - support for virtual_router_asn and virtual_router_ips properties #15741

Merged
merged 8 commits into from
Mar 22, 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
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ func flattenManagedApplicationParametersOrOutputs(input interface{}) (map[string
results[k] = v.(float64)
case string:
results[k] = v.(string)
case map[string]interface{}:
// Azure NVA managed applications read call returns empty map[string]interface{} parameter 'tags'
// Do not return an error if the parameter is unsupported type, but is empty
if len(v.(map[string]interface{})) == 0 {
log.Printf("parameter '%s' is unexpected type %T, but we're ignoring it because of the empty value", k, t)
} else {
return nil, fmt.Errorf("unexpected parameter type %T", t)
}
default:
return nil, fmt.Errorf("unexpected parameter type %T", t)
}
Expand Down
25 changes: 25 additions & 0 deletions internal/services/network/virtual_hub_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ func dataSourceVirtualHub() *pluginsdk.Resource {
Computed: true,
},

"virtual_router_asn": {
Type: pluginsdk.TypeInt,
Computed: true,
},

"virtual_router_ips": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},

"tags": tags.SchemaDataSource(),

"default_route_table_id": {
Expand Down Expand Up @@ -85,6 +98,18 @@ func dataSourceVirtualHubRead(d *pluginsdk.ResourceData, meta interface{}) error
virtualWanId = props.VirtualWan.ID
}
d.Set("virtual_wan_id", virtualWanId)

var virtualRouterAsn *int64
if props.VirtualRouterAsn != nil {
virtualRouterAsn = props.VirtualRouterAsn
}
d.Set("virtual_router_asn", virtualRouterAsn)

var virtualRouterIps *[]string
if props.VirtualRouterIps != nil {
virtualRouterIps = props.VirtualRouterIps
}
d.Set("virtual_router_ips", virtualRouterIps)
}

virtualHub, err := parse.VirtualHubID(*resp.ID)
Expand Down
2 changes: 2 additions & 0 deletions internal/services/network/virtual_hub_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func TestAccDataSourceAzureRMVirtualHub_basic(t *testing.T) {
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("address_prefix").Exists(),
check.That(data.ResourceName).Key("virtual_wan_id").Exists(),
check.That(data.ResourceName).Key("virtual_router_asn").Exists(),
check.That(data.ResourceName).Key("virtual_router_ips").Exists(),
),
},
})
Expand Down
25 changes: 25 additions & 0 deletions internal/services/network/virtual_hub_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ func resourceVirtualHub() *pluginsdk.Resource {
ValidateFunc: azure.ValidateResourceID,
},

"virtual_router_asn": {
Type: pluginsdk.TypeInt,
Computed: true,
},

"virtual_router_ips": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},

"route": {
Type: pluginsdk.TypeSet,
Optional: true,
Expand Down Expand Up @@ -234,6 +247,18 @@ func resourceVirtualHubRead(d *pluginsdk.ResourceData, meta interface{}) error {
virtualWanId = props.VirtualWan.ID
}
d.Set("virtual_wan_id", virtualWanId)

var virtualRouterAsn *int64
if props.VirtualRouterAsn != nil {
virtualRouterAsn = props.VirtualRouterAsn
}
d.Set("virtual_router_asn", virtualRouterAsn)

var virtualRouterIps *[]string
if props.VirtualRouterIps != nil {
virtualRouterIps = props.VirtualRouterIps
}
d.Set("virtual_router_ips", virtualRouterIps)
}

defaultRouteTable := parse.NewHubRouteTableID(id.SubscriptionId, id.ResourceGroup, id.Name, "defaultRouteTable")
Expand Down
2 changes: 2 additions & 0 deletions internal/services/network/virtual_hub_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func TestAccVirtualHub_basic(t *testing.T) {
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("virtual_router_asn").Exists(),
check.That(data.ResourceName).Key("virtual_router_ips").Exists(),
),
},
data.ImportStep(),
Expand Down
4 changes: 4 additions & 0 deletions website/docs/d/virtual_hub.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ The following attributes are exported:

* `default_route_table_id` - The ID of the default Route Table in the Virtual Hub.

* `virtual_router_asn` - The Autonomous System Number of the Virtual Hub BGP router.

* `virtual_router_ips` - The IP addresses of the Virtual Hub BGP router.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/virtual_hub.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ The following attributes are exported:

* `default_route_table_id` - The ID of the default Route Table in the Virtual Hub.

* `virtual_router_asn` - The Autonomous System Number of the Virtual Hub BGP router.

* `virtual_router_ips` - The IP addresses of the Virtual Hub BGP router.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:
Expand Down