From 1ebaed6cc8b9af90a3c55e18eb9c4b02b042189d Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Mon, 7 Mar 2022 21:12:17 +0000 Subject: [PATCH] data.azuread_service_principals: export the object_id attribute in the service_principals list Closes: #735 --- docs/data-sources/service_principals.md | 1 + .../serviceprincipals/service_principals_data_source.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docs/data-sources/service_principals.md b/docs/data-sources/service_principals.md index e8a4be7f9b..47ae4bb176 100644 --- a/docs/data-sources/service_principals.md +++ b/docs/data-sources/service_principals.md @@ -81,6 +81,7 @@ The following attributes are exported: * `application_id` - The application ID (client ID) of the application associated with this service principal. * `application_tenant_id` - The tenant ID where the associated application is registered. * `display_name` - The display name of the application associated with this service principal. +* `object_id` - The object ID of the service principal. * `preferred_single_sign_on_mode` - The single sign-on mode configured for this application. Azure AD uses the preferred single sign-on mode to launch the application from Microsoft 365 or the Azure AD My Apps. * `saml_metadata_url` - The URL where the service exposes SAML metadata for federation. * `service_principal_names` - A list of identifier URI(s), copied over from the associated application. diff --git a/internal/services/serviceprincipals/service_principals_data_source.go b/internal/services/serviceprincipals/service_principals_data_source.go index 63cae7afa9..6624f9dc36 100644 --- a/internal/services/serviceprincipals/service_principals_data_source.go +++ b/internal/services/serviceprincipals/service_principals_data_source.go @@ -118,6 +118,12 @@ func servicePrincipalsDataSource() *schema.Resource { Computed: true, }, + "object_id": { + Description: "The object ID of the service principal", + Type: schema.TypeString, + Computed: true, + }, + "preferred_single_sign_on_mode": { Description: "The single sign-on mode configured for this application. Azure AD uses the preferred single sign-on mode to launch the application from Microsoft 365 or the Azure AD My Apps", Type: schema.TypeString, @@ -296,6 +302,7 @@ func servicePrincipalsDataSourceRead(ctx context.Context, d *schema.ResourceData sp["app_role_assignment_required"] = s.AppRoleAssignmentRequired sp["application_id"] = s.AppId sp["application_tenant_id"] = s.AppOwnerOrganizationId + sp["object_id"] = s.ID sp["preferred_single_sign_on_mode"] = s.PreferredSingleSignOnMode sp["saml_metadata_url"] = s.SamlMetadataUrl sp["service_principal_names"] = servicePrincipalNames