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 table azure_application_gateway. Closes #311 #316

Merged
merged 4 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Empty file.
10 changes: 10 additions & 0 deletions azure-test/tests/azure_application_gateway/test-get-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"id": "{{ output.resource_id.value }}",
"name": "{{ resourceName }}",
"region": "{{ output.region.value }}",
"resource_group": "{{ resourceName }}",
"subscription_id": "{{ output.subscription_id.value }}",
"type": "Microsoft.Network/applicationGateways"
}
]
3 changes: 3 additions & 0 deletions azure-test/tests/azure_application_gateway/test-get-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, id, type, region, resource_group, subscription_id
from azure.azure_application_gateway
where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}';
10 changes: 10 additions & 0 deletions azure-test/tests/azure_application_gateway/test-list-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"id": "{{ output.resource_id.value }}",
"name": "{{ resourceName }}",
"region": "{{ output.region.value }}",
"resource_group": "{{ resourceName }}",
"subscription_id": "{{ output.subscription_id.value }}",
"type": "Microsoft.Network/applicationGateways"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, id, type, region, resource_group, subscription_id
from azure.azure_application_gateway
where id = '{{ output.resource_id.value }}';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, id, type, region
from azure.azure_application_gateway
where name = 'dummy-test{{ resourceName }}' and resource_group = '{{ resourceName }}';
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 }}"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, akas, title
from azure.azure_application_gateway
where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}';
1 change: 1 addition & 0 deletions azure-test/tests/azure_application_gateway/variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
156 changes: 156 additions & 0 deletions azure-test/tests/azure_application_gateway/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
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 environment used for the test."
}

terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.75.0"
}
}
}

provider "azurerm" {
# Cannot be passed as a variable
features {}
environment = var.azure_environment
subscription_id = var.azure_subscription
}

resource "azurerm_resource_group" "named_test_resource" {
name = var.resource_name
location = "West Europe"
}

resource "azurerm_virtual_network" "named_test_resource" {
name = var.resource_name
resource_group_name = azurerm_resource_group.named_test_resource.name
location = azurerm_resource_group.named_test_resource.location
address_space = ["10.254.0.0/16"]
}

resource "azurerm_subnet" "frontend" {
name = var.resource_name
resource_group_name = azurerm_resource_group.named_test_resource.name
virtual_network_name = azurerm_virtual_network.named_test_resource.name
address_prefixes = ["10.254.0.0/24"]
}

resource "azurerm_subnet" "backend" {
name = var.resource_name
resource_group_name = azurerm_resource_group.named_test_resource.name
virtual_network_name = azurerm_virtual_network.named_test_resource.name
address_prefixes = ["10.254.2.0/24"]
}

resource "azurerm_public_ip" "named_test_resource" {
name = var.resource_name
resource_group_name = azurerm_resource_group.named_test_resource.name
location = azurerm_resource_group.named_test_resource.location
allocation_method = "Dynamic"
}

locals {
backend_address_pool_name = "${azurerm_virtual_network.named_test_resource.name}-beap"
frontend_port_name = "${azurerm_virtual_network.named_test_resource.name}-feport"
frontend_ip_configuration_name = "${azurerm_virtual_network.named_test_resource.name}-feip"
http_setting_name = "${azurerm_virtual_network.named_test_resource.name}-be-htst"
listener_name = "${azurerm_virtual_network.named_test_resource.name}-httplstn"
request_routing_rule_name = "${azurerm_virtual_network.named_test_resource.name}-rqrt"
redirect_configuration_name = "${azurerm_virtual_network.named_test_resource.name}-rdrcfg"
}

resource "azurerm_application_gateway" "named_test_resource" {
name = var.resource_name
resource_group_name = azurerm_resource_group.named_test_resource.name
location = azurerm_resource_group.named_test_resource.location

sku {
name = "Standard_Small"
tier = "Standard"
capacity = 2
}

gateway_ip_configuration {
name = var.resource_name
subnet_id = azurerm_subnet.frontend.id
}

frontend_port {
name = local.frontend_port_name
port = 80
}

frontend_ip_configuration {
name = local.frontend_ip_configuration_name
public_ip_address_id = azurerm_public_ip.named_test_resource.id
}

backend_address_pool {
name = local.backend_address_pool_name
}

backend_http_settings {
name = local.http_setting_name
cookie_based_affinity = "Disabled"
path = "/path1/"
port = 80
protocol = "Http"
request_timeout = 60
}

http_listener {
name = local.listener_name
frontend_ip_configuration_name = local.frontend_ip_configuration_name
frontend_port_name = local.frontend_port_name
protocol = "Http"
}

request_routing_rule {
name = local.request_routing_rule_name
rule_type = "Basic"
http_listener_name = local.listener_name
backend_address_pool_name = local.backend_address_pool_name
backend_http_settings_name = local.http_setting_name
}
}

output "region" {
value = azurerm_resource_group.named_test_resource.location
}

output "resource_aka" {
depends_on = [azurerm_application_gateway.named_test_resource]
value = "azure://${azurerm_application_gateway.named_test_resource.id}"
}

output "resource_aka_lower" {
value = "azure://${lower(azurerm_application_gateway.named_test_resource.id)}"
}

output "resource_name" {
value = var.resource_name
}

output "resource_id" {
value = azurerm_application_gateway.named_test_resource.id
}

output "subscription_id" {
value = var.azure_subscription
}
1 change: 1 addition & 0 deletions azure/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"azure_app_service_function_app": tableAzureAppServiceFunctionApp(ctx),
"azure_app_service_plan": tableAzureAppServicePlan(ctx),
"azure_app_service_web_app": tableAzureAppServiceWebApp(ctx),
"azure_application_gateway": tableAzureApplicationGateway(ctx),
"azure_application_security_group": tableAzureApplicationSecurityGroup(ctx),
"azure_batch_account": tableAzureBatchAccount(ctx),
"azure_compute_availability_set": tableAzureComputeAvailabilitySet(ctx),
Expand Down
Loading