I need to get access to a Function App staging slot in Terraform.
I can get it for its production slot:
data "azurerm_linux_function_app" "my_application" {
name = <app_name>
resource_group_name = <resource_group_name>
}
resource "azurerm_role_assignment" "role_assignment" {
scope = <scope>
role_definition_name = <role_name>
principal_id = data.azurerm_linux_function_app.my_application.identity.0.principal_id
}
For the staging slot, I would have expected to be able to do something similar:
data "azurerm_linux_function_app_slot" "my_app_staging" {
name = <app_name>
resource_group_name = <resource_group_name>
slot_name = "staging"
}
resource "azurerm_role_assignment" "staging_role_assignment" {
scope = <scope>
role_definition_name = <role_name>
principal_id = data.azurerm_linux_function_app_slot.my_app_staging.identity.0.principal_id
}
However I get the following error:
The provider hashicorp/azurerm does not support data source
"azurerm_linux_function_app_slot".
Question
How to get the principal_id
of a Function App’s Staging slot in Terraform?
2
Answers
There is no Support data source for "azurerm_linux_function_app_slot".
these are the available data sources
You can try to import the Function Apps Deployment Slots using the
resource id
, e.gSource: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_function_app_slot
Hope this helps!
That data source is not implemented in the provider as of 3.48.0.
Alternatively, you could use User Assigned identity and use the data source for User Assigned Identity.
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/user_assigned_identity