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

Add resources azurerm_virtual_network_gateway and azurerm_virtual_network_gateway_connection #133

Merged
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1f79d31
Add resources azurerm_virtual_network_gateway and azurerm_virtual_net…
dominik-lekse Jun 26, 2017
2087dd7
Adapt resources azurerm_virtual_network_gateway and azurerm_virtual_n…
dominik-lekse Jun 26, 2017
a236467
Applied review feedback to azurerm_virtual_network_gateway and azurer…
dominik-lekse Jun 26, 2017
ee0bbe1
Add support for latest skus in azurerm_virtual_network_gateway
dominik-lekse Jun 26, 2017
b89586f
Fixed validation of skus in azurerm_virtual_network_gateway
dominik-lekse Jun 26, 2017
2990404
Merge branch 'master' into feature/virtual-network-gateway
dominik-lekse Aug 5, 2017
c6ec4bc
Revised resources azurerm_virtual_network_gateway and azurerm_virtual…
dominik-lekse Aug 5, 2017
554046a
Fixed import tests TestAccAzureRMVirtualNetworkGateway_importBasic an…
dominik-lekse Aug 5, 2017
b4143ba
Merge branch 'master' into feature/virtual-network-gateway
dominik-lekse Sep 16, 2017
b06dd57
Fixed description of field authorization_key in documentation of reso…
dominik-lekse Sep 17, 2017
f07a31c
virtual_network_gateway_connection: Removed reading parameters which …
dominik-lekse Sep 17, 2017
0325c74
virtual_network_gateway: Removed comments on subnet deletion workaround
dominik-lekse Sep 17, 2017
1686272
Revised test for resources virtual_network_gateway and virtual_networ…
dominik-lekse Sep 17, 2017
ed51416
Merge branch 'master' into feature/virtual-network-gateway
dominik-lekse Sep 30, 2017
9739bc1
Merge branch 'master' into feature/virtual-network-gateway
dominik-lekse Oct 31, 2017
f95bf5d
azurer_virtual_network_gateway: Ignore case for subnet_id
dominik-lekse Oct 31, 2017
26b1d69
Merge branch 'master' into feature/virtual-network-gateway
dominik-lekse Jan 23, 2018
4baf7e5
Migrated resources virtual_network_gateway and virtual_network_gatewa…
dominik-lekse Jan 23, 2018
d724fd7
Migrated acceptance tests for resources virtual_network_gateway and v…
dominik-lekse Jan 24, 2018
8fcfc41
Merge branch 'master' into feature/virtual-network-gateway
dominik-lekse Jan 25, 2018
51614e0
Minor refactoring
tombuildsstuff Jan 25, 2018
d94db0f
Making the `vpn_client_configuration` a list
tombuildsstuff Jan 25, 2018
1b6ddaa
Crash protection for importing legacy resources
tombuildsstuff Jan 25, 2018
81a63b6
Refactoring to make `bgp_settings` a List
tombuildsstuff Jan 25, 2018
6b2f496
Fixing minor linting issues
tombuildsstuff Jan 25, 2018
19eb152
Working around a golint bug in the VNG acctests
tombuildsstuff Jan 25, 2018
f82fdd1
Adding validation to match the Azure Portal
tombuildsstuff Jan 25, 2018
66e4602
Adding a test covering updating the shared key
tombuildsstuff Jan 26, 2018
5046f19
Consistency in the documentation for VNG's/VNG Connections
tombuildsstuff Jan 26, 2018
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
Prev Previous commit
Next Next commit
Merge branch 'master' into feature/virtual-network-gateway
# Conflicts:
#	azurerm/provider.go
#	azurerm/resource_arm_subnet.go
#	azurerm/validators.go
dominik-lekse committed Sep 16, 2017
commit b4143baa993e4d92ff5a74fe6960ea081fe09a02
141 changes: 69 additions & 72 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
@@ -70,82 +70,79 @@ func Provider() terraform.ResourceProvider {
},

ResourcesMap: map[string]*schema.Resource{
"azurerm_application_insights": resourceArmApplicationInsights(),
"azurerm_app_service_plan": resourceArmAppServicePlan(),
"azurerm_availability_set": resourceArmAvailabilitySet(),
"azurerm_cdn_endpoint": resourceArmCdnEndpoint(),
"azurerm_cdn_profile": resourceArmCdnProfile(),
"azurerm_container_registry": resourceArmContainerRegistry(),
"azurerm_container_service": resourceArmContainerService(),
"azurerm_container_group": resourceArmContainerGroup(),
"azurerm_cosmosdb_account": resourceArmCosmosDBAccount(),
"azurerm_dns_a_record": resourceArmDnsARecord(),
"azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(),
"azurerm_dns_cname_record": resourceArmDnsCNameRecord(),
"azurerm_dns_mx_record": resourceArmDnsMxRecord(),
"azurerm_dns_ns_record": resourceArmDnsNsRecord(),
"azurerm_dns_ptr_record": resourceArmDnsPtrRecord(),
"azurerm_dns_srv_record": resourceArmDnsSrvRecord(),
"azurerm_dns_txt_record": resourceArmDnsTxtRecord(),
"azurerm_dns_zone": resourceArmDnsZone(),
"azurerm_eventgrid_topic": resourceArmEventGridTopic(),
"azurerm_eventhub": resourceArmEventHub(),
"azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(),
"azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(),
"azurerm_eventhub_namespace": resourceArmEventHubNamespace(),
"azurerm_express_route_circuit": resourceArmExpressRouteCircuit(),
"azurerm_image": resourceArmImage(),
"azurerm_key_vault": resourceArmKeyVault(),

"azurerm_lb": resourceArmLoadBalancer(),
"azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(),
"azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(),
"azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(),
"azurerm_lb_probe": resourceArmLoadBalancerProbe(),
"azurerm_lb_rule": resourceArmLoadBalancerRule(),
"azurerm_local_network_gateway": resourceArmLocalNetworkGateway(),

"azurerm_managed_disk": resourceArmManagedDisk(),
"azurerm_network_interface": resourceArmNetworkInterface(),
"azurerm_network_security_group": resourceArmNetworkSecurityGroup(),
"azurerm_network_security_rule": resourceArmNetworkSecurityRule(),
"azurerm_public_ip": resourceArmPublicIp(),

"azurerm_redis_cache": resourceArmRedisCache(),
"azurerm_route": resourceArmRoute(),
"azurerm_route_table": resourceArmRouteTable(),

"azurerm_servicebus_namespace": resourceArmServiceBusNamespace(),
"azurerm_servicebus_queue": resourceArmServiceBusQueue(),
"azurerm_servicebus_subscription": resourceArmServiceBusSubscription(),
"azurerm_servicebus_topic": resourceArmServiceBusTopic(),
"azurerm_sql_elasticpool": resourceArmSqlElasticPool(),
"azurerm_storage_account": resourceArmStorageAccount(),
"azurerm_storage_blob": resourceArmStorageBlob(),
"azurerm_storage_container": resourceArmStorageContainer(),
"azurerm_storage_share": resourceArmStorageShare(),
"azurerm_storage_queue": resourceArmStorageQueue(),
"azurerm_storage_table": resourceArmStorageTable(),
"azurerm_subnet": resourceArmSubnet(),

"azurerm_template_deployment": resourceArmTemplateDeployment(),
"azurerm_traffic_manager_endpoint": resourceArmTrafficManagerEndpoint(),
"azurerm_traffic_manager_profile": resourceArmTrafficManagerProfile(),
"azurerm_virtual_machine_extension": resourceArmVirtualMachineExtensions(),
"azurerm_virtual_machine": resourceArmVirtualMachine(),
"azurerm_virtual_machine_scale_set": resourceArmVirtualMachineScaleSet(),

"azurerm_application_insights": resourceArmApplicationInsights(),
"azurerm_app_service_plan": resourceArmAppServicePlan(),
"azurerm_availability_set": resourceArmAvailabilitySet(),
"azurerm_cdn_endpoint": resourceArmCdnEndpoint(),
"azurerm_cdn_profile": resourceArmCdnProfile(),
"azurerm_container_registry": resourceArmContainerRegistry(),
"azurerm_container_service": resourceArmContainerService(),
"azurerm_container_group": resourceArmContainerGroup(),
"azurerm_cosmosdb_account": resourceArmCosmosDBAccount(),
"azurerm_dns_a_record": resourceArmDnsARecord(),
"azurerm_dns_aaaa_record": resourceArmDnsAAAARecord(),
"azurerm_dns_cname_record": resourceArmDnsCNameRecord(),
"azurerm_dns_mx_record": resourceArmDnsMxRecord(),
"azurerm_dns_ns_record": resourceArmDnsNsRecord(),
"azurerm_dns_ptr_record": resourceArmDnsPtrRecord(),
"azurerm_dns_srv_record": resourceArmDnsSrvRecord(),
"azurerm_dns_txt_record": resourceArmDnsTxtRecord(),
"azurerm_dns_zone": resourceArmDnsZone(),
"azurerm_eventgrid_topic": resourceArmEventGridTopic(),
"azurerm_eventhub": resourceArmEventHub(),
"azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(),
"azurerm_eventhub_consumer_group": resourceArmEventHubConsumerGroup(),
"azurerm_eventhub_namespace": resourceArmEventHubNamespace(),
"azurerm_express_route_circuit": resourceArmExpressRouteCircuit(),
"azurerm_image": resourceArmImage(),
"azurerm_key_vault": resourceArmKeyVault(),
"azurerm_key_vault_secret": resourceArmKeyVaultSecret(),
"azurerm_lb": resourceArmLoadBalancer(),
"azurerm_lb_backend_address_pool": resourceArmLoadBalancerBackendAddressPool(),
"azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(),
"azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(),
"azurerm_lb_probe": resourceArmLoadBalancerProbe(),
"azurerm_lb_rule": resourceArmLoadBalancerRule(),
"azurerm_local_network_gateway": resourceArmLocalNetworkGateway(),
"azurerm_managed_disk": resourceArmManagedDisk(),
"azurerm_network_interface": resourceArmNetworkInterface(),
"azurerm_network_security_group": resourceArmNetworkSecurityGroup(),
"azurerm_network_security_rule": resourceArmNetworkSecurityRule(),
"azurerm_postgresql_configuration": resourceArmPostgreSQLConfiguration(),
"azurerm_postgresql_database": resourceArmPostgreSQLDatabase(),
"azurerm_postgresql_firewall_rule": resourceArmPostgreSQLFirewallRule(),
"azurerm_postgresql_server": resourceArmPostgreSQLServer(),
"azurerm_public_ip": resourceArmPublicIp(),
"azurerm_redis_cache": resourceArmRedisCache(),
"azurerm_resource_group": resourceArmResourceGroup(),
"azurerm_route": resourceArmRoute(),
"azurerm_route_table": resourceArmRouteTable(),
"azurerm_search_service": resourceArmSearchService(),
"azurerm_servicebus_namespace": resourceArmServiceBusNamespace(),
"azurerm_servicebus_queue": resourceArmServiceBusQueue(),
"azurerm_servicebus_subscription": resourceArmServiceBusSubscription(),
"azurerm_servicebus_topic": resourceArmServiceBusTopic(),
"azurerm_sql_database": resourceArmSqlDatabase(),
"azurerm_sql_elasticpool": resourceArmSqlElasticPool(),
"azurerm_sql_firewall_rule": resourceArmSqlFirewallRule(),
"azurerm_sql_server": resourceArmSqlServer(),
"azurerm_storage_account": resourceArmStorageAccount(),
"azurerm_storage_blob": resourceArmStorageBlob(),
"azurerm_storage_container": resourceArmStorageContainer(),
"azurerm_storage_share": resourceArmStorageShare(),
"azurerm_storage_queue": resourceArmStorageQueue(),
"azurerm_storage_table": resourceArmStorageTable(),
"azurerm_subnet": resourceArmSubnet(),
"azurerm_template_deployment": resourceArmTemplateDeployment(),
"azurerm_traffic_manager_endpoint": resourceArmTrafficManagerEndpoint(),
"azurerm_traffic_manager_profile": resourceArmTrafficManagerProfile(),
"azurerm_virtual_machine_extension": resourceArmVirtualMachineExtensions(),
"azurerm_virtual_machine": resourceArmVirtualMachine(),
"azurerm_virtual_machine_scale_set": resourceArmVirtualMachineScaleSet(),
"azurerm_virtual_network": resourceArmVirtualNetwork(),
"azurerm_virtual_network_gateway": resourceArmVirtualNetworkGateway(),
"azurerm_virtual_network_gateway_connection": resourceArmVirtualNetworkGatewayConnection(),
"azurerm_virtual_network_peering": resourceArmVirtualNetworkPeering(),

// These resources use the Riviera SDK
"azurerm_resource_group": resourceArmResourceGroup(),
"azurerm_search_service": resourceArmSearchService(),
"azurerm_sql_database": resourceArmSqlDatabase(),
"azurerm_sql_firewall_rule": resourceArmSqlFirewallRule(),
"azurerm_sql_server": resourceArmSqlServer(),
},
}

20 changes: 0 additions & 20 deletions azurerm/resource_arm_local_network_gateway.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import (
"net/http"

"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)
@@ -157,22 +156,3 @@ func resourceGroupAndLocalNetworkGatewayFromId(localNetworkGatewayId string) (st

return resGroup, name, nil
}

func retrieveLocalNetworkGatewayById(localNetworkGatewayId string, meta interface{}) (*network.LocalNetworkGateway, bool, error) {
lnetClient := meta.(*ArmClient).localNetConnClient

resGroup, name, err := resourceGroupAndLocalNetworkGatewayFromId(localNetworkGatewayId)
if err != nil {
return nil, false, errwrap.Wrapf("Error Getting LocalNetworkGateway Name and Group: {{err}}", err)
}

resp, err := lnetClient.Get(resGroup, name)
if err != nil {
if responseWasNotFound(resp.Response) {
return nil, false, nil
}
return nil, false, fmt.Errorf("Error making Read request on Azure LocalNetworkGateway %s: %+v", name, err)
}

return &resp, true, nil
}
46 changes: 1 addition & 45 deletions azurerm/resource_arm_subnet.go
Original file line number Diff line number Diff line change
@@ -5,9 +5,8 @@ import (
"log"

"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"time"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

var subnetResourceName = "azurerm_subnet"
@@ -233,48 +232,5 @@ func resourceArmSubnetDelete(d *schema.ResourceData, meta interface{}) error {
_, error := subnetClient.Delete(resGroup, vnetName, name, make(chan struct{}))
err = <-error

// After deleting a gateway subnet, we check if the subnet has been deleted and
// retry if necessary. This is necessary as a workaround for scenarios in which
// a gateway subnet is deleted immediately after its previously associated
// virtual network gateway has been deleted. Unfortunately, the Azure Management
// API does not provide information on the state, therefore we try for a
// limited period of time.
if err != nil && name == "GatewaySubnet" {
err = resourceArmSubnetRetryDeleteGatewaySubnet(subnetClient, name, vnetName, resGroup)
}

return err
}

func resourceArmSubnetRetryDeleteGatewaySubnet(subnetClient network.SubnetsClient, name string, vnetName string, resGroup string) error {
stateConf := &resource.StateChangeConf{
Pending: []string{"Deleting", "Failed"},
Target: []string{"NotFound"},
Refresh: func() (interface{}, string, error) {
resp, err := subnetClient.Get(resGroup, vnetName, name, "")

if err != nil {
if responseWasNotFound(resp.Response) {
return resp, "NotFound", nil
}

return nil, "", fmt.Errorf("Error issuing read request when retrying to delete Gateway Subnet %s/%s (resource group %s): %+v", vnetName, name, resGroup, err)
}

// Retry deletion of gateway subnet if provisioning state is failed
if *resp.SubnetPropertiesFormat.ProvisioningState == "Failed" {
log.Printf("[DEBUG] Retry deleting Gateway Subnet %s/%s after failed provisioning state.", vnetName, name)
subnetClient.Delete(resGroup, vnetName, name, make(chan struct{}))
}

return resp, *resp.SubnetPropertiesFormat.ProvisioningState, nil
},
PollInterval: 30 * time.Second,
Timeout: 15 * time.Minute,
}
if _, err := stateConf.WaitForState(); err != nil {
return fmt.Errorf("Error waiting for Gateway Subnet %s/%s to be removed: %s", vnetName, name, err)
}

return nil
}
5 changes: 3 additions & 2 deletions azurerm/resource_arm_virtual_network_gateway.go
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func resourceArmVirtualNetworkGateway() *schema.Resource {
@@ -274,7 +275,7 @@ func resourceArmVirtualNetworkGatewayRead(d *schema.ResourceData, meta interface

resp, err := client.Get(resGroup, name)
if err != nil {
if responseWasNotFound(resp.Response) {
if utils.ResponseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
@@ -365,7 +366,7 @@ func virtualNetworkGatewayStateRefreshFunc(client *ArmClient, resourceGroupName
return func() (interface{}, string, error) {
resp, err := client.vnetGatewayClient.Get(resourceGroupName, virtualNetworkGateway)
if err != nil {
if withNotFound && responseWasNotFound(resp.Response) {
if withNotFound && utils.ResponseWasNotFound(resp.Response) {
return resp, "NotFound", nil
}
return nil, "", fmt.Errorf("Error making Read request on AzureRM Virtual Network Gateway %s: %+v", virtualNetworkGateway, err)
5 changes: 3 additions & 2 deletions azurerm/resource_arm_virtual_network_gateway_connection.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
"log"
"time"
)
@@ -163,7 +164,7 @@ func resourceArmVirtualNetworkGatewayConnectionRead(d *schema.ResourceData, meta

resp, err := vnetGatewayConnectionsClient.Get(resGroup, name)
if err != nil {
if responseWasNotFound(resp.Response) {
if utils.ResponseWasNotFound(resp.Response) {
d.SetId("")
return nil
}
@@ -246,7 +247,7 @@ func virtualNetworkGatewayConnectionStateRefreshFunc(client *ArmClient, resource
return func() (interface{}, string, error) {
resp, err := client.vnetGatewayConnectionsClient.Get(resourceGroupName, virtualNetworkGatewayConnection)
if err != nil {
if withNotFound && responseWasNotFound(resp.Response) {
if withNotFound && utils.ResponseWasNotFound(resp.Response) {
return resp, "NotFound", nil
}
return nil, "", fmt.Errorf("Error making Read request on AzureRM Virtual Network Gateway Connection %s: %+v", virtualNetworkGatewayConnection, err)
42 changes: 37 additions & 5 deletions azurerm/validators.go
Original file line number Diff line number Diff line change
@@ -5,18 +5,40 @@ import (
"regexp"
"time"

"github.com/Azure/go-autorest/autorest/date"
"github.com/hashicorp/terraform/helper/schema"
"github.com/satori/uuid"
)

func evaluateSchemaValidateFunc(i interface{}, k string, validateFunc schema.SchemaValidateFunc) (bool, error) {
_, es := validateFunc(i, k)
func validateRFC3339Date(v interface{}, k string) (ws []string, errors []error) {
dateString := v.(string)

if len(es) > 0 {
return false, es[0]
if _, err := date.ParseTime(time.RFC3339, dateString); err != nil {
errors = append(errors, fmt.Errorf("%q is an invalid RFC3339 date: %+v", k, err))
}

return true, nil
return
}

// validateIntInSlice returns a SchemaValidateFunc which tests if the provided value
// is of type int and matches the value of an element in the valid slice
func validateIntInSlice(valid []int) schema.SchemaValidateFunc {
return func(i interface{}, k string) (s []string, es []error) {
v, ok := i.(int)
if !ok {
es = append(es, fmt.Errorf("expected type of %s to be int", k))
return
}

for _, str := range valid {
if v == str {
return
}
}

es = append(es, fmt.Errorf("expected %q to be one of %v, got %v", k, valid, v))
return
}
}

func validateUUID(v interface{}, k string) (ws []string, errors []error) {
@@ -41,3 +63,13 @@ func validateDBAccountName(v interface{}, k string) (ws []string, errors []error

return
}

func evaluateSchemaValidateFunc(i interface{}, k string, validateFunc schema.SchemaValidateFunc) (bool, error) {
_, es := validateFunc(i, k)

if len(es) > 0 {
return false, es[0]
}

return true, nil
}
You are viewing a condensed version of this merge commit. You can view the full changes here.