Skip to content

Commit b36baa8

Browse files
DEVOPS-60 completed the automation
1 parent 15d3a88 commit b36baa8

File tree

8 files changed

+195
-615
lines changed

8 files changed

+195
-615
lines changed

.github/dependabot.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: /
5+
schedule:
6+
interval: "weekly"
7+
day: thursday
8+
time: "11:05"
9+
timezone: Asia/Kolkata
10+
# Assignees to set on pull requests
11+
assignees:
12+
- "githubofkrishnadhas"
13+
# prefix specifies a prefix for all commit messages. When you specify a prefix for commit messages,
14+
# GitHub will automatically add a colon between the defined prefix and the commit message provided the
15+
# defined prefix ends with a letter, number, closing parenthesis, or closing bracket.
16+
commit-message:
17+
prefix: "dependabot python package"
18+
# Use reviewers to specify individual reviewers or teams of reviewers for all pull requests raised for a package manager.
19+
reviewers:
20+
- "devwithkrishna/admin"
21+
# Raise pull requests for version updates to pip against the `main` branch
22+
target-branch: "main"
23+
# Labels on pull requests for version updates only
24+
labels:
25+
- "pip dependencies"
26+
- "pip-package"
27+
# Increase the version requirements for Composer only when required
28+
versioning-strategy: increase-if-necessary
29+
# Dependabot opens a maximum of five pull requests for version updates. Once there are five open pull requests from Dependabot,
30+
# Dependabot will not open any new requests until some of those open requests are merged or closed.
31+
# Use open-pull-requests-limit to change this limit.
32+
open-pull-requests-limit: 10

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ ipython_config.py
9999
# This is especially recommended for binary packages to ensure reproducibility, and is more
100100
# commonly ignored for libraries.
101101
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102-
#poetry.lock
102+
poetry.lock
103103

104104
# pdm
105105
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.

Pipfile

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,67 @@
11
# get-azure-role-assignments-using-python
22
This repository contains python code to get the role assignments from azure
3+
4+
5+
# What this repository do
6+
7+
```markdown
8+
This repo contains the source code which can be used to list the role assignments on a subscription level
9+
for Azure using Python azure SDK's.
10+
```
11+
12+
## parameters
13+
14+
| inputs | description | mandatory |
15+
|--------|-------------|-----------|
16+
|subscription_id| azure subscription id| :heavy_check_mark: |
17+
18+
## Authentication
19+
20+
Authentication to Azure is done using service principal credentials
21+
22+
have a `.env file`
23+
24+
```yaml
25+
AZURE_CLIENT_ID="xxx"
26+
AZURE_CLIENT_SECRET="xxx"
27+
AZURE_TENANT_ID="xxx"
28+
AZURE_SUBSCRIPTION_ID="xxx"
29+
```
30+
Where xxx refers to the actual values. These will vary for everyone
31+
32+
using python-dotenv module and fucntion load_dotenv() uses it for local testing.
33+
34+
# Final output
35+
36+
```json
37+
{
38+
"id": "/subscriptions/<subscription id>/providers/Microsoft.Authorization/roleAssignments/<assignment id>",
39+
"name": "<name>",
40+
"type": "Microsoft.Authorization/roleAssignments",
41+
"principal_id": "<principal id>",
42+
"principal_type": "< group or user or service principal>",
43+
"role_definition_id": "<role definition id>",
44+
"assignment_creation_time": "<when assignment was created>",
45+
"scope": "/subscriptions/<subscription id>",
46+
"principal_name": "<principal name>",
47+
"rbac_role_name": "<Azure Rbac or custom role namess>"
48+
}
49+
```
50+
51+
* for local testing the code creates this as a json file.
52+
53+
# How to run the code locally
54+
55+
```commandline
56+
python3 role_assignments.py --subscription_id <subscription id>
57+
```
58+
59+
### For package management poetry is used.
60+
61+
62+
## Refernces
63+
64+
[role-assignments-list](https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-list-rest)
65+
[role-based-access-control built-in-roles](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles)
66+
[AuthorizationManagementClient](https://learn.microsoft.com/en-us/rest/api/authorization/role-definitions/get?view=rest-authorization-2022-04-01&tabs=Python)
67+
[azure graph rbac](https://learn.microsoft.com/en-us/python/api/azure-graphrbac/azure.graphrbac.operations.service_principals_operations.serviceprincipalsoperations?view=azure-python-previous#azure-graphrbac-operations-service-principals-operations-serviceprincipalsoperations-get)

azcli.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)