Hi Brandon, thanks for getting back to me with the reference to the Resource Groups API.
I have tried this out and can confirm that I can both read and write to the resource group but note that when writing to the group, there is no endpoint available for adding or deleting individual “objects”. Unless you can point me to the appropriate API endpoint, as far as I can see you are required to provide the entire list of objects every time you want to update the resource group.
Unfortunately this does not work when trying to add all of our domains to the resource group and the API returns a 500 “Internal Server” error.
This is an example of setting a small number of domains:
PUT accounts/0f6a7a9d5f0effe679873e8827bf4e3d/iam/resource_groups/545ec699c6784b2da92c9dc1456e5019
{
"scope": {
"key": "com.cloudflare.api.account.0f6a7a9d5f0effe679873e8827bf4e3d",
"objects": [
{
"key": "com.cloudflare.api.account.zone.85fa4a346804940b59b9410cd635c2e8"
},
{
"key": "com.cloudflare.api.account.zone.6c95c37ca1dd7e08cc8155ef9e161f10"
},
{
"key": "com.cloudflare.api.account.zone.41332351b65e80c54c02ced2a643f78b"
},
{
"key": "com.cloudflare.api.account.zone.ddd0f18362cfbc6429f911a3889f97e2"
},
{
"key": "com.cloudflare.api.account.zone.f7bd9660c3b032e93623af89f97c98c2"
},
{
"key": "com.cloudflare.api.account.zone.bca10462e61fcab4895cae96b356d9d1"
}
]
}
}
{
"result": {
"id": "545ec699c6784b2da92c9dc1456e5019",
"name": "All Domain Group",
"status": "V",
"created_on": "2024-08-15T08:23:11.991725Z",
"modified_on": "2024-08-19T11:40:44.46143Z",
"scope": {
"key": "com.cloudflare.api.account.0f6a7a9d5f0effe679873e8827bf4e3d",
"objects": [
{
"key": "com.cloudflare.api.account.zone.85fa4a346804940b59b9410cd635c2e8"
},
{
"key": "com.cloudflare.api.account.zone.6c95c37ca1dd7e08cc8155ef9e161f10"
},
{
"key": "com.cloudflare.api.account.zone.41332351b65e80c54c02ced2a643f78b"
},
{
"key": "com.cloudflare.api.account.zone.ddd0f18362cfbc6429f911a3889f97e2"
},
{
"key": "com.cloudflare.api.account.zone.f7bd9660c3b032e93623af89f97c98c2"
},
{
"key": "com.cloudflare.api.account.zone.bca10462e61fcab4895cae96b356d9d1"
}
]
}
},
"success": true,
"errors": [],
"messages": []
}
But if I try to add all of our domains I get:
PUT accounts/0f6a7a9d5f0effe679873e8827bf4e3d/iam/resource_groups/545ec699c6784b2da92c9dc1456e5019
{
// record with over 6000 "objects" deleted to save space
}
{
"result": [],
"success": false,
"errors": [
{
"code": 500,
"message": "Internal Server Error"
}
],
"messages": []
}
I don’t know if you have any suggestions, but even of the above worked, it would still be completely unusable due to race conditions. This is because updating the groups would require that api code reads the group, modifies it, and then updates the group. This clearly suffers from a fatal race condition that will manifest when two people try to update the group at roughly the same time.
Thanks for your time.