diff --git a/azurerm/import_arm_virtual_network_gateway_connection_test.go b/azurerm/import_arm_virtual_network_gateway_connection_test.go deleted file mode 100644 index 074004b12f36..000000000000 --- a/azurerm/import_arm_virtual_network_gateway_connection_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package azurerm - -import ( - "testing" - - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" -) - -func TestAccAzureRMVirtualNetworkGatewayConnection_importSiteToSite(t *testing.T) { - resourceName := "azurerm_virtual_network_gateway_connection.test" - - ri := acctest.RandInt() - config := testAccAzureRMVirtualNetworkGatewayConnection_sitetosite(ri, testLocation()) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMVirtualNetworkGatewayConnectionDestroy, - Steps: []resource.TestStep{ - { - Config: config, - }, - - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/azurerm/resource_arm_virtual_machine_extension.go b/azurerm/resource_arm_virtual_machine_extension.go index b153743da3dd..4f5ea06a30d0 100644 --- a/azurerm/resource_arm_virtual_machine_extension.go +++ b/azurerm/resource_arm_virtual_machine_extension.go @@ -188,9 +188,6 @@ func resourceArmVirtualMachineExtensionsRead(d *schema.ResourceData, meta interf } } - if resp.VirtualMachineExtensionProperties.Settings != nil { - } - flattenAndSetTags(d, resp.Tags) return nil diff --git a/azurerm/resource_arm_virtual_network_gateway_connection.go b/azurerm/resource_arm_virtual_network_gateway_connection.go index 1d2e92b449b0..663ab380d3a4 100644 --- a/azurerm/resource_arm_virtual_network_gateway_connection.go +++ b/azurerm/resource_arm_virtual_network_gateway_connection.go @@ -7,6 +7,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) @@ -16,15 +18,17 @@ func resourceArmVirtualNetworkGatewayConnection() *schema.Resource { Read: resourceArmVirtualNetworkGatewayConnectionRead, Update: resourceArmVirtualNetworkGatewayConnectionCreateUpdate, Delete: resourceArmVirtualNetworkGatewayConnectionDelete, + Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, Schema: map[string]*schema.Schema{ "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.NoZeroValues, }, "resource_group_name": resourceGroupNameSchema(), @@ -40,36 +44,41 @@ func resourceArmVirtualNetworkGatewayConnection() *schema.Resource { string(network.IPsec), string(network.Vnet2Vnet), }, true), - DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + DiffSuppressFunc: suppress.CaseDifference, }, "virtual_network_gateway_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateResourceID, }, "authorization_key": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, + Type: schema.TypeString, + Optional: true, + Sensitive: true, + ValidateFunc: validation.NoZeroValues, }, "express_route_circuit_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: azure.ValidateResourceIDOrEmpty, }, "peer_virtual_network_gateway_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: azure.ValidateResourceIDOrEmpty, }, "local_network_gateway_id": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + ValidateFunc: azure.ValidateResourceIDOrEmpty, }, "enable_bgp": { @@ -85,9 +94,10 @@ func resourceArmVirtualNetworkGatewayConnection() *schema.Resource { }, "routing_weight": { - Type: schema.TypeInt, - Optional: true, - Computed: true, + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validation.IntBetween(1, 1000), }, "shared_key": { @@ -105,7 +115,7 @@ func resourceArmVirtualNetworkGatewayConnection() *schema.Resource { "dh_group": { Type: schema.TypeString, Required: true, - DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.StringInSlice([]string{ string(network.DHGroup1), string(network.DHGroup14), @@ -117,10 +127,11 @@ func resourceArmVirtualNetworkGatewayConnection() *schema.Resource { string(network.None), }, true), }, + "ike_encryption": { Type: schema.TypeString, Required: true, - DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.StringInSlice([]string{ string(network.AES128), string(network.AES192), @@ -129,10 +140,11 @@ func resourceArmVirtualNetworkGatewayConnection() *schema.Resource { string(network.DES3), }, true), }, + "ike_integrity": { Type: schema.TypeString, Required: true, - DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.StringInSlice([]string{ string(network.IkeIntegrityGCMAES128), string(network.IkeIntegrityGCMAES256), @@ -142,10 +154,11 @@ func resourceArmVirtualNetworkGatewayConnection() *schema.Resource { string(network.IkeIntegritySHA384), }, true), }, + "ipsec_encryption": { Type: schema.TypeString, Required: true, - DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.StringInSlice([]string{ string(network.IpsecEncryptionAES128), string(network.IpsecEncryptionAES192), @@ -158,10 +171,11 @@ func resourceArmVirtualNetworkGatewayConnection() *schema.Resource { string(network.IpsecEncryptionNone), }, true), }, + "ipsec_integrity": { Type: schema.TypeString, Required: true, - DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.StringInSlice([]string{ string(network.IpsecIntegrityGCMAES128), string(network.IpsecIntegrityGCMAES192), @@ -171,10 +185,11 @@ func resourceArmVirtualNetworkGatewayConnection() *schema.Resource { string(network.IpsecIntegritySHA256), }, true), }, + "pfs_group": { Type: schema.TypeString, Required: true, - DiffSuppressFunc: ignoreCaseDiffSuppressFunc, + DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.StringInSlice([]string{ string(network.PfsGroupECP256), string(network.PfsGroupECP384), @@ -185,12 +200,14 @@ func resourceArmVirtualNetworkGatewayConnection() *schema.Resource { string(network.PfsGroupPFS24), }, true), }, + "sa_datasize": { Type: schema.TypeInt, Optional: true, Computed: true, ValidateFunc: validation.IntAtLeast(1024), }, + "sa_lifetime": { Type: schema.TypeInt, Optional: true, @@ -234,8 +251,7 @@ func resourceArmVirtualNetworkGatewayConnectionCreateUpdate(d *schema.ResourceDa return fmt.Errorf("Error Creating/Updating AzureRM Virtual Network Gateway Connection %q (Resource Group %q): %+v", name, resGroup, err) } - err = future.WaitForCompletionRef(ctx, client.Client) - if err != nil { + if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { return fmt.Errorf("Error waiting for completion of Virtual Network Gateway Connection %q (Resource Group %q): %+v", name, resGroup, err) } @@ -345,8 +361,7 @@ func resourceArmVirtualNetworkGatewayConnectionDelete(d *schema.ResourceData, me return fmt.Errorf("Error Deleting Virtual Network Gateway Connection %q (Resource Group %q): %+v", name, resGroup, err) } - err = future.WaitForCompletionRef(ctx, client.Client) - if err != nil { + if err := future.WaitForCompletionRef(ctx, client.Client); err != nil { return fmt.Errorf("Error waiting for deletion of Virtual Network Gateway Connection %q (Resource Group %q): %+v", name, resGroup, err) } @@ -357,11 +372,14 @@ func getArmVirtualNetworkGatewayConnectionProperties(d *schema.ResourceData) (*n connectionType := network.VirtualNetworkGatewayConnectionType(d.Get("type").(string)) props := &network.VirtualNetworkGatewayConnectionPropertiesFormat{ - ConnectionType: connectionType, + ConnectionType: connectionType, + EnableBgp: utils.Bool(d.Get("enable_bgp").(bool)), + UsePolicyBasedTrafficSelectors: utils.Bool(d.Get("use_policy_based_traffic_selectors").(bool)), } if v, ok := d.GetOk("virtual_network_gateway_id"); ok { virtualNetworkGatewayId := v.(string) + _, name, err := resourceGroupAndVirtualNetworkGatewayFromId(virtualNetworkGatewayId) if err != nil { return nil, fmt.Errorf("Error Getting VirtualNetworkGateway Name and Group:: %+v", err) @@ -420,10 +438,6 @@ func getArmVirtualNetworkGatewayConnectionProperties(d *schema.ResourceData) (*n } } - props.EnableBgp = utils.Bool(d.Get("enable_bgp").(bool)) - - props.UsePolicyBasedTrafficSelectors = utils.Bool(d.Get("use_policy_based_traffic_selectors").(bool)) - if v, ok := d.GetOk("routing_weight"); ok { routingWeight := int32(v.(int)) props.RoutingWeight = &routingWeight @@ -434,8 +448,7 @@ func getArmVirtualNetworkGatewayConnectionProperties(d *schema.ResourceData) (*n } if v, ok := d.GetOk("ipsec_policy"); ok { - ipsecPolicies := v.([]interface{}) - props.IpsecPolicies = expandArmVirtualNetworkGatewayConnectionIpsecPolicies(ipsecPolicies) + props.IpsecPolicies = expandArmVirtualNetworkGatewayConnectionIpsecPolicies(v.([]interface{})) } if props.ConnectionType == network.ExpressRoute { diff --git a/azurerm/resource_arm_virtual_network_gateway_connection_test.go b/azurerm/resource_arm_virtual_network_gateway_connection_test.go index 9d9fc8bb0a2f..d58ac0307e19 100644 --- a/azurerm/resource_arm_virtual_network_gateway_connection_test.go +++ b/azurerm/resource_arm_virtual_network_gateway_connection_test.go @@ -11,6 +11,7 @@ import ( ) func TestAccAzureRMVirtualNetworkGatewayConnection_sitetosite(t *testing.T) { + resourceName := "azurerm_virtual_network_gateway_connection.test" ri := acctest.RandInt() config := testAccAzureRMVirtualNetworkGatewayConnection_sitetosite(ri, testLocation()) @@ -25,6 +26,11 @@ func TestAccAzureRMVirtualNetworkGatewayConnection_sitetosite(t *testing.T) { testCheckAzureRMVirtualNetworkGatewayConnectionExists("azurerm_virtual_network_gateway_connection.test"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/website/docs/r/virtual_network_gateway_connection.html.markdown b/website/docs/r/virtual_network_gateway_connection.html.markdown index 0407a8c0de91..bea46f86c06c 100644 --- a/website/docs/r/virtual_network_gateway_connection.html.markdown +++ b/website/docs/r/virtual_network_gateway_connection.html.markdown @@ -19,66 +19,66 @@ and an on-premises VPN device and network. ```hcl resource "azurerm_resource_group" "test" { - name = "test" + name = "test" location = "West US" } resource "azurerm_virtual_network" "test" { - name = "test" - location = "${azurerm_resource_group.test.location}" + name = "test" + location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" - address_space = ["10.0.0.0/16"] + address_space = ["10.0.0.0/16"] } resource "azurerm_subnet" "test" { - name = "GatewaySubnet" - resource_group_name = "${azurerm_resource_group.test.name}" + name = "GatewaySubnet" + resource_group_name = "${azurerm_resource_group.test.name}" virtual_network_name = "${azurerm_virtual_network.test.name}" - address_prefix = "10.0.1.0/24" + address_prefix = "10.0.1.0/24" } resource "azurerm_local_network_gateway" "onpremise" { - name = "onpremise" - location = "${azurerm_resource_group.test.location}" + name = "onpremise" + location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" - gateway_address = "168.62.225.23" - address_space = ["10.1.1.0/24"] + gateway_address = "168.62.225.23" + address_space = ["10.1.1.0/24"] } resource "azurerm_public_ip" "test" { - name = "test" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" + name = "test" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" public_ip_address_allocation = "Dynamic" } resource "azurerm_virtual_network_gateway" "test" { - name = "test" - location = "${azurerm_resource_group.test.location}" + name = "test" + location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" - type = "Vpn" + type = "Vpn" vpn_type = "RouteBased" active_active = false - enable_bgp = false - sku = "Basic" + enable_bgp = false + sku = "Basic" ip_configuration { - public_ip_address_id = "${azurerm_public_ip.test.id}" + public_ip_address_id = "${azurerm_public_ip.test.id}" private_ip_address_allocation = "Dynamic" - subnet_id = "${azurerm_subnet.test.id}" + subnet_id = "${azurerm_subnet.test.id}" } } resource "azurerm_virtual_network_gateway_connection" "onpremise" { - name = "onpremise" - location = "${azurerm_resource_group.test.location}" + name = "onpremise" + location = "${azurerm_resource_group.test.location}" resource_group_name = "${azurerm_resource_group.test.name}" - type = "IPsec" + type = "IPsec" virtual_network_gateway_id = "${azurerm_virtual_network_gateway.test.id}" - local_network_gateway_id = "${azurerm_local_network_gateway.onpremise.id}" + local_network_gateway_id = "${azurerm_local_network_gateway.onpremise.id}" shared_key = "4-v3ry-53cr37-1p53c-5h4r3d-k3y" } @@ -91,108 +91,108 @@ in different locations/regions. ```hcl resource "azurerm_resource_group" "us" { - name = "us" + name = "us" location = "East US" } resource "azurerm_virtual_network" "us" { - name = "us" - location = "${azurerm_resource_group.us.location}" + name = "us" + location = "${azurerm_resource_group.us.location}" resource_group_name = "${azurerm_resource_group.us.name}" - address_space = ["10.0.0.0/16"] + address_space = ["10.0.0.0/16"] } resource "azurerm_subnet" "us_gateway" { - name = "GatewaySubnet" - resource_group_name = "${azurerm_resource_group.us.name}" + name = "GatewaySubnet" + resource_group_name = "${azurerm_resource_group.us.name}" virtual_network_name = "${azurerm_virtual_network.us.name}" - address_prefix = "10.0.1.0/24" + address_prefix = "10.0.1.0/24" } resource "azurerm_public_ip" "us" { - name = "us" - location = "${azurerm_resource_group.us.location}" - resource_group_name = "${azurerm_resource_group.us.name}" + name = "us" + location = "${azurerm_resource_group.us.location}" + resource_group_name = "${azurerm_resource_group.us.name}" public_ip_address_allocation = "Dynamic" } resource "azurerm_virtual_network_gateway" "us" { - name = "us-gateway" - location = "${azurerm_resource_group.us.location}" + name = "us-gateway" + location = "${azurerm_resource_group.us.location}" resource_group_name = "${azurerm_resource_group.us.name}" - type = "Vpn" + type = "Vpn" vpn_type = "RouteBased" - sku = "Basic" + sku = "Basic" ip_configuration { - public_ip_address_id = "${azurerm_public_ip.us.id}" + public_ip_address_id = "${azurerm_public_ip.us.id}" private_ip_address_allocation = "Dynamic" - subnet_id = "${azurerm_subnet.us_gateway.id}" + subnet_id = "${azurerm_subnet.us_gateway.id}" } } resource "azurerm_resource_group" "europe" { - name = "europe" + name = "europe" location = "West Europe" } resource "azurerm_virtual_network" "europe" { - name = "europe" - location = "${azurerm_resource_group.europe.location}" + name = "europe" + location = "${azurerm_resource_group.europe.location}" resource_group_name = "${azurerm_resource_group.europe.name}" - address_space = ["10.1.0.0/16"] + address_space = ["10.1.0.0/16"] } resource "azurerm_subnet" "europe_gateway" { - name = "GatewaySubnet" - resource_group_name = "${azurerm_resource_group.europe.name}" + name = "GatewaySubnet" + resource_group_name = "${azurerm_resource_group.europe.name}" virtual_network_name = "${azurerm_virtual_network.europe.name}" - address_prefix = "10.1.1.0/24" + address_prefix = "10.1.1.0/24" } resource "azurerm_public_ip" "europe" { - name = "europe" - location = "${azurerm_resource_group.europe.location}" - resource_group_name = "${azurerm_resource_group.europe.name}" + name = "europe" + location = "${azurerm_resource_group.europe.location}" + resource_group_name = "${azurerm_resource_group.europe.name}" public_ip_address_allocation = "Dynamic" } resource "azurerm_virtual_network_gateway" "europe" { - name = "europe-gateway" - location = "${azurerm_resource_group.europe.location}" + name = "europe-gateway" + location = "${azurerm_resource_group.europe.location}" resource_group_name = "${azurerm_resource_group.europe.name}" - type = "Vpn" + type = "Vpn" vpn_type = "RouteBased" - sku = "Basic" + sku = "Basic" ip_configuration { - public_ip_address_id = "${azurerm_public_ip.europe.id}" + public_ip_address_id = "${azurerm_public_ip.europe.id}" private_ip_address_allocation = "Dynamic" - subnet_id = "${azurerm_subnet.europe_gateway.id}" + subnet_id = "${azurerm_subnet.europe_gateway.id}" } } resource "azurerm_virtual_network_gateway_connection" "us_to_europe" { - name = "us-to-europe" - location = "${azurerm_resource_group.us.location}" + name = "us-to-europe" + location = "${azurerm_resource_group.us.location}" resource_group_name = "${azurerm_resource_group.us.name}" - type = "Vnet2Vnet" - virtual_network_gateway_id = "${azurerm_virtual_network_gateway.us.id}" + type = "Vnet2Vnet" + virtual_network_gateway_id = "${azurerm_virtual_network_gateway.us.id}" peer_virtual_network_gateway_id = "${azurerm_virtual_network_gateway.europe.id}" shared_key = "4-v3ry-53cr37-1p53c-5h4r3d-k3y" } resource "azurerm_virtual_network_gateway_connection" "europe_to_us" { - name = "europe-to-us" - location = "${azurerm_resource_group.europe.location}" + name = "europe-to-us" + location = "${azurerm_resource_group.europe.location}" resource_group_name = "${azurerm_resource_group.europe.name}" - type = "Vnet2Vnet" - virtual_network_gateway_id = "${azurerm_virtual_network_gateway.europe.id}" + type = "Vnet2Vnet" + virtual_network_gateway_id = "${azurerm_virtual_network_gateway.europe.id}" peer_virtual_network_gateway_id = "${azurerm_virtual_network_gateway.us.id}" shared_key = "4-v3ry-53cr37-1p53c-5h4r3d-k3y"