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_postgresql_server. Closes #63 #64

Merged
merged 8 commits into from
Apr 7, 2021
Merged
Empty file.
23 changes: 23 additions & 0 deletions azure-test/tests/azure_postgresql_server/test-get-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"administrator_login": "psqladminun",
"backup_retention_days": 7,
"fully_qualified_domain_name": "{{ output.server_fqdn.value }}",
"geo_redundant_backup": "Disabled",
"id": "{{ output.resource_id.value }}",
"location": "{{ output.location.value }}",
"minimal_tls_version": "TLS1_2",
"name": "{{ resourceName }}",
"public_network_access": "Enabled",
"region": "{{ output.location.value }}",
"resource_group": "{{ resourceName }}",
"sku_family": "Gen5",
"sku_name": "B_Gen5_1",
"sku_size": "<null>",
"sku_tier": "Basic",
"ssl_enforcement": "Enabled",
"subscription_id": "{{ output.subscription_id.value }}",
"type": "Microsoft.DBforPostgreSQL/servers",
"version": "9.5"
}
]
3 changes: 3 additions & 0 deletions azure-test/tests/azure_postgresql_server/test-get-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, id, type, version, location, version, administrator_login, fully_qualified_domain_name, minimal_tls_version, public_network_access, sku_family, sku_name, sku_tier, sku_size, ssl_enforcement, backup_retention_days, geo_redundant_backup, resource_group, region, subscription_id
from azure.azure_postgresql_server
where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"configuration_name": "log_checkpoints",
"configuration_value": "on",
"end_ip_address": "40.112.8.12",
"name": "{{ resourceName }}",
"rule_name": "{{ resourceName }}",
"rule_type": "Microsoft.DBforPostgreSQL/servers/firewallRules",
"server_admin_login_name": "ActiveDirectory",
"start_ip_address": "40.112.8.12"
}
]
18 changes: 18 additions & 0 deletions azure-test/tests/azure_postgresql_server/test-hydrate-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
select
name,
rule ->> 'Name' as rule_name,
rule ->> 'Type' as rule_type,
rule -> 'FirewallRuleProperties' ->> 'endIpAddress' as end_ip_address,
rule -> 'FirewallRuleProperties' ->> 'startIpAddress' as start_ip_address,
configurations ->> 'Name' as configuration_name,
configurations -> 'ConfigurationProperties' ->> 'value' as configuration_value,
server_admin ->> 'Name' as server_admin_login_name
from
azure_postgresql_server,
jsonb_array_elements(server_configurations) as configurations,
jsonb_array_elements(firewall_rules) as rule,
jsonb_array_elements(server_administrators) as server_admin
where
name = '{{ resourceName }}'
and resource_group = '{{ resourceName }}'
and configurations ->> 'Name' = 'log_checkpoints';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"id": "{{ output.resource_id.value }}",
"location": "{{ output.location.value }}",
"name": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions azure-test/tests/azure_postgresql_server/test-list-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select id, name, location
from azure.azure_postgresql_server
where name = '{{ resourceName }}';
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, akas, title
from azure.azure_postgresql_server
where name = 'dummy-{{ resourceName }}' and resource_group = '{{ resourceName }}';
13 changes: 13 additions & 0 deletions azure-test/tests/azure_postgresql_server/test-turbot-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"akas": [
"{{ output.resource_aka.value }}",
"{{ output.resource_aka_lower.value }}"
],
"name": "{{ resourceName }}",
"tags": {
"name": "{{ resourceName }}"
},
"title": "{{ resourceName }}"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, akas, title, tags
from azure.azure_postgresql_server
where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}';
1 change: 1 addition & 0 deletions azure-test/tests/azure_postgresql_server/variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
113 changes: 113 additions & 0 deletions azure-test/tests/azure_postgresql_server/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@

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" {
features {}
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_postgresql_server" "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

sku_name = "B_Gen5_1"
version = "9.5"
storage_mb = 5120

backup_retention_days = 7
geo_redundant_backup_enabled = false
auto_grow_enabled = false
infrastructure_encryption_enabled = false

administrator_login = "psqladminun"
administrator_login_password = "H@Sh1CoR3!"

ssl_enforcement_enabled = true
ssl_minimal_tls_version_enforced = "TLS1_2"

tags = {
name = var.resource_name
}
}

resource "azurerm_postgresql_configuration" "named_test_resource" {
name = "log_checkpoints"
resource_group_name = azurerm_resource_group.named_test_resource.name
server_name = azurerm_postgresql_server.named_test_resource.name
value = "on"
}

resource "azurerm_postgresql_firewall_rule" "named_test_resource" {
name = var.resource_name
resource_group_name = azurerm_resource_group.named_test_resource.name
server_name = azurerm_postgresql_server.named_test_resource.name
start_ip_address = "40.112.8.12"
end_ip_address = "40.112.8.12"
}

resource "azurerm_postgresql_active_directory_administrator" "named_test_resource" {
server_name = azurerm_postgresql_server.named_test_resource.name
resource_group_name = azurerm_resource_group.named_test_resource.name
login = "sqladmin"
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = data.azurerm_client_config.current.object_id
}

output "resource_aka" {
value = "azure://${azurerm_postgresql_server.named_test_resource.id}"
}

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

output "resource_name" {
value = var.resource_name
}

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

output "location" {
value = lower(azurerm_resource_group.named_test_resource.location)
}

output "subscription_id" {
value = var.azure_subscription
}

output "server_fqdn" {
value = azurerm_postgresql_server.named_test_resource.fqdn
}
1 change: 1 addition & 0 deletions azure/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"azure_network_interface": tableAzureNetworkInterface(ctx),
"azure_network_security_group": tableAzureNetworkSecurityGroup(ctx),
"azure_network_watcher": tableAzureNetworkWatcher(ctx),
"azure_postgresql_server": tableAzurePostgreSqlServer(ctx),
"azure_provider": tableAzureProvider(ctx),
"azure_public_ip": tableAzurePublicIP(ctx),
"azure_resource_group": tableAzureResourceGroup(ctx),
Expand Down
Loading