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

New Data Source azurerm_virtual_wan #9382

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5d6e892
add virtual_wan data source with default param
EtienneDeneuve Nov 12, 2020
3be4a89
?? azurerm/internal/services/network/virtual_wan_data_source.go Edit#…
EtienneDeneuve Nov 13, 2020
b4c554c
Edit# 14235
EtienneDeneuve Nov 18, 2020
44b5392
M azurerm/internal/services/network/virtual_wan_data_source.go Edit#…
EtienneDeneuve Nov 18, 2020
73a7048
M azurerm/internal/services/network/virtual_wan_data_source.go Edit#…
EtienneDeneuve Nov 18, 2020
98b21c0
M azurerm/internal/services/network/virtual_wan_data_source.go Edit#…
EtienneDeneuve Nov 18, 2020
3064e4e
M azurerm/internal/services/network/virtual_wan_data_source.go Edit#…
EtienneDeneuve Nov 18, 2020
740da64
M azurerm/internal/services/network/virtual_wan_data_source.go Edit#…
EtienneDeneuve Nov 19, 2020
1025295
M azurerm/internal/services/network/virtual_wan_data_source.go Edit#…
EtienneDeneuve Nov 19, 2020
4b4fb40
M azurerm/internal/services/network/virtual_wan_data_source.go Edit#…
EtienneDeneuve Nov 19, 2020
82b7d15
Update website/docs/d/virtual_wan.html.markdown
EtienneDeneuve Nov 19, 2020
f452e41
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 19, 2020
274f187
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 19, 2020
b32461b
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 19, 2020
ab3bc0d
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 19, 2020
d180676
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 19, 2020
59961bc
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 19, 2020
acd81c9
Update website/docs/d/virtual_wan.html.markdown
EtienneDeneuve Nov 19, 2020
2cdb978
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 19, 2020
f6a4f2b
Update website/docs/d/virtual_wan.html.markdown
EtienneDeneuve Nov 19, 2020
68ee6f3
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 19, 2020
bb527b2
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 19, 2020
ef823ec
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 24, 2020
508982a
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 24, 2020
a2d5768
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 24, 2020
0078537
Update azurerm/internal/services/network/virtual_wan_data_source.go
EtienneDeneuve Nov 24, 2020
24cc410
Update website/docs/d/virtual_wan.html.markdown
EtienneDeneuve Nov 24, 2020
3a2c101
M go.mod
EtienneDeneuve Nov 24, 2020
d7e5f31
M go.mod
EtienneDeneuve Nov 24, 2020
ad4eff0
M go.mod
EtienneDeneuve Nov 24, 2020
e75ea56
remove go.(mod|sum)
EtienneDeneuve Nov 24, 2020
5adf72c
M go.mod
EtienneDeneuve Nov 24, 2020
65fa593
M go.mod
EtienneDeneuve Nov 24, 2020
2660dc8
M go.mod
EtienneDeneuve Nov 24, 2020
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
1 change: 1 addition & 0 deletions azurerm/internal/services/network/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (r Registration) SupportedDataSources() map[string]*schema.Resource {
"azurerm_virtual_network_gateway_connection": dataSourceArmVirtualNetworkGatewayConnection(),
"azurerm_virtual_network": dataSourceArmVirtualNetwork(),
"azurerm_web_application_firewall_policy": dataArmWebApplicationFirewallPolicy(),
"azurerm_virtual_wan": dataSourceArmVirtualWan(),
}
}

Expand Down
147 changes: 147 additions & 0 deletions azurerm/internal/services/network/virtual_wan_data_source.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package network

import (
"fmt"
"log"
"time"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-05-01/network"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func dataSourceArmVirtualWan() *schema.Resource {
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
return &schema.Resource{
Read: dataSourceArmVirtualWanRead,
Timeouts: &schema.ResourceTimeout{
Read: schema.DefaultTimeout(5 * time.Minute),
},

Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
},
"resource_group_name": azure.SchemaResourceGroupNameForDataSource(),

"allow_branch_to_branch_traffic": {
Type: schema.TypeBool,
Optional: true,
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
Computed: true,
},

"disable_vpn_encryption": {
Type: schema.TypeBool,
Optional: true,
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
Computed: true,
},
"office365_local_breakout_category": {
Type: schema.TypeString,
Optional: true,
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
Computed: true,
},
"sku": {
Type: schema.TypeString,
Computed: true,
},
"virtual_hubs": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
"vpn_sites": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
"location": azure.SchemaLocationForDataSource(),

"tags": tags.SchemaDataSource(),
},
}
}

func dataSourceArmVirtualWanRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Network.VirtualWanClient
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
defer cancel()

name := d.Get("name").(string)
resourceGroup := d.Get("resource_group_name").(string)

resp, err := client.Get(ctx, resourceGroup, name)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
return fmt.Errorf("Error: Virtual Wan %q (Resource Group %q) was not found", name, resourceGroup)
}
return fmt.Errorf("Error reading Virtual Wan %q (Resource Group %q): %+v", name, resourceGroup, err)
}

if resp.ID == nil || *resp.ID == "" {
return fmt.Errorf("API returns a nil/empty id on Virtual Wan %q (resource group %q): %+v", name, resourceGroup, err)
}
d.SetId(*resp.ID)

d.Set("name", resp.Name)
d.Set("resource_group_name", resourceGroup)
if location := resp.Location; location != nil {
d.Set("location", azure.NormalizeLocation(*location))
}
b := false
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved

if props := resp.VirtualWanProperties; props != nil {
log.Printf("[DEBUG] ETIENNE ETIENNE ETIENNE %+v", props)
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
if abtbt := *props.AllowBranchToBranchTraffic; props.AllowBranchToBranchTraffic != nil {
if err := d.Set("allow_branch_to_branch_traffic", abtbt); err != nil {
return fmt.Errorf("error setting `allow_branch_to_branch_traffic`: %v", err)
}
} else {
if err := d.Set("allow_branch_to_branch_traffic", &b); err != nil {
return fmt.Errorf("error setting `allow_branch_to_branch_traffic`: %v", err)
}
}
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
if dve := *props.DisableVpnEncryption; props.DisableVpnEncryption != nil {
if err := d.Set("disable_vpn_encryption", dve); err != nil {
return fmt.Errorf("error setting `disable_vpn_encryption`: %v", err)
}
} else {
if err := d.Set("disable_vpn_encryption", &b); err != nil {
return fmt.Errorf("error setting `disable_vpn_encryption`: %v", err)
}
}
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
if err := d.Set("office365_local_breakout_category", props.Office365LocalBreakoutCategory); err != nil {
return fmt.Errorf("error setting `office365_local_breakout_category`: %v", err)
}
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
if err := d.Set("sku", props.Type); err != nil {
return fmt.Errorf("error setting `sku`: %v", err)
}
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
if err := d.Set("virtual_hubs", flattenVirtualWanProperties(props.VirtualHubs)); err != nil {
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("error setting `virtual_hubs`: %v", err)
}
if err := d.Set("vpn_sites", flattenVirtualWanProperties(props.VpnSites)); err != nil {
EtienneDeneuve marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("error setting `vpn_sites`: %v", err)
}
}

return tags.FlattenAndSet(d, resp.Tags)
}

func flattenVirtualWanProperties(input *[]network.SubResource) []interface{} {
if input == nil {
return []interface{}{}
}
output := make([]interface{}, 0)
for _, v := range *input {
if v.ID != nil {
output = append(output, *v.ID)
}
}
return output
}
172 changes: 86 additions & 86 deletions website/docs/d/images.html.markdown
Original file line number Diff line number Diff line change
@@ -1,86 +1,86 @@
---
subcategory: "Compute"
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_images"
description: |-
Gets information about existing Images within a Resource Group.
---
# Data Source: azurerm_images
Use this data source to access information about existing Images within a Resource Group.
## Example Usage
```hcl
data "azurerm_images" "example" {
resource_group_name = "example-resources"
}
```
## Argument Reference
The following arguments are supported:
* `resource_group_name` - The name of the Resource Group in which the Image exists.
* `tags_filter` - A mapping of tags to filter the list of images against.
## Attributes Reference
The following attributes are exported:
* `images` - One or more `images` blocks as defined below:
---
A `images` block exports the following:
* `name` - The name of the Image.
* `location` - The supported Azure location where the Image exists.
* `zone_resilient` - Is zone resiliency enabled?
* `os_disk` - An `os_disk` block as defined below.
* `data_disk` - One or more `data_disk` blocks as defined below.
* `tags` - A mapping of tags assigned to the Image.
---
The `os_disk` block exports the following:
* `blob_uri` - the URI in Azure storage of the blob used to create the image.
* `caching` - the caching mode for the OS Disk.
* `managed_disk_id` - the ID of the Managed Disk used as the OS Disk Image.
* `os_state` - the State of the OS used in the Image.
* `os_type` - the type of Operating System used on the OS Disk.
* `size_gb` - the size of the OS Disk in GB.
---
The `data_disk` block exports the following:
* `blob_uri` - the URI in Azure storage of the blob used to create the image.
* `caching` - the caching mode for the Data Disk.
* `lun` - the logical unit number of the data disk.
* `managed_disk_id` - the ID of the Managed Disk used as the Data Disk Image.
* `size_gb` - the size of this Data Disk in GB.
## Timeouts
The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:
* `read` - (Defaults to 5 minutes) Used when retrieving the Images within a Resource Group.
---
subcategory: "Compute"
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_images"
description: |-
Gets information about existing Images within a Resource Group.

---

# Data Source: azurerm_images

Use this data source to access information about existing Images within a Resource Group.

## Example Usage

```hcl
data "azurerm_images" "example" {
resource_group_name = "example-resources"
}
```

## Argument Reference

The following arguments are supported:

* `resource_group_name` - The name of the Resource Group in which the Image exists.

* `tags_filter` - A mapping of tags to filter the list of images against.

## Attributes Reference

The following attributes are exported:

* `images` - One or more `images` blocks as defined below:

---

A `images` block exports the following:

* `name` - The name of the Image.

* `location` - The supported Azure location where the Image exists.

* `zone_resilient` - Is zone resiliency enabled?

* `os_disk` - An `os_disk` block as defined below.

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

* `tags` - A mapping of tags assigned to the Image.

---

The `os_disk` block exports the following:

* `blob_uri` - the URI in Azure storage of the blob used to create the image.

* `caching` - the caching mode for the OS Disk.

* `managed_disk_id` - the ID of the Managed Disk used as the OS Disk Image.

* `os_state` - the State of the OS used in the Image.

* `os_type` - the type of Operating System used on the OS Disk.

* `size_gb` - the size of the OS Disk in GB.

---

The `data_disk` block exports the following:

* `blob_uri` - the URI in Azure storage of the blob used to create the image.

* `caching` - the caching mode for the Data Disk.

* `lun` - the logical unit number of the data disk.

* `managed_disk_id` - the ID of the Managed Disk used as the Data Disk Image.

* `size_gb` - the size of this Data Disk in GB.

## Timeouts

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

* `read` - (Defaults to 5 minutes) Used when retrieving the Images within a Resource Group.
Loading