Can I block Inheritance in Azure - azure

can someone please help me with the following question
if I have an Azure Subscription, Resource Group then an Azure Key Vault in that resource group can I block inheritance from the Subscription and Resource group so users with rights at the subscription and resource group level do not automatically inherited the rights (like contributor or owner etc.) to the Key Vault. I see I cannot delete the permissions at the key Vault level as the permissions are inherited. However I may still want someone to have say contributor at the subscription or resource group level but have lesser or no rights on the Key Vault itself
Please advise, thanks in advance
__AAnotherUser

The best solution for what you're looking for might be locks if this is the only resource you want to lock down:
https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-lock-resources
There are also more granular RBAC setups than just giving someone full owner/contributor access:
https://learn.microsoft.com/en-us/azure/active-directory/role-based-access-control-custom-roles

Related

Block inherited permissions to azure resource group

My subscription has a service principal that must have contributor rights. These rights will be inherited by all resource groups. In one resource group that has been established for over a year. for security reasons, this service principal must be prohibited from doing anything. The maximum allowed is reading. I tried using https://learn.microsoft.com/en-us/azure/governance/blueprints/overview but apparently I misconfigured or just doesn't work in my case. Since under the credential of this service principal, I was able to delete the test storage account. Could you please help me set up these policies to see if it's possible or not? Thank you.

Service principal or Managed Identity

I have a client that can only give me full access to one or two resource groups.
I need to deliver some prescripted terraform resources that contain the need for a service principal.
Can you lock an SP to a resource group? The subscription itself is a production subscription so they want to know if you can tie down using role base access just to that group.
Or should I be create a MI account?
Can you lock an SP to a resource group?
You most certainly can. Azure Role-based access control is very granular and you can apply access control at any level (management group, subscription, resource group or even at individual resource).
Please see this for more details: https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-steps.

Azure policy to auto add user group in resource group contributors

This is my first project in Azure. Please avoid if any mistake. I have a user group "Azure Cross Team Contributors". I want to add it in resource group contributors by default whenever I create any resource group. I got to know there is policy, But not able to write policy rule. What would be policy rule for this scenario.
Similar thread answered on Microsoft Q&A , so updating here for broader community usage. Thank you AshishMishra and DCtheGeek for helping on the thread.
Azure Policy lets you audit the compliance of the configuration of Azure Resource Manager (ARM) properties.
In some cases, such as AKS or Guest Configuration, it can also audit configuration of Resource Provider properties. While Azure Policy can be used to audit how a role definition is defined (sample here), it isn't for applying roles to specific objects. That's the domain of Azure role-based access control (RBAC).
If you want the group "Azure Cross Team Contributors" to have access to all resource groups within a subscription, an easier alternative is to grant the role assignment at the subscription scope.
There isn't a built-in role with the name "Resource Group Contributors".
Feel free to revert back if you have any further queries. Thank you.

Terraform with Azure. Access rights best practices

What are the best practices when using Terraform to provision infrastructure on Azure? We are struggling to decide between two variants:
Create one Service principal for Terraform and give it Owner rights to the whole subscription so it can create resource groups for each environment and assign roles to service principals in resources.
Create Resource Groups and service principals for each environment manually and assign terraform's service principal Owner rights to only the Resource Group.
The first option is more convenient, but I'm worried about security concerns when giving Terraform Owner rights on the subscription level.
What would be the best solution?
When you worry about security, there should be a limit to your requirements. If you want to create resources only in one resource group or serial resource groups, and then control them for all things. I'd suggest you create a service principal and assign it the Owner role of the resource group or groups, not the whole subscription. And it's the best way for security and you also have all the rights to control the resources in that group or groups, only limit the scope to that group or groups.
Assign the Owner role to the whole subscription, it's not secure, you know, there would be some mistakes on somebody sometimes.

Azure Owner Role cannot create Resource Group

I am assigned an owner role in my Employer's Azure subscription. He was able to create resource groups, but I can't. We're both wondering why since I was already assigned as Owner, the highest role aside from subscription level.
When I try the az group create --name myGroup -l southeastasia command, its response is
The client 'live.com#<myAccount>#outlook.com' with object id '<object ID>'
does not have authorization to perform action 'Microsoft.Resources/subscriptions/
resourcegroups/write' over scope '/subscriptions/<subscription>/resourcegroups/<myGroup>'.
Edit: I have no subscription level resources
Do you have multiple subscriptions in your tenant? If yes, you should set it.
##list subscription
az account list --output table
##change the active subscription
az account set --subscription "My Demos"
If you only have a subscription, I suggest you could create a sp, then use the sp to create a new resource group. See this link.
Update:
You should give Owner role on subscription level, according to your screenshot, you give Owner role on resource group role, you only create resources in the resource group. You also could not create new resource group. You should give Owner role to your subscription,like below:
Note: This issue is more likely to happen in newer subscriptions and usually happens if a certain resource type has never been created before in that subscription.
Subscription admins often fix this issue by granting resource group owners contributor rights on the subscription level which contradicts with their strategy of isolating access down to the level of resource group level not the subscription level.
For root cause and quick resolution, refer "Common problem when using Azure resource groups & RBAC".
Well, the error clearly says you dont have rights over the scope, so you are either owner of the wrong sub or you have a role that specifically restricts that.

Resources