I have registered a client app from portal and creating oauth2 server through terraform. I am also creating password using below code
resource "azuread_application_password" "example" {
application_object_id = data.azuread_application.example.application_id
}
but "application_object_id" is deprecated
"application_object_id" is deprecated: Reason: "The object ID of the application for which this password should be created"
I am using azurerm version = "~>3.49.0"
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.49.0"
}
azuread = {
source = "hashicorp/azuread"
version = "2.42.0"
}
...
}
}
resource "azurerm_api_management_authorization_server" "server" {
name = "server"
api_management_name = azurerm_api_management.apim.name
resource_group_name = data.azurerm_resource_group.rg.name
display_name = "Oauth2 Authorization server"
description = "OAuth2 Server"
authorization_endpoint = "https://login.microsoftonline.com/${data.azurerm_client_config.current.tenant_id}/oauth2/v2.0/authorize"
token_endpoint = "https://login.microsoftonline.com/${data.azurerm_client_config.current.tenant_id}/oauth2/v2.0/token"
client_id = data.azuread_application.example.application_id
client_secret = azuread_application_password.example.value
grant_types = ["authorizationCode"]
authorization_methods = ["GET", "POST"]
client_registration_endpoint = "https://*************.developer.azure-api.net"
}
How to create secret or use secret from client app using terraform? Is there any way to use secrets while creating server? Thanks in advance!
How to create secret or use secret from client app using terraform? Is there any way to use secrets while creating server?
The application_object_id
was deprecated in version 1.5.0. The latest version, 2.53.1, now supports application_id
instead of application_object_id
. For more details, refer to the Terraform doc
Here is the terraform code to create application secrets/password in Azuread application
provider "azuread" {
}
resource "azuread_application_registration" "example" {
display_name = "venkatsample_app"
}
resource "azuread_application_password" "example" {
application_id = azuread_application_registration.example.id
display_name = "sampletest_secret"
}
output "application_secrets" {
value = azuread_application_password.example.value
sensitive = true
}
Azuread provider version
Terraform apply
After executing the script, secrets have been created in the Azure AD application
.
If you want to use the application secret, you can use it as shown below
azuread_application_password.example.value