From 408051e81792736ca89217f7cb4a25489683fc3c Mon Sep 17 00:00:00 2001 From: misraved Date: Mon, 7 Nov 2022 13:38:27 +0530 Subject: [PATCH 1/2] Update docs/index.md file to include multi-subscription examples closes #519 --- docs/index.md | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/docs/index.md b/docs/index.md index 75df4acd..e0dcfaa3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -112,6 +112,93 @@ connection "azure" { } ``` +## Specify multiple subscriptions + +You may create multiple azure connections: +```hcl +connection "azure_all" { + type = "aggregator" + plugin = "azure" + connections = ["azure_*"] +} + +connection "azure_sub_1" { + plugin = "azure" + subscription_id = "azure_01" +} + +connection "azure_sub_2" { + plugin = "azure" + subscription_id = "azure_02" +} + +connection "azure_sub_3" { + plugin = "azure" + subscription_id = "azure_03" +} +``` + +Depending on the mode of authentication, a multi-subscription configuration can also look like: +```hcl +connection "azure_all" { + type = "aggregator" + plugin = "azure" + connections = ["azure_*"] +} + +connection "azure_sub_1" { + plugin = "azure" + tenant_id = "00000000-0000-0000-0000-000000000000" + subscription_id = "00000000-0000-0000-0000-000000000000" + client_id = "00000000-0000-0000-0000-000000000000" + client_secret = "~dummy@3password" +} + +connection "azure_sub_2" { + plugin = "azure" + tenant_id = "00000000-0000-0000-0000-000000000000" + subscription_id = "00000000-0000-0000-0000-000000000000" + client_id = "00000000-0000-0000-0000-000000000000" + client_secret = "~dummy@3password" +} +``` + +Each connection is implemented as a distinct [Postgres schema](https://www.postgresql.org/docs/current/ddl-schemas.html). As such, you can use qualified table names to query a specific connection: + +```sql +select * from azure_sub_1.azure_subscription +``` + +Alternatively, can use an unqualified name and it will be resolved according to the [Search Path](https://steampipe.io/docs/using-steampipe/managing-connections#setting-the-search-path): +```sql +select * from azure_subscription +``` + +You can multi-account connections by using an [**aggregator** connection](https://steampipe.io/docs/using-steampipe/managing-connections#using-aggregators). Aggregators allow you to query data from multiple connections for a plugin as if they are a single connection: + +```hcl +connection "azure_all" { + plugin = "azure" + type = "aggregator" + connections = ["azure_sub_1", "azure_sub_2", "azure_sub_3"] +} +``` + +Querying tables from this connection will return results from the `azure_sub_1`, `azure_sub_2`, and `azure_sub_3` connections: +```sql +select * from azure_all.azure_subscription +``` + +Steampipe supports the `*` wildcard in the connection names. For example, to aggregate all the Azure plugin connections whose names begin with `azure_`: + +```hcl +connection "azure_all" { + type = "aggregator" + plugin = "azure" + connections = ["azure_*"] +} +``` + ## Get involved - Open source: https://github.com/turbot/steampipe-plugin-azure From a31242fe2b2a3517edf2e0e2f05d78a8fc38d647 Mon Sep 17 00:00:00 2001 From: misraved Date: Mon, 7 Nov 2022 21:38:48 +0530 Subject: [PATCH 2/2] Update docs per review comments --- docs/index.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/docs/index.md b/docs/index.md index e0dcfaa3..7f4fc7eb 100644 --- a/docs/index.md +++ b/docs/index.md @@ -112,9 +112,10 @@ connection "azure" { } ``` -## Specify multiple subscriptions +## Multi-Subscription Connections You may create multiple azure connections: + ```hcl connection "azure_all" { type = "aggregator" @@ -139,6 +140,7 @@ connection "azure_sub_3" { ``` Depending on the mode of authentication, a multi-subscription configuration can also look like: + ```hcl connection "azure_all" { type = "aggregator" @@ -163,18 +165,19 @@ connection "azure_sub_2" { } ``` -Each connection is implemented as a distinct [Postgres schema](https://www.postgresql.org/docs/current/ddl-schemas.html). As such, you can use qualified table names to query a specific connection: +Each connection is implemented as a distinct [Postgres schema](https://www.postgresql.org/docs/current/ddl-schemas.html). As such, you can use qualified table names to query a specific connection: ```sql select * from azure_sub_1.azure_subscription ``` -Alternatively, can use an unqualified name and it will be resolved according to the [Search Path](https://steampipe.io/docs/using-steampipe/managing-connections#setting-the-search-path): +Alternatively, you can use an unqualified name and it will be resolved according to the [Search Path](https://steampipe.io/docs/using-steampipe/managing-connections#setting-the-search-path): + ```sql select * from azure_subscription ``` -You can multi-account connections by using an [**aggregator** connection](https://steampipe.io/docs/using-steampipe/managing-connections#using-aggregators). Aggregators allow you to query data from multiple connections for a plugin as if they are a single connection: +You can create multi-subscription connections by using an [**aggregator** connection](https://steampipe.io/docs/using-steampipe/managing-connections#using-aggregators). Aggregators allow you to query data from multiple connections for a plugin as if they are a single connection: ```hcl connection "azure_all" { @@ -185,6 +188,7 @@ connection "azure_all" { ``` Querying tables from this connection will return results from the `azure_sub_1`, `azure_sub_2`, and `azure_sub_3` connections: + ```sql select * from azure_all.azure_subscription ``` @@ -199,11 +203,6 @@ connection "azure_all" { } ``` -## Get involved - -- Open source: https://github.com/turbot/steampipe-plugin-azure -- Community: [Slack Channel](https://steampipe.io/community/join) - ## Configuring Azure Credentials The Azure plugin support multiple formats/authentication mechanisms and they are tried in the below order: @@ -326,3 +325,8 @@ connection "azure" { plugin = "azure" } ``` + +## Get involved + +- Open source: https://github.com/turbot/steampipe-plugin-azure +- Community: [Slack Channel](https://steampipe.io/community/join) \ No newline at end of file