diff --git a/azure-test/tests/azure_app_service_web_app/test-get-expected.json b/azure-test/tests/azure_app_service_web_app/test-get-expected.json index 2d31cd15..b8606b79 100644 --- a/azure-test/tests/azure_app_service_web_app/test-get-expected.json +++ b/azure-test/tests/azure_app_service_web_app/test-get-expected.json @@ -4,10 +4,15 @@ "enabled": true, "https_only": false, "id": "{{ output.resource_id.value }}", + "identity": { + "PrincipalID": "{{ output.principal_id.value }}", + "TenantID": "{{ output.tenant_id.value }}", + "Type": "SystemAssigned" + }, "kind": "app", "name": "{{resourceName}}", - "region": "East US", + "region": "east us", "reserved": false, "resource_group": "{{resourceName}}" } -] \ No newline at end of file +] diff --git a/azure-test/tests/azure_app_service_web_app/test-get-query.sql b/azure-test/tests/azure_app_service_web_app/test-get-query.sql index 768ecd83..356f66f4 100644 --- a/azure-test/tests/azure_app_service_web_app/test-get-query.sql +++ b/azure-test/tests/azure_app_service_web_app/test-get-query.sql @@ -1,3 +1,3 @@ -select name, id, kind, region, client_affinity_enabled, enabled, https_only, reserved, resource_group +select name, id, kind, region, client_affinity_enabled, enabled, https_only, reserved, resource_group, identity from azure.azure_app_service_web_app -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_app_service_web_app/test-hydrate-expected.json b/azure-test/tests/azure_app_service_web_app/test-hydrate-expected.json index a70dd4f5..00562d52 100644 --- a/azure-test/tests/azure_app_service_web_app/test-hydrate-expected.json +++ b/azure-test/tests/azure_app_service_web_app/test-hydrate-expected.json @@ -6,7 +6,7 @@ "id": "{{ output.resource_id.value }}", "kind": "app", "name": "{{resourceName}}", - "region": "East US", + "region": "east us", "resource_group": "{{resourceName}}" } -] \ No newline at end of file +] diff --git a/azure-test/tests/azure_app_service_web_app/test-hydrate-query.sql b/azure-test/tests/azure_app_service_web_app/test-hydrate-query.sql index 0e2d849a..9598089e 100644 --- a/azure-test/tests/azure_app_service_web_app/test-hydrate-query.sql +++ b/azure-test/tests/azure_app_service_web_app/test-hydrate-query.sql @@ -1,3 +1,3 @@ select name, id, kind, region, client_affinity_enabled, enabled, https_only, resource_group from azure.azure_app_service_web_app -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_app_service_web_app/test-list-expected.json b/azure-test/tests/azure_app_service_web_app/test-list-expected.json index db8cea80..3fcf5db4 100644 --- a/azure-test/tests/azure_app_service_web_app/test-list-expected.json +++ b/azure-test/tests/azure_app_service_web_app/test-list-expected.json @@ -1,6 +1,11 @@ [ { "id": "{{ output.resource_id.value }}", + "identity": { + "PrincipalID": "{{ output.principal_id.value }}", + "TenantID": "{{ output.tenant_id.value }}", + "Type": "SystemAssigned" + }, "name": "{{resourceName}}" } -] \ No newline at end of file +] diff --git a/azure-test/tests/azure_app_service_web_app/test-list-query.sql b/azure-test/tests/azure_app_service_web_app/test-list-query.sql index 56291973..9df13945 100644 --- a/azure-test/tests/azure_app_service_web_app/test-list-query.sql +++ b/azure-test/tests/azure_app_service_web_app/test-list-query.sql @@ -1,3 +1,3 @@ -select id, name +select id, name, identity from azure.azure_app_service_web_app -where name = '{{resourceName}}' +where name = '{{resourceName}}'; \ No newline at end of file diff --git a/azure-test/tests/azure_app_service_web_app/test-not-found-expected.json b/azure-test/tests/azure_app_service_web_app/test-not-found-expected.json index ec747fa4..19765bd5 100644 --- a/azure-test/tests/azure_app_service_web_app/test-not-found-expected.json +++ b/azure-test/tests/azure_app_service_web_app/test-not-found-expected.json @@ -1 +1 @@ -null \ No newline at end of file +null diff --git a/azure-test/tests/azure_app_service_web_app/test-not-found-query.sql b/azure-test/tests/azure_app_service_web_app/test-not-found-query.sql index f96dac64..2d699867 100644 --- a/azure-test/tests/azure_app_service_web_app/test-not-found-query.sql +++ b/azure-test/tests/azure_app_service_web_app/test-not-found-query.sql @@ -1,3 +1,3 @@ select name, id from azure.azure_app_service_web_app -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_app_service_web_app/test-turbot-expected.json b/azure-test/tests/azure_app_service_web_app/test-turbot-expected.json index 3ceae2f7..82954714 100644 --- a/azure-test/tests/azure_app_service_web_app/test-turbot-expected.json +++ b/azure-test/tests/azure_app_service_web_app/test-turbot-expected.json @@ -10,4 +10,4 @@ }, "title": "{{resourceName}}" } -] \ No newline at end of file +] diff --git a/azure-test/tests/azure_app_service_web_app/test-turbot-query.sql b/azure-test/tests/azure_app_service_web_app/test-turbot-query.sql index ef1fdf6d..b1ddeb8e 100644 --- a/azure-test/tests/azure_app_service_web_app/test-turbot-query.sql +++ b/azure-test/tests/azure_app_service_web_app/test-turbot-query.sql @@ -1,3 +1,3 @@ select name, akas, title, tags from azure.azure_app_service_web_app -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_app_service_web_app/variables.tf b/azure-test/tests/azure_app_service_web_app/variables.tf index fefce150..6432d582 100644 --- a/azure-test/tests/azure_app_service_web_app/variables.tf +++ b/azure-test/tests/azure_app_service_web_app/variables.tf @@ -62,6 +62,9 @@ resource "azurerm_app_service" "named_test_resource" { location = azurerm_resource_group.named_test_resource.location resource_group_name = azurerm_resource_group.named_test_resource.name app_service_plan_id = azurerm_app_service_plan.named_test_resource.id + identity { + type = "SystemAssigned" + } tags = { name = var.resource_name @@ -87,3 +90,11 @@ output "resource_id" { output "subscription_id" { value = var.azure_subscription } + +output "tenant_id" { + value = azurerm_app_service.named_test_resource.identity[0].tenant_id +} + +output "principal_id" { + value = azurerm_app_service.named_test_resource.identity[0].principal_id +} \ No newline at end of file diff --git a/azure/table_azure_app_service_web_app.go b/azure/table_azure_app_service_web_app.go index 427753b9..ec15d021 100644 --- a/azure/table_azure_app_service_web_app.go +++ b/azure/table_azure_app_service_web_app.go @@ -88,6 +88,12 @@ func tableAzureAppServiceWebApp(_ context.Context) *plugin.Table { Type: proto.ColumnType_BOOL, Transform: transform.FromField("SiteProperties.HTTPSOnly"), }, + { + Name: "identity", + Description: "Managed service identity for the resource.", + Type: proto.ColumnType_JSON, + Transform: transform.From(webAppIdentity), + }, { Name: "outbound_ip_addresses", Description: "List of IP addresses that the app uses for outbound connections (e.g. database access).", @@ -286,3 +292,25 @@ func getAppServiceWebAppSiteAuthSetting(ctx context.Context, d *plugin.QueryData return op, nil } + +//// TRANSFORM FUNCTION + +func webAppIdentity(ctx context.Context, d *transform.TransformData) (interface{}, error) { + data := d.HydrateItem.(web.Site) + objectMap := make(map[string]interface{}) + if data.Identity != nil { + if &data.Identity.Type != nil { + objectMap["Type"] = data.Identity.Type + } + if data.Identity.TenantID != nil { + objectMap["TenantID"] = data.Identity.TenantID + } + if data.Identity.PrincipalID != nil { + objectMap["PrincipalID"] = data.Identity.PrincipalID + } + if data.Identity.UserAssignedIdentities != nil { + objectMap["UserAssignedIdentities"] = data.Identity.UserAssignedIdentities + } + } + return objectMap, nil +} diff --git a/docs/tables/azure_app_service_web_app.md b/docs/tables/azure_app_service_web_app.md index 745732e6..2f1293a6 100644 --- a/docs/tables/azure_app_service_web_app.md +++ b/docs/tables/azure_app_service_web_app.md @@ -85,3 +85,18 @@ from where configuration -> 'properties' ->> 'ftpsState' <> 'AllAllowed'; ``` + + +### List web apps that have managed service identity disabled + +```sql +select + name, + enabled, + region, + identity +from + azure_app_service_web_app +where + identity = '{}'; +```