Azure / Azure/azure-rest-api-specs

[Role Definitions] API Updates is eventually consistent

Open
#2,135 6 comments 0 reactions 0 assignees View on GitHub
ARM - RBAC Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
3d 2h
Merged PRs (30d)
424

Description

:wave:

Terraform recently added support for [managing Role Definitions](https://www.terraform.io/docs/providers/azurerm/r/role_definition.html) (which uses the Azure API's via the Azure SDK for Go).

Generally speaking this works well - however we've discovered that [the Read/GET API](https://docs.microsoft.com/en-us/rest/api/authorization/RoleDefinitions/Get) is eventually consistent for Updates - as shown in the following API Responses which were taken ~10 seconds apart:

Request 1:
```
{
"properties": {
"roleName": "tom-custom-tf",
"type": "CustomRole",
"description": "This is a custom role created via Terraform",
"assignableScopes": ["/subscriptions/00000000-0000-0000-0000-000000000000"],
"permissions": [{
"actions": ["*"],
"notActions": ["Microsoft.Authorization/*/read"]
}],
"createdOn": "2017-12-12T15:43:36.7863750Z",
"updatedOn": "2017-12-12T15:45:48.1361754Z",
"createdBy": "00000000-0000-0000-0000-000000000000",
"updatedBy": "00000000-0000-0000-0000-000000000000"
},
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/00000000-0000-0000-0000-000000000000",
"type": "Microsoft.Authorization/roleDefinitions",
"name": "00000000-0000-0000-0000-000000000000"
}
```

Request 2:
```
{
"properties": {
"roleName": "tom-custom-tf",
"type": "CustomRole",
"description": "This is a custom role created via Terraform",
"assignableScopes": ["/subscriptions/00000000-0000-0000-0000-000000000000"],
"permissions": [{
"actions": ["*"],
"notActions": []
}],
"createdOn": "2017-12-12T15:43:36.7863750Z",
"updatedOn": "2017-12-12T15:43:36.7863750Z",
"createdBy": "00000000-0000-0000-0000-000000000000",
"updatedBy": "00000000-0000-0000-0000-000000000000"
},
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/00000000-0000-0000-0000-000000000000",
"type": "Microsoft.Authorization/roleDefinitions",
"name": "00000000-0000-0000-0000-000000000000"
}
```

Request 3:
```
{
"properties": {
"roleName": "tom-custom-tf",
"type": "CustomRole",
"description": "This is a custom role created via Terraform",
"assignableScopes": ["/subscriptions/00000000-0000-0000-0000-000000000000"],
"permissions": [{
"actions": ["*"],
"notActions": ["Microsoft.Authorization/*/read"]
}],
"createdOn": "2017-12-12T15:43:36.7863750Z",
"updatedOn": "2017-12-12T15:45:48.1361754Z",
"createdBy": "00000000-0000-0000-0000-000000000000",
"updatedBy": "00000000-0000-0000-0000-000000000000"
},
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/00000000-0000-0000-0000-000000000000",
"type": "Microsoft.Authorization/roleDefinitions",
"name": "00000000-0000-0000-0000-000000000000"
}
```

Request 4:
```
{
"properties": {
"roleName": "tom-custom-tf",
"type": "CustomRole",
"description": "This is a custom role created via Terraform",
"assignableScopes": ["/subscriptions/00000000-0000-0000-0000-000000000000"],
"permissions": [{
"actions": ["*"],
"notActions": []
}],
"createdOn": "2017-12-12T15:43:36.7863750Z",
"updatedOn": "2017-12-12T15:43:36.7863750Z",
"createdBy": "00000000-0000-0000-0000-000000000000",
"updatedBy": "00000000-0000-0000-0000-000000000000"
},
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleDefinitions/00000000-0000-0000-0000-000000000000",
"type": "Microsoft.Authorization/roleDefinitions",
"name": "00000000-0000-0000-0000-000000000000"
}
```

Whilst we can look into checking the `UpdatedOn` field as a workaround in the short-term - would it be possible to look into fixing the API so that it's consistent across API responses? I feel this API in particular needs to be consistent seeing as it's Identity/Security related?

Thanks!

Contributor guide

Open the contributing guide

Research direction

The report points to the Azure Role Definitions Get API and Terraform's azurerm_role_definition resource, with the Azure SDK for Go involved; begin by reviewing those API and provider entry points and the four sample responses. Done means determining whether the REST API or its specification can guarantee consistent update responses, then documenting or addressing the identified behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, go
Domain
api, authorization, cloud, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.