'Error assigning Synapse role using Terraform

i am trying to assign an in-bulit role in Synapse through Terraform but i get an Error.

This is what I'm trying to do:

resource "azurerm_synapse_role_assignment" "example" {
  synapse_workspace_id = azurerm_synapse_workspace.syn_ws.id
  role_name            = "Synapse Administrator"
  principal_id         = "<user_objectid>"       # alternatively data.azurerm_client_config.current.object_id

  depends_on = [azurerm_synapse_firewall_rule.example]
}

Below is the error generated, it seems like there is authorization missing, but all other steps to create the resource group, storage, workspace etc. work.

Error: listing synapse role definitions accesscontrol.RoleDefinitionsClient#ListRoleDefinitions: Failure sending request: StatusCode=0 -- Original Error: Get "https://synapse-da-dev.dev.azuresynapse.net/roleDefinitions?api-version=2020-08-01-preview&scope=workspaces%2Fsynapse-da-dev": authenticationrequired        
│
│   with module.rg-synapse.azurerm_synapse_role_assignment.example,
│   on ..\modules\rg-synapse\main.tf line 113, in resource "azurerm_synapse_role_assignment" "example":
│  113: resource "azurerm_synapse_role_assignment" "example" {

Any input is greatly appreciated thank you so much!



Solution 1:[1]

check if your terraform agent have access to synapse, if you are blocking all public access to synapse , then add the IP of terraform agent to allowed sources.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tufan