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 support to query identity settings in App Service > Web App. closes #54 #90

Merged
merged 5 commits into from
May 4, 2021

Conversation

Paulami30
Copy link
Contributor

Integration test logs

Logs
No env file present for the current environment:  staging 
 Falling back to .env config
No env file present for the current environment:  staging
customEnv TURBOT_TEST_EXPECTED_TIMEOUT undefined

SETUP: tests/azure_app_service_web_app []

PRETEST: tests/azure_app_service_web_app

TEST: tests/azure_app_service_web_app
Running terraform
data.azurerm_client_config.current: Refreshing state...
data.null_data_source.resource: Refreshing state...
azurerm_resource_group.named_test_resource: Creating...
azurerm_resource_group.named_test_resource: Creation complete after 3s [id=/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40279]
azurerm_app_service_plan.named_test_resource: Creating...
azurerm_storage_account.named_test_resource: Creating...
azurerm_app_service_plan.named_test_resource: Still creating... [10s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [10s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [20s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [20s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [30s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [30s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [40s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [40s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [50s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [50s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [1m0s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [1m0s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [1m10s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [1m10s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [1m20s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [1m20s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [1m30s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [1m30s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [1m40s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [1m40s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [1m50s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [1m50s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [2m0s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [2m0s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [2m10s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [2m10s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [2m20s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [2m20s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [2m30s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [2m30s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [2m40s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [2m40s elapsed]
azurerm_app_service_plan.named_test_resource: Still creating... [2m50s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [2m50s elapsed]
azurerm_app_service_plan.named_test_resource: Creation complete after 2m58s [id=/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40279/providers/Microsoft.Web/serverfarms/turbottest40279]
azurerm_app_service.named_test_resource: Creating...
azurerm_storage_account.named_test_resource: Still creating... [3m0s elapsed]
azurerm_storage_account.named_test_resource: Creation complete after 3m3s [id=/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40279/providers/Microsoft.Storage/storageAccounts/turbottest40279]
azurerm_app_service.named_test_resource: Still creating... [10s elapsed]
azurerm_app_service.named_test_resource: Still creating... [20s elapsed]
azurerm_app_service.named_test_resource: Still creating... [30s elapsed]
azurerm_app_service.named_test_resource: Still creating... [40s elapsed]
azurerm_app_service.named_test_resource: Still creating... [50s elapsed]
azurerm_app_service.named_test_resource: Still creating... [1m0s elapsed]
azurerm_app_service.named_test_resource: Creation complete after 1m2s [id=/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40279/providers/Microsoft.Web/sites/turbottest40279]

Warning: Deprecated Resource

The null_data_source was historically used to construct intermediate values to
re-use elsewhere in configuration, the same can now be achieved using locals


Apply complete! Resources: 4 added, 0 changed, 0 destroyed.

Outputs:

resource_aka = azure:///subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40279/providers/Microsoft.Web/sites/turbottest40279
resource_aka_lower = azure:///subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourcegroups/turbottest40279/providers/microsoft.web/sites/turbottest40279
resource_id = /subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40279/providers/Microsoft.Web/sites/turbottest40279
resource_name = turbottest40279
subscription_id = cd4401c4-3cc8-4565-a594-839c1e345f1e

Running SQL query: test-get-query.sql
[
  {
    "client_affinity_enabled": false,
    "enabled": true,
    "https_only": false,
    "id": "/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40279/providers/Microsoft.Web/sites/turbottest40279",
    "identity_type": "SystemAssigned",
    "kind": "app",
    "name": "turbottest40279",
    "region": "east us",
    "reserved": false,
    "resource_group": "turbottest40279"
  }
]
✔ PASSED

Running SQL query: test-hydrate-query.sql
[
  {
    "client_affinity_enabled": false,
    "enabled": true,
    "https_only": false,
    "id": "/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40279/providers/Microsoft.Web/sites/turbottest40279",
    "kind": "app",
    "name": "turbottest40279",
    "region": "east us",
    "resource_group": "turbottest40279"
  }
]
✔ PASSED

Running SQL query: test-list-query.sql
[
  {
    "id": "/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40279/providers/Microsoft.Web/sites/turbottest40279",
    "identity_type": "SystemAssigned",
    "name": "turbottest40279"
  }
]
✔ PASSED

Running SQL query: test-not-found-query.sql
null
✔ PASSED

Running SQL query: test-turbot-query.sql
[
  {
    "akas": [
      "azure:///subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40279/providers/Microsoft.Web/sites/turbottest40279",
      "azure:///subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourcegroups/turbottest40279/providers/microsoft.web/sites/turbottest40279"
    ],
    "name": "turbottest40279",
    "tags": {
      "name": "turbottest40279"
    },
    "title": "turbottest40279"
  }
]
✔ PASSED

POSTTEST: tests/azure_app_service_web_app

TEARDOWN: tests/azure_app_service_web_app

SUMMARY:

1/1 passed.

@Paulami30 Paulami30 requested a review from Subhajit97 April 9, 2021 13:57
@Paulami30 Paulami30 self-assigned this Apr 9, 2021
@Subhajit97 Subhajit97 linked an issue Apr 16, 2021 that may be closed by this pull request
Copy link
Contributor

@Subhajit97 Subhajit97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Subhajit97 Subhajit97 requested a review from cbruno10 April 16, 2021 06:54
@@ -88,6 +88,24 @@ func tableAzureAppServiceWebApp(_ context.Context) *plugin.Table {
Type: proto.ColumnType_BOOL,
Transform: transform.FromField("SiteProperties.HTTPSOnly"),
},
{
Name: "identity_type",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Paulami30 Since there aren't that many fields here, and identity information is easy to find, would this work if we just had an identity column with the JSON type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we fetch the whole identity column, we do not get the data. That is why I had to fetch the keys from the object.

Copy link
Contributor

@cbruno10 cbruno10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Paulami30 Similar to how we handle the response data format in the azure_firewall table, could we handle it similar to https://github.com/turbot/steampipe-plugin-azure/blob/main/azure/table_azure_firewall.go#L247 and condense the data into an identity column?

@cbruno10 cbruno10 assigned sayan133 and unassigned Paulami30 Apr 23, 2021
@sayan133
Copy link
Contributor

sayan133 commented Apr 23, 2021

Integration test logs

Logs
No env file present for the current environment:  staging 
 Falling back to .env config
No env file present for the current environment:  staging
customEnv TURBOT_TEST_EXPECTED_TIMEOUT undefined

SETUP: tests/azure_app_service_web_app []

PRETEST: tests/azure_app_service_web_app

TEST: tests/azure_app_service_web_app
Running terraform
azurerm_resource_group.named_test_resource: Creating...
azurerm_resource_group.named_test_resource: Creation complete after 2s [id=/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40092]
azurerm_app_service_plan.named_test_resource: Creating...
azurerm_storage_account.named_test_resource: Creating...
azurerm_app_service_plan.named_test_resource: Still creating... [10s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [10s elapsed]
azurerm_app_service_plan.named_test_resource: Creation complete after 13s [id=/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40092/providers/Microsoft.Web/serverfarms/turbottest40092]
azurerm_app_service.named_test_resource: Creating...
azurerm_storage_account.named_test_resource: Still creating... [20s elapsed]
azurerm_app_service.named_test_resource: Still creating... [10s elapsed]
azurerm_storage_account.named_test_resource: Still creating... [30s elapsed]
azurerm_storage_account.named_test_resource: Creation complete after 33s [id=/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40092/providers/Microsoft.Storage/storageAccounts/turbottest40092]
azurerm_app_service.named_test_resource: Still creating... [20s elapsed]
azurerm_app_service.named_test_resource: Still creating... [30s elapsed]
azurerm_app_service.named_test_resource: Still creating... [40s elapsed]
azurerm_app_service.named_test_resource: Still creating... [50s elapsed]
azurerm_app_service.named_test_resource: Creation complete after 55s [id=/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40092/providers/Microsoft.Web/sites/turbottest40092]

Warning: Deprecated Resource

The null_data_source was historically used to construct intermediate values to
re-use elsewhere in configuration, the same can now be achieved using locals


Warning: Version constraints inside provider configuration blocks are deprecated

  on variables.tf line 22, in provider "azurerm":
  22:   version = "=2.41.0"

Terraform 0.13 and earlier allowed provider version constraints inside the
provider configuration block, but that is now deprecated and will be removed
in a future version of Terraform. To silence this warning, move the provider
version constraint into the required_providers block.


Apply complete! Resources: 4 added, 0 changed, 0 destroyed.

Outputs:

principal_id = "c283b9c3-b94f-492d-8504-44baed33cf34"
resource_aka = "azure:///subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40092/providers/Microsoft.Web/sites/turbottest40092"
resource_aka_lower = "azure:///subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourcegroups/turbottest40092/providers/microsoft.web/sites/turbottest40092"
resource_id = "/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40092/providers/Microsoft.Web/sites/turbottest40092"
resource_name = "turbottest40092"
subscription_id = "cd4401c4-3cc8-4565-a594-839c1e345f1e"
tenant_id = "cdffd708-7da0-4cea-abeb-0a4c334d7f64"

Running SQL query: test-get-query.sql
[
  {
    "client_affinity_enabled": false,
    "enabled": true,
    "https_only": false,
    "id": "/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40092/providers/Microsoft.Web/sites/turbottest40092",
    "identity": {
      "PrincipalID": "c283b9c3-b94f-492d-8504-44baed33cf34",
      "TenantID": "cdffd708-7da0-4cea-abeb-0a4c334d7f64",
      "Type": "SystemAssigned"
    },
    "kind": "app",
    "name": "turbottest40092",
    "region": "east us",
    "reserved": false,
    "resource_group": "turbottest40092"
  }
]
✔ PASSED

Running SQL query: test-hydrate-query.sql
[
  {
    "client_affinity_enabled": false,
    "enabled": true,
    "https_only": false,
    "id": "/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40092/providers/Microsoft.Web/sites/turbottest40092",
    "kind": "app",
    "name": "turbottest40092",
    "region": "east us",
    "resource_group": "turbottest40092"
  }
]
✔ PASSED

Running SQL query: test-list-query.sql
[
  {
    "id": "/subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40092/providers/Microsoft.Web/sites/turbottest40092",
    "identity": {
      "PrincipalID": "c283b9c3-b94f-492d-8504-44baed33cf34",
      "TenantID": "cdffd708-7da0-4cea-abeb-0a4c334d7f64",
      "Type": "SystemAssigned"
    },
    "name": "turbottest40092"
  }
]
✔ PASSED

Running SQL query: test-not-found-query.sql
null
✔ PASSED

Running SQL query: test-turbot-query.sql
[
  {
    "akas": [
      "azure:///subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourceGroups/turbottest40092/providers/Microsoft.Web/sites/turbottest40092",
      "azure:///subscriptions/cd4401c4-3cc8-4565-a594-839c1e345f1e/resourcegroups/turbottest40092/providers/microsoft.web/sites/turbottest40092"
    ],
    "name": "turbottest40092",
    "tags": {
      "name": "turbottest40092"
    },
    "title": "turbottest40092"
  }
]
✔ PASSED

POSTTEST: tests/azure_app_service_web_app

TEARDOWN: tests/azure_app_service_web_app

SUMMARY:

1/1 passed.

@sayan133 sayan133 requested a review from Subhajit97 April 26, 2021 07:06
@sayan133 sayan133 requested review from Subhajit97 and cbruno10 April 30, 2021 11:10
Copy link
Contributor

@Subhajit97 Subhajit97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sayan133
Copy link
Contributor

sayan133 commented May 3, 2021

New Query Example

List web apps that have managed service identity set to disabled

select
  name,
  enabled,
  region,
  identity
from
  azure_app_service_web_app
where
  identity = '{}';
+--------+---------+------------+----------+
| name   | enabled | region     | identity |
+--------+---------+------------+----------+
| del-me | true    | central us | {}       |
+--------+---------+------------+----------+

Copy link
Contributor

@rajlearner17 rajlearner17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cbruno10 cbruno10 merged commit 8439e39 into main May 4, 2021
@cbruno10 cbruno10 deleted the issue-54 branch May 4, 2021 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to query identity settings in App Service > Web App
5 participants