@@ -77,12 +77,19 @@ data "azuread_service_principal" "msgraph" {
77
77
// ---------------------------------------------------------------------------
78
78
// Create New application in Microsoft Entra ID
79
79
// ---------------------------------------------------------------------------
80
+ data "azuread_application_template" "enterprise_app" {
81
+ # will create the application based on this template ID to have features like Provisioning
82
+ # available in the enterprise application
83
+ template_id = " 8adf8e6e-67b2-4cf2-a259-e3dc5476c621"
84
+ }
80
85
resource "azuread_application" "meshcloud_replicator" {
81
86
display_name = " replicator.${ var . service_principal_name_suffix } "
82
-
87
+ template_id = data . azuread_application_template . enterprise_app . template_id
83
88
feature_tags {
84
89
enterprise = true
85
90
}
91
+
92
+
86
93
web {
87
94
implicit_grant {
88
95
access_token_issuance_enabled = false
@@ -152,21 +159,16 @@ resource "azuread_application_password" "application_pw" {
152
159
// ---------------------------------------------------------------------------
153
160
resource "azuread_service_principal" "meshcloud_replicator" {
154
161
application_id = azuread_application. meshcloud_replicator . application_id
155
- # The following tags are needed to create an Enterprise Application
156
- # See https://github.com/hashicorp/terraform-provider-azuread/issues/7#issuecomment-529597534
157
- # tags = [
158
- # "WindowsAzureActiveDirectoryIntegratedApp",
159
- # ]
162
+ feature_tags {
163
+ enterprise = true
164
+ }
165
+ # creating an application base on the template, makes a enterprise application being created
166
+ # to use that enterprise application we have to include use_existing line.
167
+ # there is caveat here, if an error happens during destorying this enterprise app, Terraform
168
+ # might not display it https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/service_principal#use_existing
169
+ use_existing = true
160
170
}
161
171
162
- # //---------------------------------------------------------------------------
163
- # // Generate new password for the service principal
164
- # //---------------------------------------------------------------------------
165
- # resource "azuread_service_principal_password" "service_principal_pw" {
166
- # service_principal_id = azuread_service_principal.meshcloud_replicator.id
167
- # end_date = "2999-01-01T01:02:03Z" # no expiry
168
- # }
169
-
170
172
// ---------------------------------------------------------------------------
171
173
// Assign the created ARM role to the Enterprise application
172
174
// ---------------------------------------------------------------------------
@@ -236,15 +238,3 @@ resource "azurerm_management_group_policy_assignment" "privilege-escalation-prev
236
238
policy_definition_id = azurerm_policy_definition. privilege_escalation_prevention . id
237
239
management_group_id = var. scope
238
240
}
239
-
240
- # Terraform does not find the blueprint service principal, even though I find it with
241
- # ` az ad sp list --filter "appId eq 'f71766dc-90d9-4b7d-bd9d-4499c4331c3f'"`
242
- # data "azuread_application" "blueprint_service_principal" {
243
- # application_id = "f71766dc-90d9-4b7d-bd9d-4499c4331c3f"
244
- # }
245
-
246
- # facilitate migration from v0.1.0 of the module
247
- # moved {
248
- # from = azuread_application_password.spp_pw
249
- # to = azuread_application_password.service_principal_pw
250
- # }
0 commit comments