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_network' - add guid attribute (#2325) #6445

Merged
merged 2 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -31,7 +31,6 @@ func dataSourceArmVirtualNetwork() *schema.Resource {
"resource_group_name": azure.SchemaResourceGroupNameForDataSource(),

"location": azure.SchemaLocationForDataSource(),

"address_space": {
Type: schema.TypeList,
Computed: true,
Expand All @@ -48,6 +47,11 @@ func dataSourceArmVirtualNetwork() *schema.Resource {
},
},

"guid": {
Type: schema.TypeString,
Computed: true,
},

"subnets": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -89,6 +93,10 @@ func dataSourceArmVnetRead(d *schema.ResourceData, meta interface{}) error {
}
d.SetId(*resp.ID)

if guid := resp.ResourceGUID; guid != nil {
d.Set("guid", resp.ResourceGUID)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d.Set will check if this is nil for us


if location := resp.Location; location != nil {
d.Set("location", azure.NormalizeLocation(*location))
}
Expand Down
10 changes: 10 additions & 0 deletions azurerm/internal/services/network/resource_arm_virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func resourceArmVirtualNetwork() *schema.Resource {
},
},

"guid": {
Type: schema.TypeString,
Computed: true,
},

"subnet": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -232,6 +237,11 @@ func resourceArmVirtualNetworkRead(d *schema.ResourceData, meta interface{}) err

d.Set("name", resp.Name)
d.Set("resource_group_name", resGroup)

if guid := resp.ResourceGUID; guid != nil {
d.Set("guid", resp.ResourceGUID)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d.Set will check if this is nil for us


if location := resp.Location; location != nil {
d.Set("location", azure.NormalizeLocation(*location))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestAccDataSourceArmVirtualNetwork_basic(t *testing.T) {
resource.TestCheckResourceAttr(data.ResourceName, "name", name),
resource.TestCheckResourceAttr(data.ResourceName, "location", azure.NormalizeLocation(data.Locations.Primary)),
resource.TestCheckResourceAttr(data.ResourceName, "dns_servers.0", "10.0.0.4"),
resource.TestCheckResourceAttr(data.ResourceName, "address_spaces.0", "10.0.0.0/16"),
resource.TestCheckResourceAttr(data.ResourceName, "address_space.0", "10.0.0.0/16"),
resource.TestCheckResourceAttr(data.ResourceName, "subnets.0", "subnet1"),
),
},
Expand All @@ -48,7 +48,7 @@ func TestAccDataSourceArmVirtualNetwork_peering(t *testing.T) {
Config: testAccDataSourceArmVirtualNetwork_peeringWithDataSource(data),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(data.ResourceName, "name", virtualNetworkName),
resource.TestCheckResourceAttr(data.ResourceName, "address_spaces.0", "10.0.1.0/24"),
resource.TestCheckResourceAttr(data.ResourceName, "address_space.0", "10.0.1.0/24"),
resource.TestCheckResourceAttr(data.ResourceName, "vnet_peerings.%", "1"),
),
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/virtual_network.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ output "virtual_network_id" {
* `location` - Location of the virtual network.
* `address_space` - The list of address spaces used by the virtual network.
* `dns_servers` - The list of DNS servers used by the virtual network.
* `guid` - The GUID of the virtual network.
* `subnets` - The list of name of the subnets that are attached to this virtual network.
* `vnet_peerings` - A mapping of name - virtual network id of the virtual network peerings.

Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/virtual_network.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ The following attributes are exported:

* `resource_group_name` - The name of the resource group in which to create the virtual network.

* `location` - The location/region where the virtual network is created
* `location` - The location/region where the virtual network is created.

* `address_space` - The address space that is used the virtual network.

* `guid` - The GUID of the virtual network.

* `subnet`- One or more `subnet` blocks as defined below.

---
Expand Down