-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
b19fad1
commit 048bce9
Showing
15 changed files
with
493 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
14 changes: 14 additions & 0 deletions
14
azure-test/tests/azure_virtual_network_gateway/posttest-variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
resource "null_resource" "delay" { | ||
provisioner "local-exec" { | ||
command = "sleep 3600" | ||
} | ||
} | ||
|
||
resource "null_resource" "named_test_resource" { | ||
depends_on = [ | ||
null_resource.delay | ||
] | ||
provisioner "local-exec" { | ||
command = "az network vnet-gateway delete -g {{ resourceName }} -n {{ resourceName }}" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
azure-test/tests/azure_virtual_network_gateway/test-get-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"enable_bgp": false, | ||
"id": "{{ output.resource_id.value }}", | ||
"name": "{{ resourceName }}", | ||
"region": "{{ output.region.value }}", | ||
"resource_group": "{{ resourceName }}", | ||
"type": "Microsoft.Network/virtualNetworkGateways" | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
azure-test/tests/azure_virtual_network_gateway/test-get-query.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select name, id, region, type, enable_bgp, resource_group | ||
from azure.azure_virtual_network_gateway | ||
where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; |
6 changes: 6 additions & 0 deletions
6
azure-test/tests/azure_virtual_network_gateway/test-list-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"id": "{{ output.resource_id.value }}", | ||
"name": "{{ resourceName }}" | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
azure-test/tests/azure_virtual_network_gateway/test-list-query.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select id, name | ||
from azure.azure_virtual_network_gateway | ||
where name = '{{ resourceName }}'; |
1 change: 1 addition & 0 deletions
1
azure-test/tests/azure_virtual_network_gateway/test-not-found-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
null |
3 changes: 3 additions & 0 deletions
3
azure-test/tests/azure_virtual_network_gateway/test-not-found-query.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select name, akas, title | ||
from azure.azure_virtual_network_gateway | ||
where name = 'dummy-{{ resourceName }}' and resource_group = '{{ resourceName }}'; |
10 changes: 10 additions & 0 deletions
10
azure-test/tests/azure_virtual_network_gateway/test-turbot-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"akas": [ | ||
"{{ output.resource_aka.value }}", | ||
"{{ output.resource_aka_lower.value }}" | ||
], | ||
"name": "{{ resourceName }}", | ||
"title": "{{ resourceName }}" | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
azure-test/tests/azure_virtual_network_gateway/test-turbot-query.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
select name, akas, title | ||
from azure.azure_virtual_network_gateway | ||
where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
104 changes: 104 additions & 0 deletions
104
azure-test/tests/azure_virtual_network_gateway/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
variable "resource_name" { | ||
type = string | ||
default = "turbot-test-20200125-create-update" | ||
description = "Name of the resource used throughout the test." | ||
} | ||
|
||
variable "azure_environment" { | ||
type = string | ||
default = "public" | ||
description = "Azure environment used for the test." | ||
} | ||
|
||
variable "azure_subscription" { | ||
type = string | ||
default = "3510ae4d-530b-497d-8f30-53b9616fc6c1" | ||
description = "Azure subscription used for the test." | ||
} | ||
|
||
provider "azurerm" { | ||
# Cannot be passed as a variable | ||
version = "=1.36.0" | ||
environment = var.azure_environment | ||
subscription_id = var.azure_subscription | ||
} | ||
|
||
data "azurerm_client_config" "current" {} | ||
|
||
data "null_data_source" "resource" { | ||
inputs = { | ||
scope = "azure:///subscriptions/${data.azurerm_client_config.current.subscription_id}" | ||
} | ||
} | ||
|
||
resource "azurerm_resource_group" "named_test_resource" { | ||
name = var.resource_name | ||
location = "East US" | ||
} | ||
|
||
resource "azurerm_virtual_network" "named_test_resource" { | ||
name = var.resource_name | ||
address_space = ["10.0.0.0/16"] | ||
location = azurerm_resource_group.named_test_resource.location | ||
resource_group_name = azurerm_resource_group.named_test_resource.name | ||
} | ||
|
||
resource "azurerm_subnet" "named_test_resource" { | ||
name = "GatewaySubnet" | ||
resource_group_name = azurerm_resource_group.named_test_resource.name | ||
virtual_network_name = azurerm_virtual_network.named_test_resource.name | ||
address_prefix = "10.0.1.0/24" | ||
} | ||
|
||
resource "azurerm_public_ip" "named_test_resource" { | ||
depends_on = [azurerm_subnet.named_test_resource] | ||
name = var.resource_name | ||
location = azurerm_resource_group.named_test_resource.location | ||
resource_group_name = azurerm_resource_group.named_test_resource.name | ||
allocation_method = "Dynamic" | ||
} | ||
|
||
locals { | ||
path = "${path.cwd}/info.json" | ||
} | ||
|
||
resource "null_resource" "named_test_resource" { | ||
depends_on = [azurerm_public_ip.named_test_resource] | ||
provisioner "local-exec" { | ||
command = "az network vnet-gateway create --gateway-type Vpn --location ${azurerm_resource_group.named_test_resource.location} --name ${var.resource_name} --no-wait --public-ip-addresses ${var.resource_name} --resource-group ${var.resource_name} --vnet ${var.resource_name}" | ||
} | ||
provisioner "local-exec" { | ||
command = "az network vnet-gateway show -g ${var.resource_name} -n ${var.resource_name} > ${local.path}" | ||
} | ||
} | ||
|
||
data "local_file" "input" { | ||
depends_on = [null_resource.named_test_resource] | ||
filename = local.path | ||
} | ||
|
||
output "resource_aka" { | ||
depends_on = [null_resource.named_test_resource] | ||
value = "azure://${jsondecode(data.local_file.input.content).id}" | ||
} | ||
|
||
output "resource_aka_lower" { | ||
depends_on = [null_resource.named_test_resource] | ||
value = "azure://${lower(jsondecode(data.local_file.input.content).id)}" | ||
} | ||
|
||
output "resource_name" { | ||
value = var.resource_name | ||
} | ||
|
||
output "resource_id" { | ||
value = jsondecode(data.local_file.input.content).id | ||
} | ||
|
||
output "subscription_id" { | ||
value = var.azure_subscription | ||
} | ||
|
||
output "region" { | ||
value = azurerm_resource_group.named_test_resource.location | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.