Skip to content

Commit

Permalink
Add table azure_iothub_dps. Closes #322 (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdatasourav authored Oct 4, 2021
1 parent 20f013a commit 986f095
Show file tree
Hide file tree
Showing 15 changed files with 429 additions and 0 deletions.
Empty file.
5 changes: 5 additions & 0 deletions azure-test/tests/azure_iothub_dps/posttest-variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "null_resource" "named_resource" {
provisioner "local-exec" {
command = "az iot dps delete --resource-group {{ output.resource_name.value }} --name {{ output.resource_name.value }}"
}
}
10 changes: 10 additions & 0 deletions azure-test/tests/azure_iothub_dps/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.location.value }}",
"resource_group": "{{ resourceName }}",
"subscription_id": "{{ output.subscription_id.value }}",
"type": "Microsoft.Devices/provisioningServices"
}
]
3 changes: 3 additions & 0 deletions azure-test/tests/azure_iothub_dps/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_iothub_dps
where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}';
7 changes: 7 additions & 0 deletions azure-test/tests/azure_iothub_dps/test-list-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"id": "{{ output.resource_id.value }}",
"name": "{{ resourceName }}",
"type": "Microsoft.Devices/provisioningServices"
}
]
3 changes: 3 additions & 0 deletions azure-test/tests/azure_iothub_dps/test-list-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, id, type
from azure.azure_iothub_dps
where name = '{{ resourceName }}';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
null
3 changes: 3 additions & 0 deletions azure-test/tests/azure_iothub_dps/test-not-found-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, tags, title, akas
from azure.azure_iothub_dps
where name = 'dummy-{{ resourceName }}' and resource_group = '{{ resourceName }}';
10 changes: 10 additions & 0 deletions azure-test/tests/azure_iothub_dps/test-turbot-expected.json
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 azure-test/tests/azure_iothub_dps/test-turbot-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, title, akas
from azure.azure_iothub_dps
where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}';
1 change: 1 addition & 0 deletions azure-test/tests/azure_iothub_dps/variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
80 changes: 80 additions & 0 deletions azure-test/tests/azure_iothub_dps/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
variable "resource_name" {
type = string
default = "steampipe-test"
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-53c0616fc6c1"
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"
}

locals {
path = "${path.cwd}/info.json"
}

resource "null_resource" "named_test_resource" {
depends_on = [azurerm_resource_group.named_test_resource]
provisioner "local-exec" {
command = "az iot dps create --name ${var.resource_name} --resource-group ${var.resource_name} --location ${azurerm_resource_group.named_test_resource.location} > ${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 "location" {
value = azurerm_resource_group.named_test_resource.location
}

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 @@ -71,6 +71,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"azure_frontdoor": tableAzureFrontDoor(ctx),
"azure_healthcare_service": tableAzureHealthcareService(ctx),
"azure_iothub": tableAzureIotHub(ctx),
"azure_iothub_dps": tableAzureIotHubDps(ctx),
"azure_key_vault": tableAzureKeyVault(ctx),
"azure_key_vault_deleted_vault": tableAzureKeyVaultDeletedVault(ctx),
"azure_key_vault_key": tableAzureKeyVaultKey(ctx),
Expand Down
Loading

0 comments on commit 986f095

Please sign in to comment.