Last active
July 31, 2020 18:27
-
-
Save zmilleson/822bceebdaa4908ff4562a350cbcf44e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This takes the Contributor role and creates a new Terraform Contributor role. | |
# It can do everything that the contributor can do but also create resource locks and assign roles for permissions to resources. | |
$subscriptionId = Read-Host -Prompt "Input the Subscription ID." | |
$subObj = Get-AzSubscription -SubscriptionId $subscriptionId | |
$role = Get-AzRoleDefinition -Name "Contributor" | |
$role.Name = "Terraform "+$subObj.Name+" Contributor" | |
$role.Description = "Adds the ability to Add Resource Locks to resources along with the normal Contributor actions." | |
$role.Actions.Add("Microsoft.Authorization/locks/*") | |
$role.NotActions.Remove("Microsoft.Authorization/*/Write") | |
$role.AssignableScopes.Clear() | |
$role.AssignableScopes.Add("/subscriptions/$subscriptionId") | |
New-AzRoleDefinition -Role $role |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment