-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added further utilities readme files to Wiki (#840)
* Update to latest * Update to latest * Update to latest * Update to latest * Update to latest * Update to latest
- Loading branch information
1 parent
550e0fa
commit cb72e20
Showing
15 changed files
with
280 additions
and
65 deletions.
There are no files selected for viewing
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 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 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 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 file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Bicep to ARM conversion script | ||
|
||
At the time of writing bicep is still in a beta phase. For this reason, some people may want to wait for bicep's _General Availability_ and prefer to use ARM Templates for the time being. | ||
For these scenarios, the CARML library provides a script that uses the Bicep Toolkit translator/compiler to support the conversion of CARML Bicep modules to ARM templates. | ||
This page documents the conversion utility and how to use it. | ||
|
||
--- | ||
|
||
### _Navigation_ | ||
|
||
- [Location](#location) | ||
- [How it works](#what-it-does) | ||
- [How to use it](#how-to-use-it) | ||
- [Examples](#examples) | ||
|
||
--- | ||
# Location | ||
|
||
You can find the script under `/utilities/tools/ConvertTo-ARMTemplate.ps1` | ||
|
||
# How it works | ||
|
||
The script finds all 'deploy.bicep' files and tries to convert them to json-based ARM templates | ||
by using the following steps. | ||
1. Remove existing deploy.json files | ||
1. Convert bicep files to json | ||
1. Remove bicep metadata from json | ||
1. Remove bicep files and folders | ||
1. Update pipeline files - Replace .bicep with .json in pipeline files | ||
|
||
# How to use it | ||
|
||
For details on how to use the function please refer to the script's local documentation. | ||
> **Note:** The script must be loaded before the function can be invoked |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Get formatted RBAC roles Script | ||
|
||
Use this script to format a given raw 'Roles' table from Azure to the format required by either bicep or ARM in any RBAC deployment. | ||
|
||
--- | ||
|
||
### _Navigation_ | ||
|
||
- [Location](#location) | ||
- [How it works](#what-it-does) | ||
- [How to use it](#how-to-use-it) | ||
- [Examples](#examples) | ||
|
||
--- | ||
# Location | ||
|
||
You can find the script under `/utilities/tools/Get-FormattedRBACRoles.ps1` | ||
|
||
# How it works | ||
|
||
1. From the provided raw and plain roles list, create a list of only the contained role names | ||
1. Fetch all available roles from Azure | ||
1. Go through all provided role names, match them with those from Azure to get the matching RoleDefinitionId and format a string like `'<roleName>': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','<roleDefinitionId>')` for each match | ||
1. Print the result to the terminal | ||
|
||
# How to use it | ||
|
||
The script does not accept any custom parameter per se, but expects you to replace the placeholder in the `rawRoles` variable inside the script | ||
|
||
```PowerShell | ||
$rawRoles = @' | ||
<paste the table here> | ||
'@ | ||
``` | ||
|
||
To get the list of roles in the expected format: | ||
1. Navigate to Azure | ||
1. Deploy one instance of the service you want to fetch the roles for | ||
1. Navigate to the `Access Control (IAM)` blade in the resource | ||
1. Open the `Roles` tab | ||
1. Set the `Type` in the dropdown to `BuiltInRole` | ||
|
||
<img src="media/rbacRoles.png" alt="Complete deployment flow filtered" height="300"> | ||
|
||
1. Select and copy the entire table as is to the PowerShell variable. | ||
|
||
The result should look similar to | ||
|
||
```PowerShell | ||
$rawRoles = @' | ||
Owner | ||
Grants full access to manage all resources, including the ability to assign roles in Azure RBAC. | ||
builtInRole | ||
General | ||
View | ||
Contributor | ||
Grants full access to manage all resources, but does not allow you to assign roles in Azure RBAC, manage assignments in Azure Blueprints, or share image galleries. | ||
BuiltInRole | ||
General | ||
View | ||
Reader | ||
View all resources, but does not allow you to make any changes. | ||
BuiltInRole | ||
General | ||
View | ||
'@ | ||
``` | ||
1. Execute the script. The output for the above example would be | ||
|
||
```yml | ||
VERBOSE: Bicep | ||
VERBOSE: ----- | ||
'Owner': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','8e3af657-a8ff-443c-a75c-2fe8c4bcb635') | ||
'Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','b24988ac-6180-42a0-ab88-20f7382dd24c') | ||
'Reader': subscriptionResourceId('Microsoft.Authorization/roleDefinitions','acdd72a7-3385-48ef-bd42-f606fba81ae7') | ||
VERBOSE: | ||
VERBOSE: ARM | ||
VERBOSE: --- | ||
"Owner": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions','8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]", | ||
"Contributor": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions','b24988ac-6180-42a0-ab88-20f7382dd24c')]", | ||
"Reader": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions','acdd72a7-3385-48ef-bd42-f606fba81ae7')]", | ||
``` | ||
1. Copy the output into the RBAC file into the `buildInRoleNames` variable. Again, for the same example using bicep this would be: | ||
|
||
```bicep | ||
var builtInRoleNames = { | ||
'Owner': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635') | ||
'Contributor': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c') | ||
'Reader': subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'acdd72a7-3385-48ef-bd42-f606fba81ae7') | ||
} | ||
``` | ||
|
||
For further details on how to use the function please refer to the script's local documentation. | ||
> **Note:** The script must be loaded before the function can be invoked |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Register Azure DevOps Pipelines | ||
|
||
Use this script to automatically register all specified Azure DevOps pipelines in a target Azure DevOps project. This is especially useful to register the initial module pipelines as there is one for each module in the repository. | ||
|
||
--- | ||
|
||
### _Navigation_ | ||
|
||
- [Location](#location) | ||
- [How it works](#what-it-does) | ||
- [How to use it](#how-to-use-it) | ||
- [Examples](#examples) | ||
|
||
--- | ||
# Location | ||
|
||
You can find the script under `/utilities/tools/Register-AzureDevOpsPipeline.ps1` | ||
|
||
# How it works | ||
|
||
1. Get all pipelines in a given target folder (for example `.azuredevops/modulePipelines`) | ||
1. Fetch all currently registered pipelines in the target Azure DevOps project | ||
1. Compare the local defined and remote-registered pipelines to detect which need to be created and which skipped | ||
1. Create all pipelines that are missing | ||
1. Optionally register the pipelines also for build validation (i.e. they registered to be required for Pull Requests) | ||
|
||
# How to use it | ||
|
||
> **Note:** You'll need the 'azure-devops' extension to run this function: `az extension add --upgrade -n azure-devops` | ||
The steps you'd want to follow are | ||
1. (if pipelines are in GitHub) Create a service connection to the target GitHub repository using e.g. oAuth | ||
1. Create a PAT token for the Azure DevOps environment in which you want to register the pipelines in | ||
1. Run this script with the corresponding input parameters | ||
1. Create any required element required to execute the pipelines. For example: | ||
- Library group(s) used in the pipeline(s) | ||
- Service connection(s) used in the pipeline(s) | ||
- Agent pool(s) used in the pipeline(s) if not using the default available agents | ||
|
||
For further details on how to use the function please refer to the script's local documentation. | ||
> **Note:** The script must be loaded before the function can be invoked | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Module ReadMe Generation Script | ||
|
||
Use this script to generate most parts of a templates ReadMe file. It will take care of all aspects but the description & module-specific parameter usage examples. However, the latter are added for default cases such as `tags` or `roleAssignments` if the corresponding parameter exists in the provided template. | ||
|
||
For further information about the parameter usage blocks, please refer to the [section](#special-case-parameter-usage-section) below. | ||
|
||
--- | ||
|
||
### _Navigation_ | ||
|
||
- [Location](#location) | ||
- [How it works](#what-it-does) | ||
- [Special case: 'Parameter Usage' section](#special-case-parameter-usage-section) | ||
- [How to use it](#how-to-use-it) | ||
- [Examples](#examples) | ||
|
||
--- | ||
# Location | ||
|
||
You can find the script under `/utilities/tools/Set-ModuleReadMe.ps1` | ||
|
||
# How it works | ||
|
||
1. Using the provided template path, the script first makes sure to convert it to ARM if necessary (i.e. if a path to a bicep file was provided) | ||
1. If the intended readMe file does not yet exist in the expected path, it is generated with a skeleton (with e.g. a generated header name, etc.) | ||
1. It then goes through all sections defined as `SectionsToRefresh` (by default all) and refreshes the section content (for example for the `Parameters`) based on the values in the ARM template. It detects sections by their header and regenerates always the full section. | ||
1. Once all are refreshed, the current ReadMe file is overwritten. **Note:** The script can be invoked with a `WhatIf` in combination with `Verbose` to just receive an console-output of the updated content. | ||
|
||
## Special case: 'Parameter Usage' section | ||
|
||
The 'Parameter Usage' examples are located just beneath the 'Parameters' table. They are intended to show how to use complex objects/arrays that can be provided as parameters (excluding child-resources as they have their own readMe). | ||
|
||
For the most part, this section is to be populated manually. However, for a specific set of common parameters, we automatically add their example to the readMe if the parameter exists in the template. At the time of this writing these are: | ||
- Private Endpoints | ||
- Role Assignments | ||
- Tags | ||
- User Assigned Identities | ||
|
||
To be able to change this list with minimum effort, the script reads the content from markdown files in the folder: `utilities/tools/moduleReadMeSource` and matches their title against the parameters of the template file. If a match is found, it's content is added to the readme alongside the generated header. This means, if you want to add another case, you just need to add a new file to the `moduleReadMeSource` folder and follow the naming pattern `resourceUsage-<parameteRName>.md`. | ||
|
||
For example, the content of file `resourceUsage-roleAssignments.md` in folder `moduleReadMeSource` is added to a template's readMe if it contains a parameter `roleAssignments`. The combined result is: | ||
|
||
```markdown | ||
### Parameter Usage: `roleAssignments` | ||
|
||
<[resourceUsage-roleAssignments.md] file content> | ||
``` | ||
|
||
# How to use it | ||
|
||
For details on how to use the function please refer to the script's local documentation. | ||
> **Note:** The script must be loaded before the function can be invoked |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
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
Oops, something went wrong.