I am fairly new in Azure and Terraform, and am trying to create a secret client for Azure Service Principal using Terraform. I am unable to figure this out.
This is what I have right now:
provider "azuread" {
version = "=0.7.0"
client_id = var.aws_client_id
subscription_id = var.aws_subscription_id
tenant_id = var.aws_tenant_id
client_secret = var.aws_client_secret
}
# Create an application
resource "azuread_application" "app" {
name = var.azurerd_app_name
}
# Create a service principal
resource "azuread_service_principal" "app" {
application_id = azuread_application.app.application_id
}
This is what I was trying(Not very sure about it):
resource "random_string" "password" {
length = 32
special = true
}
# Create Service Principal password
resource "azuread_service_principal_password" "app" {
end_date = "2299-12-30T23:00:00Z" # Forever
service_principal_id = azuread_service_principal.app.id
value = random_string.password.result
}
This, obviously, doesn't work. This is not giving any error, but, no secret is visible on Azure console. Looks like this is for attaching some password to service principal but I am not very sure what it is doing.
Please let me know what could be done regarding this. Any help would be appreciated. Thanks
terraform output
to get the password when I have thisresource "azuread_service_principal_password" "app" { service_principal_id = azuread_service_principal.app.id } output "sp_password" { value = azuread_service_principal_password.app.value sensitive = true }
– Aracelyaraceous