Skip to content

Commit

Permalink
azurerm_role_definition - expose role_definition_resource_id (#8492)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackofallops authored Sep 17, 2020
1 parent e7f7688 commit 0322cbc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import (
"log"
"time"

azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/authorization/parse"

"github.com/Azure/azure-sdk-for-go/services/preview/authorization/mgmt/2018-09-01-preview/authorization"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/authorization/parse"
azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)
Expand Down Expand Up @@ -118,6 +116,11 @@ func resourceArmRoleDefinition() *schema.Resource {
Type: schema.TypeString,
},
},

"role_definition_resource_id": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -196,6 +199,7 @@ func resourceArmRoleDefinitionRead(d *schema.ResourceData, meta interface{}) err

d.Set("scope", roleDefinitionId.Scope)
d.Set("role_definition_id", roleDefinitionId.RoleID)
d.Set("role_definition_resource_id", roleDefinitionId.ResourceID)

resp, err := client.Get(ctx, roleDefinitionId.Scope, roleDefinitionId.RoleID)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ resource "azurerm_role_definition" "test" {
resource "azurerm_role_assignment" "test" {
name = "%s"
scope = data.azurerm_subscription.primary.id
role_definition_id = azurerm_role_definition.test.id
role_definition_id = azurerm_role_definition.test.role_definition_resource_id
principal_id = data.azurerm_client_config.test.object_id
}
`, roleDefinitionId, rInt, roleAssignmentId)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/role_definition.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ The following attributes are exported:

* `id` - The Role Definition ID.

* `role_definition_resource_id` - The Azure Resource Manager ID for the resource

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:
Expand Down

0 comments on commit 0322cbc

Please sign in to comment.