CompositionalIT / farmer

Repeatable Azure deployments with ARM templates - made easy!
https://compositionalit.github.io/farmer
MIT License
523 stars 157 forks source link

Update the list of RBAC roles #1001

Closed isaacabraham closed 1 year ago

isaacabraham commented 1 year ago

The changes in this PR are as follows:

I have read the contributing guidelines and have completed the following:

To do this, I extracted all roles:

az role definition list --custom-role-only false --output json --query '[].{roleName:roleName, description:description, name:name}' > roles.json

Then the following script generates the F# that I can copy into the IdentityExtensions.fs file:

#r "nuget:FSharp.Data"

open FSharp.Data

type Roles = JsonProvider<"roles.json">

let samples = Roles.GetSamples()

let output = [
    let samples =
        samples
        |> Seq.sortBy (fun s -> s.RoleName)
        |> Seq.map (fun s ->
            {|
                Name = s.Name
                RoleName =
                    s.RoleName.Replace(" ", "").Replace("(Preview)", "").Replace("Deprecated", "")
                    |> Seq.filter System.Char.IsLetterOrDigit
                    |> Seq.toArray
                    |> System.String
                Description = s.Description
                IsPreview = s.RoleName.Contains "Preview"
                IsDeprecated = s.RoleName.Contains "Deprecated"
            |})

    for sample in samples do
    [
        $"""    /// {sample.Description}{if sample.IsPreview then " (This is a preview role)" else ""}"""
        if sample.IsDeprecated then $"""    [<Obsolete "This role has been deprecated.">]"""
        $"""    let {sample.RoleName} = makeRoleId "{sample.RoleName}" "{sample.Name}" """
    ]
]
System.IO.File.WriteAllLines("output.fsx", output)
isaacabraham commented 1 year ago

It does appear that a few roles that were previously there are no longer (this was just on a spot check e.g. a SignalR one). Is that to be expected @ninjarobot - or am I perhaps using that AZ CLI command incorrectly and it's returning a filtered list of roles?