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 field for virtual network gateway and virtual network gateway connection #9330

Merged
merged 24 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a463cdc
add fields
chenjianfei2017 Oct 26, 2020
a1d14b9
add fields for virtual network gateway
chenjianfei2017 Nov 2, 2020
f7ded89
Merge branch 'master' of https://github.com/terraform-providers/terra…
chenjianfei2017 Nov 2, 2020
a34bf70
format
chenjianfei2017 Nov 2, 2020
9149dcc
fmt
chenjianfei2017 Nov 2, 2020
85d86ac
fmt
chenjianfei2017 Nov 2, 2020
9f98fb1
Merge branch 'netwoek' into conn
chenjianfei2017 Nov 2, 2020
4a1788c
Merge branch 'master' of https://github.com/terraform-providers/terra…
chenjianfei2017 Nov 10, 2020
a9698f1
Update website/docs/r/virtual_network_gateway.html.markdown
chenjianfei2017 Nov 11, 2020
81f5e78
Update website/docs/r/virtual_network_gateway.html.markdown
chenjianfei2017 Nov 11, 2020
678d4bb
Update website/docs/d/virtual_network_gateway_connection.html.markdown
chenjianfei2017 Nov 11, 2020
b3a06b3
Update website/docs/d/virtual_network_gateway_connection.html.markdown
chenjianfei2017 Nov 11, 2020
34baaec
Update website/docs/d/virtual_network_gateway.html.markdown
chenjianfei2017 Nov 11, 2020
636b73c
Update azurerm/internal/services/network/virtual_network_gateway_reso…
chenjianfei2017 Nov 11, 2020
a1aafac
refine network gateway field coverage
chenjianfei2017 Nov 11, 2020
abf3c1e
fmt
chenjianfei2017 Nov 13, 2020
37f0925
change fmt
chenjianfei2017 Nov 13, 2020
4133fbd
change fmt
chenjianfei2017 Nov 13, 2020
218e020
Merge branch 'master' of https://github.com/terraform-providers/terra…
chenjianfei2017 Nov 16, 2020
fae11d0
Update azurerm/internal/services/network/virtual_network_gateway_conn…
chenjianfei2017 Nov 19, 2020
2a76130
Update azurerm/internal/services/network/virtual_network_gateway_conn…
chenjianfei2017 Nov 19, 2020
50b5c12
Update website/docs/d/virtual_network_gateway.html.markdown
chenjianfei2017 Nov 19, 2020
64e6c8e
fmt refine
chenjianfei2017 Nov 19, 2020
4598362
refine fmt
chenjianfei2017 Nov 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,32 @@ func TestAccAzureRMVirtualNetworkGatewayConnection_updatingSharedKey(t *testing.
})
}

func TestAccAzureRMVirtualNetworkGatewayConnection_useLocalAzureIpAddressEnabled(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_virtual_network_gateway_connection", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMVirtualNetworkGatewayConnectionDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMVirtualNetworkGatewayConnection_useLocalAzureIpAddressEnabled(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualNetworkGatewayConnectionExists(data.ResourceName),
),
},
data.ImportStep(),
{
Config: testAccAzureRMVirtualNetworkGatewayConnection_useLocalAzureIpAddressEnabledUpdate(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualNetworkGatewayConnectionExists(data.ResourceName),
),
},
data.ImportStep(),
},
})
}

func testCheckAzureRMVirtualNetworkGatewayConnectionExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := acceptance.AzureProvider.Meta().(*clients.Client).Network.VnetGatewayConnectionsClient
Expand Down Expand Up @@ -787,3 +813,143 @@ resource "azurerm_virtual_network_gateway_connection" "test" {
}
`, data.RandomInteger, data.Locations.Primary)
}

func testAccAzureRMVirtualNetworkGatewayConnection_useLocalAzureIpAddressEnabled(data acceptance.TestData) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_virtual_network" "test" {
name = "acctestvn-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
address_space = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "test" {
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"
}

resource "azurerm_public_ip" "test" {
name = "acctestip-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
allocation_method = "Static"
sku = "Standard"
}

resource "azurerm_virtual_network_gateway" "test" {
name = "acctestgw-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name

type = "Vpn"
vpn_type = "RouteBased"
sku = "VpnGw1"
private_ip_address_enabled = true
ip_configuration {
name = "vnetGatewayConfig"
public_ip_address_id = azurerm_public_ip.test.id
private_ip_address_allocation = "Dynamic"
subnet_id = azurerm_subnet.test.id
}
}

resource "azurerm_local_network_gateway" "test" {
name = "acctestlgw-%d"
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"]
}

resource "azurerm_virtual_network_gateway_connection" "test" {
name = "acctestgwc-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
local_azure_ip_address_enabled = true

type = "IPsec"
virtual_network_gateway_id = azurerm_virtual_network_gateway.test.id
local_network_gateway_id = azurerm_local_network_gateway.test.id

shared_key = "4-v3ry-53cr37-1p53c-5h4r3d-k3y"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMVirtualNetworkGatewayConnection_useLocalAzureIpAddressEnabledUpdate(data acceptance.TestData) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_virtual_network" "test" {
name = "acctestvn-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
address_space = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "test" {
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"
}

resource "azurerm_public_ip" "test" {
name = "acctestip-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
allocation_method = "Static"
sku = "Standard"
}

resource "azurerm_virtual_network_gateway" "test" {
name = "acctestgw-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name

type = "Vpn"
vpn_type = "RouteBased"
sku = "VpnGw1"
ip_configuration {
name = "vnetGatewayConfig"
public_ip_address_id = azurerm_public_ip.test.id
private_ip_address_allocation = "Dynamic"
subnet_id = azurerm_subnet.test.id
}
}

resource "azurerm_local_network_gateway" "test" {
name = "acctestlgw-%d"
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"]
}

resource "azurerm_virtual_network_gateway_connection" "test" {
name = "acctestgwc-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
local_azure_ip_address_enabled = false

type = "IPsec"
virtual_network_gateway_id = azurerm_virtual_network_gateway.test.id
local_network_gateway_id = azurerm_local_network_gateway.test.id
dpd_timeout_seconds = 30

shared_key = "4-v3ry-53cr37-1p53c-5h4r3d-k3y"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,32 @@ func TestAccAzureRMVirtualNetworkGateway_expressRoute(t *testing.T) {
})
}

func TestAccAzureRMVirtualNetworkGateway_privateIpAddressEnabled(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_virtual_network_gateway", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMVirtualNetworkGatewayDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMVirtualNetworkGateway_privateIpAddressEnabled(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualNetworkGatewayExists("azurerm_virtual_network_gateway.test"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMVirtualNetworkGateway_privateIpAddressEnabledUpdate(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualNetworkGatewayExists("azurerm_virtual_network_gateway.test"),
),
},
data.ImportStep(),
},
})
}

func testCheckAzureRMVirtualNetworkGatewayExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := acceptance.AzureProvider.Meta().(*clients.Client).Network.VnetGatewayClient
Expand Down Expand Up @@ -963,3 +989,113 @@ resource "azurerm_virtual_network_gateway" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, generation)
}

func testAccAzureRMVirtualNetworkGateway_privateIpAddressEnabled(data acceptance.TestData) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_virtual_network" "test" {
name = "acctestvn-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
address_space = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "test" {
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"
}

resource "azurerm_public_ip" "test" {
name = "acctest-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
allocation_method = "Static"
sku = "Standard"
}

resource "azurerm_virtual_network_gateway" "test" {
name = "acctest-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name

type = "Vpn"
vpn_type = "RouteBased"
sku = "VpnGw1"
private_ip_address_enabled = true

custom_route {
address_prefixes = [
"101.168.0.6/32"
]
}

ip_configuration {
name = "vnetGatewayConfig"
public_ip_address_id = azurerm_public_ip.test.id
private_ip_address_allocation = "Dynamic"
subnet_id = azurerm_subnet.test.id
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMVirtualNetworkGateway_privateIpAddressEnabledUpdate(data acceptance.TestData) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_virtual_network" "test" {
name = "acctestvn-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
address_space = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "test" {
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"
}

resource "azurerm_public_ip" "test" {
name = "acctest-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
allocation_method = "Static"
sku = "Standard"
}

resource "azurerm_virtual_network_gateway" "test" {
name = "acctest-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name

type = "Vpn"
vpn_type = "RouteBased"
sku = "VpnGw1"
private_ip_address_enabled = false

custom_route {
address_prefixes = [
"101.168.0.6/32"
]
}

ip_configuration {
name = "vnetGatewayConfig"
public_ip_address_id = azurerm_public_ip.test.id
private_ip_address_allocation = "Dynamic"
subnet_id = azurerm_subnet.test.id
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func dataSourceArmVirtualNetworkGatewayConnection() *schema.Resource {
Computed: true,
},

"dpd_timeout_seconds": {
Type: schema.TypeInt,
Computed: true,
},

"enable_bgp": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -89,6 +94,11 @@ func dataSourceArmVirtualNetworkGatewayConnection() *schema.Resource {
Computed: true,
},

"local_azure_ip_address_enabled": {
Type: schema.TypeBool,
Computed: true,
},

"local_network_gateway_id": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -233,6 +243,14 @@ func dataSourceArmVirtualNetworkGatewayConnectionRead(d *schema.ResourceData, me
d.Set("express_route_circuit_id", gwc.Peer.ID)
}

if gwc.DpdTimeoutSeconds != nil {
d.Set("dpd_timeout_seconds", gwc.DpdTimeoutSeconds)
}

if gwc.UseLocalAzureIPAddress != nil {
d.Set("local_azure_ip_address_enabled", gwc.UseLocalAzureIPAddress)
}

d.Set("resource_guid", gwc.ResourceGUID)

ipsecPoliciesSettingsFlat := flattenArmVirtualNetworkGatewayConnectionDataSourceIpsecPolicies(gwc.IpsecPolicies)
Expand Down
Loading