From 7dbf2f8a657678e753369f4b669b82a09f7d530d Mon Sep 17 00:00:00 2001 From: ParthaI Date: Mon, 5 Jul 2021 17:35:38 +0530 Subject: [PATCH 1/7] Add table azure_express_route_circuit closes #153 --- .../dependencies.txt | 0 .../test-get-expected.json | 8 + .../test-get-query.sql | 3 + .../test-hydrate-expected.json | 15 ++ .../test-hydrate-query.sql | 3 + .../test-list-expected.json | 6 + .../test-list-query.sql | 3 + .../test-not-found-expected.json | 1 + .../test-not-found-query.sql | 3 + .../test-turbot-expected.json | 13 + .../test-turbot-query.sql | 3 + .../variables.json | 1 + .../azure_express_route_circuit/varibles.tf | 86 +++++++ azure/plugin.go | 1 + azure/table_azure_express_route_circuit.go | 227 ++++++++++++++++++ docs/tables/azure_express_route_circuit.md | 46 ++++ 16 files changed, 419 insertions(+) create mode 100644 azure-test/tests/azure_express_route_circuit/dependencies.txt create mode 100644 azure-test/tests/azure_express_route_circuit/test-get-expected.json create mode 100644 azure-test/tests/azure_express_route_circuit/test-get-query.sql create mode 100644 azure-test/tests/azure_express_route_circuit/test-hydrate-expected.json create mode 100644 azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql create mode 100644 azure-test/tests/azure_express_route_circuit/test-list-expected.json create mode 100644 azure-test/tests/azure_express_route_circuit/test-list-query.sql create mode 100644 azure-test/tests/azure_express_route_circuit/test-not-found-expected.json create mode 100644 azure-test/tests/azure_express_route_circuit/test-not-found-query.sql create mode 100644 azure-test/tests/azure_express_route_circuit/test-turbot-expected.json create mode 100644 azure-test/tests/azure_express_route_circuit/test-turbot-query.sql create mode 100644 azure-test/tests/azure_express_route_circuit/variables.json create mode 100644 azure-test/tests/azure_express_route_circuit/varibles.tf create mode 100644 azure/table_azure_express_route_circuit.go create mode 100644 docs/tables/azure_express_route_circuit.md diff --git a/azure-test/tests/azure_express_route_circuit/dependencies.txt b/azure-test/tests/azure_express_route_circuit/dependencies.txt new file mode 100644 index 00000000..e69de29b diff --git a/azure-test/tests/azure_express_route_circuit/test-get-expected.json b/azure-test/tests/azure_express_route_circuit/test-get-expected.json new file mode 100644 index 00000000..42db63e9 --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/test-get-expected.json @@ -0,0 +1,8 @@ +[ + { + "id": "{{ output.resource_id.value }}", + "name": "{{ resourceName }}", + "resource_group": "{{ resourceName }}", + "sku_tier": "{{ output.sku_tire.value }}" + } +] \ No newline at end of file diff --git a/azure-test/tests/azure_express_route_circuit/test-get-query.sql b/azure-test/tests/azure_express_route_circuit/test-get-query.sql new file mode 100644 index 00000000..84bd7f0d --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/test-get-query.sql @@ -0,0 +1,3 @@ +select name, id, sku_tier, resource_group +from azure.azure_express_route_circuit +where name = '{{resourceName}}' and resource_group = '{{resourceName}}' diff --git a/azure-test/tests/azure_express_route_circuit/test-hydrate-expected.json b/azure-test/tests/azure_express_route_circuit/test-hydrate-expected.json new file mode 100644 index 00000000..506ca517 --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/test-hydrate-expected.json @@ -0,0 +1,15 @@ +[ + { + "akas": [ + "{{ output.resource_aka.value }}", + "{{ output.resource_aka_lower.value }}" + ], + "name": "{{ resourceName }}", + "sku_name": "{{ output.sku_tire.value }}_{{ output.sku_family.value }}", + "sku_tier": "{{ output.sku_tire.value }}", + "tags": { + "Name": "{{ resourceName }}" + }, + "title": "{{ resourceName }}" + } +] \ No newline at end of file diff --git a/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql b/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql new file mode 100644 index 00000000..3159bd4a --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql @@ -0,0 +1,3 @@ +select name, sku_name, sku_tier, akas, tags, title +from azure.azure_express_route_circuit +where name = '{{resourceName}}' and resource_group = '{{resourceName}}' diff --git a/azure-test/tests/azure_express_route_circuit/test-list-expected.json b/azure-test/tests/azure_express_route_circuit/test-list-expected.json new file mode 100644 index 00000000..f2d090cd --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/test-list-expected.json @@ -0,0 +1,6 @@ +[ + { + "id": "{{ output.resource_id.value }}", + "name": "{{ resourceName }}" + } +] \ No newline at end of file diff --git a/azure-test/tests/azure_express_route_circuit/test-list-query.sql b/azure-test/tests/azure_express_route_circuit/test-list-query.sql new file mode 100644 index 00000000..d924f41c --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/test-list-query.sql @@ -0,0 +1,3 @@ +select id, name +from azure.azure_express_route_circuit +where name = '{{resourceName}}' diff --git a/azure-test/tests/azure_express_route_circuit/test-not-found-expected.json b/azure-test/tests/azure_express_route_circuit/test-not-found-expected.json new file mode 100644 index 00000000..ec747fa4 --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/test-not-found-expected.json @@ -0,0 +1 @@ +null \ No newline at end of file diff --git a/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql b/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql new file mode 100644 index 00000000..47b98b42 --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql @@ -0,0 +1,3 @@ +select name, akas, tags, title +from azure.azure_express_route_circuit +where name = 'dummy-{{resourceName}}' and resource_group = '{{resourceName}}' diff --git a/azure-test/tests/azure_express_route_circuit/test-turbot-expected.json b/azure-test/tests/azure_express_route_circuit/test-turbot-expected.json new file mode 100644 index 00000000..9028baab --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/test-turbot-expected.json @@ -0,0 +1,13 @@ +[ + { + "akas": [ + "{{ output.resource_aka.value }}", + "{{ output.resource_aka_lower.value }}" + ], + "name": "{{ resourceName }}", + "tags": { + "Name": "{{ resourceName }}" + }, + "title": "{{ resourceName }}" + } +] \ No newline at end of file diff --git a/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql b/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql new file mode 100644 index 00000000..af14da0b --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql @@ -0,0 +1,3 @@ +select name, akas, title, tags +from azure.azure_express_route_circuit +where name = '{{resourceName}}' and resource_group = '{{resourceName}}' diff --git a/azure-test/tests/azure_express_route_circuit/variables.json b/azure-test/tests/azure_express_route_circuit/variables.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/variables.json @@ -0,0 +1 @@ +{} diff --git a/azure-test/tests/azure_express_route_circuit/varibles.tf b/azure-test/tests/azure_express_route_circuit/varibles.tf new file mode 100644 index 00000000..716c4a1a --- /dev/null +++ b/azure-test/tests/azure_express_route_circuit/varibles.tf @@ -0,0 +1,86 @@ + +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" + default = "d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8" + description = "Azure subscription used for the test." +} + +provider "azurerm" { + # Cannot be passed as a variable + version = "=2.43.0" + 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 = "West US" +} + +resource "azurerm_express_route_circuit" "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 + service_provider_name = "Equinix" + peering_location = "Silicon Valley" + bandwidth_in_mbps = 50 + + sku { + tier = "Standard" + family = "MeteredData" + } + + tags = { + Name = var.resource_name + } +} + +output "resource_aka" { + value = "azure://${azurerm_express_route_circuit.named_test_resource.id}" +} + +output "resource_aka_lower" { + value = "azure://${lower(azurerm_express_route_circuit.named_test_resource.id)}" +} + +output "sku_tire" { + value = "Standard" +} + +output "sku_family" { + value = "MeteredData" +} + +output "resource_name" { + value = var.resource_name +} + +output "resource_id" { + value = azurerm_express_route_circuit.named_test_resource.id +} + +output "subscription_id" { + value = var.azure_subscription +} diff --git a/azure/plugin.go b/azure/plugin.go index 63feab55..616776bc 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -42,6 +42,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx), "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), "azure_diagnostic_setting": tableAzureDiagnosticSetting(ctx), + "azure_express_route_circuit": tableAzureExpressRouteCircuit(ctx), "azure_firewall": tableAzureFirewall(ctx), "azure_key_vault": tableAzureKeyVault(ctx), "azure_key_vault_key": tableAzureKeyVaultKey(ctx), diff --git a/azure/table_azure_express_route_circuit.go b/azure/table_azure_express_route_circuit.go new file mode 100644 index 00000000..30dc1317 --- /dev/null +++ b/azure/table_azure_express_route_circuit.go @@ -0,0 +1,227 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2020-07-01/network" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_expressroute_circuit", + Description: "Azure Express Route Circuit", + Get: &plugin.GetConfig{ + KeyColumns: plugin.AllColumns([]string{"name", "resource_group"}), + Hydrate: getExpressRouteCircuit, + ShouldIgnoreError: isNotFoundError([]string{"ResourceNotFound", "ResourceGroupNotFound", "404"}), + }, + List: &plugin.ListConfig{ + Hydrate: listExpressRouteCircuits, + }, + Columns: []*plugin.Column{ + { + Name: "name", + Description: "The friendly name that identifies the Circuit", + Type: proto.ColumnType_STRING, + }, + { + Name: "id", + Description: "Resource ID.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ID"), + }, + { + Name: "etag", + Description: "A unique read-only string that changes whenever the resource is updated.", + Type: proto.ColumnType_STRING, + }, + { + Name: "sku_name", + Description: "The name of the SKU.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Sku.Name"), + }, + { + Name: "sku_tier", + Description: "The tier of the SKU. Possible values include: 'ExpressRouteCircuitSkuTierStandard', 'ExpressRouteCircuitSkuTierPremium', 'ExpressRouteCircuitSkuTierBasic', 'ExpressRouteCircuitSkuTierLocal'", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Sku.Tier"), + }, + { + Name: "sku_family", + Description: "Family - The family of the SKU. Possible values include: 'UnlimitedData', 'MeteredData'", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Sku.Family"), + }, + { + Name: "allow_classic_operations", + Description: "Allow classic operations.", + Type: proto.ColumnType_BOOL, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.AllowClassicOperations"), + }, + { + Name: "circuit_provisioning_state", + Description: "The CircuitProvisioningState state of the resource.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.CircuitProvisioningState"), + }, + { + Name: "service_provider_provisioning_state", + Description: "The ServiceProviderProvisioningState state of the resource. Possible values include: 'ServiceProviderProvisioningStateNotProvisioned', 'ServiceProviderProvisioningStateProvisioning', 'ServiceProviderProvisioningStateProvisioned', 'ServiceProviderProvisioningStateDeprovisioning", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderProvisioningState"), + }, + { + Name: "authorizations", + Description: "The list of authorizations.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.Authorizations"), + }, + { + Name: "peerings", + Description: "The list of peerings.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.Peerings"), + }, + { + Name: "service_key", + Description: "The ServiceKey.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceKey"), + }, + { + Name: "service_provider_notes", + Description: "The ServiceProviderNotes.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderNotes"), + }, + { + Name: "service_provider_properties", + Description: "The ServiceProviderProperties.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderProperties"), + }, + { + Name: "express_route_port", + Description: "The reference to the ExpressRoutePort resource when the circuit is provisioned on an ExpressRoutePort resource.", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ExpressRoutePort"), + }, + { + Name: "bandwidth_in_gbps", + Description: "The bandwidth of the circuit when the circuit is provisioned on an ExpressRoutePort resource.", + Type: proto.ColumnType_DOUBLE, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.BandwidthInGbps"), + }, + { + Name: "provisioning_state", + Description: "The provisioning state of the express route circuit resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed'", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ProvisioningState"), + }, + { + Name: "global_reach_enabled", + Description: "Flag denoting global reach status.", + Type: proto.ColumnType_BOOL, + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.GlobalReachEnabled"), + }, + { + Name: "tag_src", + Description: "Resource tags", + Type: proto.ColumnType_JSON, + Transform: transform.FromField("Tags"), + }, + + // Standard columns + { + Name: "title", + Description: ColumnDescriptionTitle, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Name"), + }, + { + Name: "tags", + Description: ColumnDescriptionTags, + Type: proto.ColumnType_JSON, + }, + { + Name: "akas", + Description: ColumnDescriptionAkas, + Type: proto.ColumnType_JSON, + Transform: transform.FromField("ID").Transform(idToAkas), + }, + { + Name: "region", + Description: ColumnDescriptionRegion, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("Location").Transform(toLower), + }, + { + Name: "resource_group", + Description: ColumnDescriptionResourceGroup, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ID").Transform(extractResourceGroupFromID), + }, + { + Name: "subscription_id", + Description: ColumnDescriptionSubscription, + Type: proto.ColumnType_STRING, + Transform: transform.FromField("ID").Transform(idToSubscriptionID), + }, + }, + } +} + +//// LIST FUNCTION + +func listExpressRouteCircuits(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + subscriptionID := session.SubscriptionID + expressRouteCircuitClient := network.NewExpressRouteCircuitsClient(subscriptionID) + expressRouteCircuitClient.Authorizer = session.Authorizer + + pagesLeft := true + for pagesLeft { + result, err := expressRouteCircuitClient.ListAll(ctx) + if err != nil { + return nil, err + } + + for _, route := range result.Values() { + d.StreamListItem(ctx, route) + } + result.NextWithContext(context.Background()) + pagesLeft = result.NotDone() + } + + return nil, nil +} + +//// HYDRATE FUNCTION + +func getExpressRouteCircuit(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + + name := d.KeyColumnQuals["name"].GetStringValue() + resourceGroup := d.KeyColumnQuals["resource_group"].GetStringValue() + + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + subscriptionID := session.SubscriptionID + expressRouteCircuitClient := network.NewExpressRouteCircuitsClient(subscriptionID) + expressRouteCircuitClient.Authorizer = session.Authorizer + op, err := expressRouteCircuitClient.Get(ctx, resourceGroup, name) + if err != nil { + return nil, err + } + return op, nil +} \ No newline at end of file diff --git a/docs/tables/azure_express_route_circuit.md b/docs/tables/azure_express_route_circuit.md new file mode 100644 index 00000000..1e055950 --- /dev/null +++ b/docs/tables/azure_express_route_circuit.md @@ -0,0 +1,46 @@ +# Table: azure_express_route_circuit + +ExpressRoute lets you extend your on-premises networks into the Microsoft cloud over a private connection with the help of a connectivity provider. With ExpressRoute, you can establish connections to Microsoft cloud services, such as Microsoft Azure and Microsoft 365. + +## Examples + +### Basic info + +```sql +select + name, + id, + allow_classic_operations, + circuit_provisioning_state +from + azure_express_route_circuit; +``` + + +### List express route circuits which have global reach enabled + +```sql +select + name, + sku_tier, + sku_name +from + azure_express_route_circuit +where + global_reach_enabled; +``` + + +### List the premium category express route circuits + +```sql +select + name, + sku_tier, + sku_name +from + azure_express_route_circuit +where + sku_tier = 'Premium'; +``` + From a8a2a4e7c9b6b0bd252fa6fc9a0df19bbc2bf5f0 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Mon, 5 Jul 2021 17:36:56 +0530 Subject: [PATCH 2/7] Updated the subscription id in vatiables.tf --- azure-test/tests/azure_express_route_circuit/varibles.tf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azure-test/tests/azure_express_route_circuit/varibles.tf b/azure-test/tests/azure_express_route_circuit/varibles.tf index 716c4a1a..d4103543 100644 --- a/azure-test/tests/azure_express_route_circuit/varibles.tf +++ b/azure-test/tests/azure_express_route_circuit/varibles.tf @@ -13,8 +13,7 @@ variable "azure_environment" { variable "azure_subscription" { type = string - # default = "3510ae4d-530b-497d-8f30-53b9616fc6c1" - default = "d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8" + default = "3510ae4d-530b-497d-8f30-53b9616fc6c1" description = "Azure subscription used for the test." } From b13a0ccbebdb24f545d6534a8be038592590f439 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Tue, 6 Jul 2021 11:22:22 +0530 Subject: [PATCH 3/7] Made changes as per review comments --- .../test-get-query.sql | 2 +- .../test-hydrate-query.sql | 2 +- .../test-list-query.sql | 2 +- .../test-not-found-query.sql | 2 +- .../test-turbot-query.sql | 2 +- .../azure_express_route_circuit/varibles.tf | 1 - azure/table_azure_express_route_circuit.go | 69 +++++++++++-------- docs/tables/azure_express_route_circuit.md | 2 +- 8 files changed, 45 insertions(+), 37 deletions(-) diff --git a/azure-test/tests/azure_express_route_circuit/test-get-query.sql b/azure-test/tests/azure_express_route_circuit/test-get-query.sql index 84bd7f0d..e66c1488 100644 --- a/azure-test/tests/azure_express_route_circuit/test-get-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-get-query.sql @@ -1,3 +1,3 @@ select name, id, sku_tier, resource_group from azure.azure_express_route_circuit -where name = '{{resourceName}}' and resource_group = '{{resourceName}}' +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}' diff --git a/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql b/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql index 3159bd4a..7ca18642 100644 --- a/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql @@ -1,3 +1,3 @@ select name, sku_name, sku_tier, akas, tags, title from azure.azure_express_route_circuit -where name = '{{resourceName}}' and resource_group = '{{resourceName}}' +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}' diff --git a/azure-test/tests/azure_express_route_circuit/test-list-query.sql b/azure-test/tests/azure_express_route_circuit/test-list-query.sql index d924f41c..67cb313f 100644 --- a/azure-test/tests/azure_express_route_circuit/test-list-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-list-query.sql @@ -1,3 +1,3 @@ select id, name from azure.azure_express_route_circuit -where name = '{{resourceName}}' +where name = '{{ resourceName }}' diff --git a/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql b/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql index 47b98b42..35b0459f 100644 --- a/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql @@ -1,3 +1,3 @@ select name, akas, tags, title from azure.azure_express_route_circuit -where name = 'dummy-{{resourceName}}' and resource_group = '{{resourceName}}' +where name = 'dummy-{{ resourceName }}' and resource_group = '{{ resourceName }}' diff --git a/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql b/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql index af14da0b..5ab489d2 100644 --- a/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql @@ -1,3 +1,3 @@ select name, akas, title, tags from azure.azure_express_route_circuit -where name = '{{resourceName}}' and resource_group = '{{resourceName}}' +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}' diff --git a/azure-test/tests/azure_express_route_circuit/varibles.tf b/azure-test/tests/azure_express_route_circuit/varibles.tf index d4103543..c90d6746 100644 --- a/azure-test/tests/azure_express_route_circuit/varibles.tf +++ b/azure-test/tests/azure_express_route_circuit/varibles.tf @@ -1,4 +1,3 @@ - variable "resource_name" { type = string default = "turbot-test-20200125-create-update" diff --git a/azure/table_azure_express_route_circuit.go b/azure/table_azure_express_route_circuit.go index 30dc1317..86c1b5ec 100644 --- a/azure/table_azure_express_route_circuit.go +++ b/azure/table_azure_express_route_circuit.go @@ -15,7 +15,7 @@ func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { return &plugin.Table{ Name: "azure_expressroute_circuit", Description: "Azure Express Route Circuit", - Get: &plugin.GetConfig{ + Get: &plugin.GetConfig{ KeyColumns: plugin.AllColumns([]string{"name", "resource_group"}), Hydrate: getExpressRouteCircuit, ShouldIgnoreError: isNotFoundError([]string{"ResourceNotFound", "ResourceGroupNotFound", "404"}), @@ -26,14 +26,14 @@ func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { Columns: []*plugin.Column{ { Name: "name", - Description: "The friendly name that identifies the Circuit", + Description: "The friendly name that identifies the Circuit.", Type: proto.ColumnType_STRING, }, { Name: "id", Description: "Resource ID.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("ID"), + Transform: transform.FromField("ID"), }, { Name: "etag", @@ -44,100 +44,100 @@ func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { Name: "sku_name", Description: "The name of the SKU.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("Sku.Name"), + Transform: transform.FromField("Sku.Name"), }, { Name: "sku_tier", - Description: "The tier of the SKU. Possible values include: 'ExpressRouteCircuitSkuTierStandard', 'ExpressRouteCircuitSkuTierPremium', 'ExpressRouteCircuitSkuTierBasic', 'ExpressRouteCircuitSkuTierLocal'", + Description: "The tier of the SKU. Possible values include: 'ExpressRouteCircuitSkuTierStandard', 'ExpressRouteCircuitSkuTierPremium', 'ExpressRouteCircuitSkuTierBasic', 'ExpressRouteCircuitSkuTierLocal'.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("Sku.Tier"), + Transform: transform.FromField("Sku.Tier"), }, { Name: "sku_family", - Description: "Family - The family of the SKU. Possible values include: 'UnlimitedData', 'MeteredData'", + Description: "Family - The family of the SKU. Possible values include: 'UnlimitedData', 'MeteredData'.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("Sku.Family"), + Transform: transform.FromField("Sku.Family"), }, { Name: "allow_classic_operations", Description: "Allow classic operations.", Type: proto.ColumnType_BOOL, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.AllowClassicOperations"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.AllowClassicOperations"), }, { Name: "circuit_provisioning_state", Description: "The CircuitProvisioningState state of the resource.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.CircuitProvisioningState"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.CircuitProvisioningState"), }, { Name: "service_provider_provisioning_state", - Description: "The ServiceProviderProvisioningState state of the resource. Possible values include: 'ServiceProviderProvisioningStateNotProvisioned', 'ServiceProviderProvisioningStateProvisioning', 'ServiceProviderProvisioningStateProvisioned', 'ServiceProviderProvisioningStateDeprovisioning", + Description: "The ServiceProviderProvisioningState state of the resource. Possible values include: 'ServiceProviderProvisioningStateNotProvisioned', 'ServiceProviderProvisioningStateProvisioning', 'ServiceProviderProvisioningStateProvisioned', 'ServiceProviderProvisioningStateDeprovisioning.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderProvisioningState"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderProvisioningState"), }, { Name: "authorizations", Description: "The list of authorizations.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.Authorizations"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.Authorizations"), }, { Name: "peerings", Description: "The list of peerings.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.Peerings"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.Peerings"), }, { Name: "service_key", Description: "The ServiceKey.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceKey"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceKey"), }, { Name: "service_provider_notes", Description: "The ServiceProviderNotes.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderNotes"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderNotes"), }, { Name: "service_provider_properties", Description: "The ServiceProviderProperties.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderProperties"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderProperties"), }, { Name: "express_route_port", Description: "The reference to the ExpressRoutePort resource when the circuit is provisioned on an ExpressRoutePort resource.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ExpressRoutePort"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ExpressRoutePort"), }, { Name: "bandwidth_in_gbps", Description: "The bandwidth of the circuit when the circuit is provisioned on an ExpressRoutePort resource.", Type: proto.ColumnType_DOUBLE, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.BandwidthInGbps"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.BandwidthInGbps"), }, { Name: "provisioning_state", - Description: "The provisioning state of the express route circuit resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed'", + Description: "The provisioning state of the express route circuit resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed'.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ProvisioningState"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ProvisioningState"), }, { Name: "global_reach_enabled", Description: "Flag denoting global reach status.", Type: proto.ColumnType_BOOL, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.GlobalReachEnabled"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.GlobalReachEnabled"), }, { Name: "tag_src", - Description: "Resource tags", + Description: "Resource tags.", Type: proto.ColumnType_JSON, - Transform: transform.FromField("Tags"), + Transform: transform.FromField("Tags"), }, - // Standard columns + // Steampipe standard columns { Name: "title", Description: ColumnDescriptionTitle, @@ -155,6 +155,8 @@ func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { Type: proto.ColumnType_JSON, Transform: transform.FromField("ID").Transform(idToAkas), }, + + // Azure standard columns { Name: "region", Description: ColumnDescriptionRegion, @@ -185,6 +187,7 @@ func listExpressRouteCircuits(ctx context.Context, d *plugin.QueryData, _ *plugi return nil, err } subscriptionID := session.SubscriptionID + expressRouteCircuitClient := network.NewExpressRouteCircuitsClient(subscriptionID) expressRouteCircuitClient.Authorizer = session.Authorizer @@ -195,33 +198,39 @@ func listExpressRouteCircuits(ctx context.Context, d *plugin.QueryData, _ *plugi return nil, err } - for _, route := range result.Values() { - d.StreamListItem(ctx, route) + for _, routeCircuit := range result.Values() { + d.StreamListItem(ctx, routeCircuit) } result.NextWithContext(context.Background()) pagesLeft = result.NotDone() } - + return nil, nil } //// HYDRATE FUNCTION func getExpressRouteCircuit(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { - name := d.KeyColumnQuals["name"].GetStringValue() resourceGroup := d.KeyColumnQuals["resource_group"].GetStringValue() + // Handle empty name or resourceGroup + if name == "" || resourceGroup == "" { + return nil, nil + } + session, err := GetNewSession(ctx, d, "MANAGEMENT") if err != nil { return nil, err } subscriptionID := session.SubscriptionID + expressRouteCircuitClient := network.NewExpressRouteCircuitsClient(subscriptionID) expressRouteCircuitClient.Authorizer = session.Authorizer + op, err := expressRouteCircuitClient.Get(ctx, resourceGroup, name) if err != nil { return nil, err } return op, nil -} \ No newline at end of file +} diff --git a/docs/tables/azure_express_route_circuit.md b/docs/tables/azure_express_route_circuit.md index 1e055950..e0f8be38 100644 --- a/docs/tables/azure_express_route_circuit.md +++ b/docs/tables/azure_express_route_circuit.md @@ -1,6 +1,6 @@ # Table: azure_express_route_circuit -ExpressRoute lets you extend your on-premises networks into the Microsoft cloud over a private connection with the help of a connectivity provider. With ExpressRoute, you can establish connections to Microsoft cloud services, such as Microsoft Azure and Microsoft 365. +An ExpressRoute circuit represents a logical connection between your on-premises infrastructure and Microsoft cloud services through a connectivity provider. You can order multiple ExpressRoute circuits. Each circuit can be in the same or different regions, and can be connected to your premises through different connectivity providers. ## Examples From 04f135595913154075c578f83e268087f70ad9d4 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Tue, 6 Jul 2021 12:07:16 +0530 Subject: [PATCH 4/7] Removed the tag_src column from the table --- azure/table_azure_express_route_circuit.go | 6 ------ docs/tables/azure_express_route_circuit.md | 5 +---- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/azure/table_azure_express_route_circuit.go b/azure/table_azure_express_route_circuit.go index 86c1b5ec..2904928c 100644 --- a/azure/table_azure_express_route_circuit.go +++ b/azure/table_azure_express_route_circuit.go @@ -130,12 +130,6 @@ func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { Type: proto.ColumnType_BOOL, Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.GlobalReachEnabled"), }, - { - Name: "tag_src", - Description: "Resource tags.", - Type: proto.ColumnType_JSON, - Transform: transform.FromField("Tags"), - }, // Steampipe standard columns { diff --git a/docs/tables/azure_express_route_circuit.md b/docs/tables/azure_express_route_circuit.md index e0f8be38..7547f362 100644 --- a/docs/tables/azure_express_route_circuit.md +++ b/docs/tables/azure_express_route_circuit.md @@ -16,7 +16,6 @@ from azure_express_route_circuit; ``` - ### List express route circuits which have global reach enabled ```sql @@ -30,8 +29,7 @@ where global_reach_enabled; ``` - -### List the premium category express route circuits +### List premium category express route circuits ```sql select @@ -43,4 +41,3 @@ from where sku_tier = 'Premium'; ``` - From ec7b0965d1309fa92272d9e3e993219886f923b0 Mon Sep 17 00:00:00 2001 From: bigdatasourav Date: Tue, 6 Jul 2021 12:12:27 +0530 Subject: [PATCH 5/7] test-update --- azure-test/tests/azure_express_route_circuit/test-get-query.sql | 2 +- .../tests/azure_express_route_circuit/test-hydrate-query.sql | 2 +- .../tests/azure_express_route_circuit/test-list-query.sql | 2 +- .../tests/azure_express_route_circuit/test-not-found-query.sql | 2 +- .../tests/azure_express_route_circuit/test-turbot-query.sql | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/azure-test/tests/azure_express_route_circuit/test-get-query.sql b/azure-test/tests/azure_express_route_circuit/test-get-query.sql index e66c1488..af1e7abe 100644 --- a/azure-test/tests/azure_express_route_circuit/test-get-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-get-query.sql @@ -1,3 +1,3 @@ select name, id, sku_tier, resource_group from azure.azure_express_route_circuit -where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}' +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; diff --git a/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql b/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql index 7ca18642..2025dcca 100644 --- a/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql @@ -1,3 +1,3 @@ select name, sku_name, sku_tier, akas, tags, title from azure.azure_express_route_circuit -where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}' +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; diff --git a/azure-test/tests/azure_express_route_circuit/test-list-query.sql b/azure-test/tests/azure_express_route_circuit/test-list-query.sql index 67cb313f..40bcbddb 100644 --- a/azure-test/tests/azure_express_route_circuit/test-list-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-list-query.sql @@ -1,3 +1,3 @@ select id, name from azure.azure_express_route_circuit -where name = '{{ resourceName }}' +where name = '{{ resourceName }}'; diff --git a/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql b/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql index 35b0459f..f6ddc81f 100644 --- a/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql @@ -1,3 +1,3 @@ select name, akas, tags, title from azure.azure_express_route_circuit -where name = 'dummy-{{ resourceName }}' and resource_group = '{{ resourceName }}' +where name = 'dummy-{{ resourceName }}' and resource_group = '{{ resourceName }}'; diff --git a/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql b/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql index 5ab489d2..281df4d7 100644 --- a/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql @@ -1,3 +1,3 @@ select name, akas, title, tags from azure.azure_express_route_circuit -where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}' +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; From 5c070d33bb3acd262eee50bcae3d366ea144a0bc Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 8 Jul 2021 18:27:06 +0530 Subject: [PATCH 6/7] Made changes as per review comments --- azure/table_azure_express_route_circuit.go | 24 +++++++++++----------- docs/tables/azure_express_route_circuit.md | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/azure/table_azure_express_route_circuit.go b/azure/table_azure_express_route_circuit.go index 2904928c..6ac3799e 100644 --- a/azure/table_azure_express_route_circuit.go +++ b/azure/table_azure_express_route_circuit.go @@ -13,7 +13,7 @@ import ( func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { return &plugin.Table{ - Name: "azure_expressroute_circuit", + Name: "azure_express_route_circuit", Description: "Azure Express Route Circuit", Get: &plugin.GetConfig{ KeyColumns: plugin.AllColumns([]string{"name", "resource_group"}), @@ -26,18 +26,18 @@ func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { Columns: []*plugin.Column{ { Name: "name", - Description: "The friendly name that identifies the Circuit.", + Description: "The friendly name that identifies the circuit.", Type: proto.ColumnType_STRING, }, { Name: "id", Description: "Resource ID.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("ID"), + Transform: transform.FromGo(), }, { Name: "etag", - Description: "A unique read-only string that changes whenever the resource is updated.", + Description: "An unique read-only string that changes whenever the resource is updated.", Type: proto.ColumnType_STRING, }, { @@ -48,15 +48,15 @@ func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { }, { Name: "sku_tier", - Description: "The tier of the SKU. Possible values include: 'ExpressRouteCircuitSkuTierStandard', 'ExpressRouteCircuitSkuTierPremium', 'ExpressRouteCircuitSkuTierBasic', 'ExpressRouteCircuitSkuTierLocal'.", + Description: "The tier of the SKU. Possible values include: 'Standard', 'Premium', 'Basic', 'Local'.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("Sku.Tier"), + Transform: transform.FromField("Sku.Tier").Transform(transform.ToString), }, { Name: "sku_family", - Description: "Family - The family of the SKU. Possible values include: 'UnlimitedData', 'MeteredData'.", + Description: "The family of the SKU. Possible values include: 'UnlimitedData', 'MeteredData'.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("Sku.Family"), + Transform: transform.FromField("Sku.Family").Transform(transform.ToString), }, { Name: "allow_classic_operations", @@ -72,9 +72,9 @@ func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { }, { Name: "service_provider_provisioning_state", - Description: "The ServiceProviderProvisioningState state of the resource. Possible values include: 'ServiceProviderProvisioningStateNotProvisioned', 'ServiceProviderProvisioningStateProvisioning', 'ServiceProviderProvisioningStateProvisioned', 'ServiceProviderProvisioningStateDeprovisioning.", + Description: "The ServiceProviderProvisioningState state of the resource. Possible values include: 'NotProvisioned', 'Provisioning', 'Provisioned', 'Deprovisioning'.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderProvisioningState"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ServiceProviderProvisioningState").Transform(transform.ToString), }, { Name: "authorizations", @@ -122,7 +122,7 @@ func tableAzureExpressRouteCircuit(_ context.Context) *plugin.Table { Name: "provisioning_state", Description: "The provisioning state of the express route circuit resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed'.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ProvisioningState"), + Transform: transform.FromField("ExpressRouteCircuitPropertiesFormat.ProvisioningState").Transform(transform.ToString), }, { Name: "global_reach_enabled", @@ -202,7 +202,7 @@ func listExpressRouteCircuits(ctx context.Context, d *plugin.QueryData, _ *plugi return nil, nil } -//// HYDRATE FUNCTION +//// HYDRATE FUNCTIONS func getExpressRouteCircuit(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { name := d.KeyColumnQuals["name"].GetStringValue() diff --git a/docs/tables/azure_express_route_circuit.md b/docs/tables/azure_express_route_circuit.md index 7547f362..71357c30 100644 --- a/docs/tables/azure_express_route_circuit.md +++ b/docs/tables/azure_express_route_circuit.md @@ -16,7 +16,7 @@ from azure_express_route_circuit; ``` -### List express route circuits which have global reach enabled +### List express route circuits with global reach enabled ```sql select @@ -29,7 +29,7 @@ where global_reach_enabled; ``` -### List premium category express route circuits +### List premium express route circuits ```sql select From eecb496a0d2fd9149d34fb58952529a6964bdefa Mon Sep 17 00:00:00 2001 From: Subhajit Kumar Mondal Date: Thu, 8 Jul 2021 21:16:44 +0530 Subject: [PATCH 7/7] Fixed indentation --- .../test-get-expected.json | 2 +- .../test-get-query.sql | 2 +- .../test-hydrate-expected.json | 2 +- .../test-hydrate-query.sql | 2 +- .../test-list-expected.json | 2 +- .../test-list-query.sql | 2 +- .../test-not-found-expected.json | 2 +- .../test-not-found-query.sql | 2 +- .../test-turbot-expected.json | 2 +- .../test-turbot-query.sql | 2 +- .../azure_express_route_circuit/varibles.tf | 2 +- azure/table_azure_express_route_circuit.go | 16 +++++++++------- 12 files changed, 20 insertions(+), 18 deletions(-) diff --git a/azure-test/tests/azure_express_route_circuit/test-get-expected.json b/azure-test/tests/azure_express_route_circuit/test-get-expected.json index 42db63e9..05bab364 100644 --- a/azure-test/tests/azure_express_route_circuit/test-get-expected.json +++ b/azure-test/tests/azure_express_route_circuit/test-get-expected.json @@ -5,4 +5,4 @@ "resource_group": "{{ resourceName }}", "sku_tier": "{{ output.sku_tire.value }}" } -] \ No newline at end of file +] diff --git a/azure-test/tests/azure_express_route_circuit/test-get-query.sql b/azure-test/tests/azure_express_route_circuit/test-get-query.sql index af1e7abe..0e41b464 100644 --- a/azure-test/tests/azure_express_route_circuit/test-get-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-get-query.sql @@ -1,3 +1,3 @@ select name, id, sku_tier, resource_group from azure.azure_express_route_circuit -where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_express_route_circuit/test-hydrate-expected.json b/azure-test/tests/azure_express_route_circuit/test-hydrate-expected.json index 506ca517..c803f5ca 100644 --- a/azure-test/tests/azure_express_route_circuit/test-hydrate-expected.json +++ b/azure-test/tests/azure_express_route_circuit/test-hydrate-expected.json @@ -12,4 +12,4 @@ }, "title": "{{ resourceName }}" } -] \ No newline at end of file +] diff --git a/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql b/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql index 2025dcca..c04d5ad4 100644 --- a/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-hydrate-query.sql @@ -1,3 +1,3 @@ select name, sku_name, sku_tier, akas, tags, title from azure.azure_express_route_circuit -where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_express_route_circuit/test-list-expected.json b/azure-test/tests/azure_express_route_circuit/test-list-expected.json index f2d090cd..e854f350 100644 --- a/azure-test/tests/azure_express_route_circuit/test-list-expected.json +++ b/azure-test/tests/azure_express_route_circuit/test-list-expected.json @@ -3,4 +3,4 @@ "id": "{{ output.resource_id.value }}", "name": "{{ resourceName }}" } -] \ No newline at end of file +] diff --git a/azure-test/tests/azure_express_route_circuit/test-list-query.sql b/azure-test/tests/azure_express_route_circuit/test-list-query.sql index 40bcbddb..c2409199 100644 --- a/azure-test/tests/azure_express_route_circuit/test-list-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-list-query.sql @@ -1,3 +1,3 @@ select id, name from azure.azure_express_route_circuit -where name = '{{ resourceName }}'; +where name = '{{ resourceName }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_express_route_circuit/test-not-found-expected.json b/azure-test/tests/azure_express_route_circuit/test-not-found-expected.json index ec747fa4..19765bd5 100644 --- a/azure-test/tests/azure_express_route_circuit/test-not-found-expected.json +++ b/azure-test/tests/azure_express_route_circuit/test-not-found-expected.json @@ -1 +1 @@ -null \ No newline at end of file +null diff --git a/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql b/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql index f6ddc81f..58faa914 100644 --- a/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-not-found-query.sql @@ -1,3 +1,3 @@ select name, akas, tags, title from azure.azure_express_route_circuit -where name = 'dummy-{{ resourceName }}' and resource_group = '{{ resourceName }}'; +where name = 'dummy-{{ resourceName }}' and resource_group = '{{ resourceName }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_express_route_circuit/test-turbot-expected.json b/azure-test/tests/azure_express_route_circuit/test-turbot-expected.json index 9028baab..ee16ed52 100644 --- a/azure-test/tests/azure_express_route_circuit/test-turbot-expected.json +++ b/azure-test/tests/azure_express_route_circuit/test-turbot-expected.json @@ -10,4 +10,4 @@ }, "title": "{{ resourceName }}" } -] \ No newline at end of file +] diff --git a/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql b/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql index 281df4d7..3c0d7896 100644 --- a/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql +++ b/azure-test/tests/azure_express_route_circuit/test-turbot-query.sql @@ -1,3 +1,3 @@ select name, akas, title, tags from azure.azure_express_route_circuit -where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; +where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}'; \ No newline at end of file diff --git a/azure-test/tests/azure_express_route_circuit/varibles.tf b/azure-test/tests/azure_express_route_circuit/varibles.tf index c90d6746..8ac8a57f 100644 --- a/azure-test/tests/azure_express_route_circuit/varibles.tf +++ b/azure-test/tests/azure_express_route_circuit/varibles.tf @@ -18,7 +18,7 @@ variable "azure_subscription" { provider "azurerm" { # Cannot be passed as a variable - version = "=2.43.0" + version = "=2.43.0" features {} environment = var.azure_environment subscription_id = var.azure_subscription diff --git a/azure/table_azure_express_route_circuit.go b/azure/table_azure_express_route_circuit.go index 6ac3799e..2e93bb69 100644 --- a/azure/table_azure_express_route_circuit.go +++ b/azure/table_azure_express_route_circuit.go @@ -191,7 +191,6 @@ func listExpressRouteCircuits(ctx context.Context, d *plugin.QueryData, _ *plugi if err != nil { return nil, err } - for _, routeCircuit := range result.Values() { d.StreamListItem(ctx, routeCircuit) } @@ -205,6 +204,15 @@ func listExpressRouteCircuits(ctx context.Context, d *plugin.QueryData, _ *plugi //// HYDRATE FUNCTIONS func getExpressRouteCircuit(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + plugin.Logger(ctx).Trace("getExpressRouteCircuit") + + // Create session + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + subscriptionID := session.SubscriptionID + name := d.KeyColumnQuals["name"].GetStringValue() resourceGroup := d.KeyColumnQuals["resource_group"].GetStringValue() @@ -213,12 +221,6 @@ func getExpressRouteCircuit(ctx context.Context, d *plugin.QueryData, h *plugin. return nil, nil } - session, err := GetNewSession(ctx, d, "MANAGEMENT") - if err != nil { - return nil, err - } - subscriptionID := session.SubscriptionID - expressRouteCircuitClient := network.NewExpressRouteCircuitsClient(subscriptionID) expressRouteCircuitClient.Authorizer = session.Authorizer