From 46752307a3cff0d127cd6385f0f01a6ec70dcda9 Mon Sep 17 00:00:00 2001 From: Kris Baranek Date: Sat, 24 Feb 2024 22:16:22 +0100 Subject: [PATCH] More renaming --- .../.test/parameters.json | 2 +- .../README.md | 4 +- .../.test/linux.prefix.parameter.json | 4 +- .../.test/linux.vmnames.parameter.json | 8 ++-- .../Compute/virtualMachinesMultiple/README.md | 43 ++++++++++--------- docs/wiki/Solution creation.md | 2 +- .../The CI environment - Token replacement.md | 14 +++--- settings.yml | 2 +- 8 files changed, 41 insertions(+), 38 deletions(-) diff --git a/constructs/Authorization/roleAssignmentsMultiRolesMultiPrincipals/.test/parameters.json b/constructs/Authorization/roleAssignmentsMultiRolesMultiPrincipals/.test/parameters.json index 9d966ec168..2fd7dfa3f3 100644 --- a/constructs/Authorization/roleAssignmentsMultiRolesMultiPrincipals/.test/parameters.json +++ b/constructs/Authorization/roleAssignmentsMultiRolesMultiPrincipals/.test/parameters.json @@ -7,7 +7,7 @@ "value": "validation-rg" }, "subscriptionId": { - "value": "[[subscriptionId]]" + "value": "#_subscriptionId_#" }, "roleAssignments": { "value": [ diff --git a/constructs/Authorization/roleAssignmentsMultiRolesMultiPrincipals/README.md b/constructs/Authorization/roleAssignmentsMultiRolesMultiPrincipals/README.md index ca376774c5..5245aef99d 100644 --- a/constructs/Authorization/roleAssignmentsMultiRolesMultiPrincipals/README.md +++ b/constructs/Authorization/roleAssignmentsMultiRolesMultiPrincipals/README.md @@ -128,7 +128,7 @@ module roleAssignments-multiRolesMultiPrincipals './Microsoft.Authorization/role roleDefinitionIdOrName: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11' } ] - subscriptionId: '[[subscriptionId]]' + subscriptionId: '#_subscriptionId_#' } } ``` @@ -161,7 +161,7 @@ module roleAssignments-multiRolesMultiPrincipals './Microsoft.Authorization/role ] }, "subscriptionId": { - "value": "[[subscriptionId]]" + "value": "#_subscriptionId_#" } } } diff --git a/constructs/Compute/virtualMachinesMultiple/.test/linux.prefix.parameter.json b/constructs/Compute/virtualMachinesMultiple/.test/linux.prefix.parameter.json index 560a375b20..df47eb01a9 100644 --- a/constructs/Compute/virtualMachinesMultiple/.test/linux.prefix.parameter.json +++ b/constructs/Compute/virtualMachinesMultiple/.test/linux.prefix.parameter.json @@ -6,7 +6,7 @@ "value": 1 }, "vmNamePrefix": { - "value": "[[namePrefix]]-vm-linux-prefix" + "value": "#_namePrefix_#-vm-linux-prefix" }, "vmNumberOfInstances": { "value": 3 @@ -54,7 +54,7 @@ "ipConfigurations": [ { "name": "ipconfig01", - "subnetId": "/subscriptions/[[subscriptionId]]/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-[[namePrefix]]-az-vnet-x-001/subnets/[[namePrefix]]-az-subnet-x-001", + "subnetId": "/subscriptions/#_subscriptionId_#/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-#_namePrefix_#-az-vnet-x-001/subnets/#_namePrefix_#-az-subnet-x-001", "pipConfiguration": { "publicIpNameSuffix": "-pip-01" } diff --git a/constructs/Compute/virtualMachinesMultiple/.test/linux.vmnames.parameter.json b/constructs/Compute/virtualMachinesMultiple/.test/linux.vmnames.parameter.json index 12cd7f813c..cd405022c5 100644 --- a/constructs/Compute/virtualMachinesMultiple/.test/linux.vmnames.parameter.json +++ b/constructs/Compute/virtualMachinesMultiple/.test/linux.vmnames.parameter.json @@ -4,9 +4,9 @@ "parameters": { "vmNames": { "value": [ - "[[namePrefix]]-vm-linux-vmnames-01", - "[[namePrefix]]-vm-linux-vmnames-02", - "[[namePrefix]]-vm-linux-vmnames-03" + "#_namePrefix_#-vm-linux-vmnames-01", + "#_namePrefix_#-vm-linux-vmnames-02", + "#_namePrefix_#-vm-linux-vmnames-03" ] }, "osType": { @@ -52,7 +52,7 @@ "ipConfigurations": [ { "name": "ipconfig01", - "subnetId": "/subscriptions/[[subscriptionId]]/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-[[namePrefix]]-az-vnet-x-001/subnets/[[namePrefix]]-az-subnet-x-001", + "subnetId": "/subscriptions/[[subscriptionId]]/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-#_namePrefix_#-az-vnet-x-001/subnets/#_namePrefix_#-az-subnet-x-001", "pipConfiguration": { "publicIpNameSuffix": "-pip-01" } diff --git a/constructs/Compute/virtualMachinesMultiple/README.md b/constructs/Compute/virtualMachinesMultiple/README.md index 914c75fc91..e67abaac0b 100644 --- a/constructs/Compute/virtualMachinesMultiple/README.md +++ b/constructs/Compute/virtualMachinesMultiple/README.md @@ -4,11 +4,14 @@ This module deploys one or multiple Virtual Machines. ## Navigation -- [Resource Types](#Resource-Types) -- [Parameters](#Parameters) -- [Outputs](#Outputs) -- [Cross-referenced modules](#Cross-referenced-modules) -- [Deployment examples](#Deployment-examples) +- [Multiple Virtual Machines `[Microsoft.Compute/virtualMachinesMultiple]`](#multiple-virtual-machines-microsoftcomputevirtualmachinesmultiple) + - [Navigation](#navigation) + - [Resource Types](#resource-types) + - [Parameters](#parameters) + - [Parameter Usage: `vmNames`](#parameter-usage-vmnames) + - [Outputs](#outputs) + - [Cross-referenced modules](#cross-referenced-modules) + - [Deployment examples](#deployment-examples) ## Resource Types @@ -126,9 +129,9 @@ Name(s) of the virtual machine(s). If no explicit names are provided, VM name(s) ```json "vmNames": { "value": [ - "[[namePrefix]]-vm-linux-vmnames-01", - "[[namePrefix]]-vm-linux-vmnames-02", - "[[namePrefix]]-vm-linux-vmnames-03" + "#_namePrefix_#-vm-linux-vmnames-01", + "#_namePrefix_#-vm-linux-vmnames-02", + "#_namePrefix_#-vm-linux-vmnames-03" ] } ``` @@ -180,7 +183,7 @@ module virtualMachinesMultiple 'ts/modules:compute.virtualmachinesmultiple:1.0.0 pipConfiguration: { publicIpNameSuffix: '-pip-01' } - subnetId: '/subscriptions/[[subscriptionId]]/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-[[namePrefix]]-az-vnet-x-001/subnets/[[namePrefix]]-az-subnet-x-001' + subnetId: '/subscriptions/#_subscriptionId_#/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-#_namePrefix_#-az-vnet-x-001/subnets/#_namePrefix_#-az-subnet-x-001' } ] nicSuffix: '-nic-01' @@ -203,7 +206,7 @@ module virtualMachinesMultiple 'ts/modules:compute.virtualmachinesmultiple:1.0.0 } ] vmInitialNumber: 1 - vmNamePrefix: '[[namePrefix]]-vm-linux-prefix' + vmNamePrefix: '#_namePrefix_#-vm-linux-prefix' vmNumberOfInstances: 3 } } @@ -242,7 +245,7 @@ module virtualMachinesMultiple 'ts/modules:compute.virtualmachinesmultiple:1.0.0 "pipConfiguration": { "publicIpNameSuffix": "-pip-01" }, - "subnetId": "/subscriptions/[[subscriptionId]]/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-[[namePrefix]]-az-vnet-x-001/subnets/[[namePrefix]]-az-subnet-x-001" + "subnetId": "/subscriptions/#_subscriptionId_#/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-#_namePrefix_#-az-vnet-x-001/subnets/#_namePrefix_#-az-subnet-x-001" } ], "nicSuffix": "-nic-01" @@ -279,7 +282,7 @@ module virtualMachinesMultiple 'ts/modules:compute.virtualmachinesmultiple:1.0.0 "value": 1 }, "vmNamePrefix": { - "value": "[[namePrefix]]-vm-linux-prefix" + "value": "#_namePrefix_#-vm-linux-prefix" }, "vmNumberOfInstances": { "value": 3 @@ -317,7 +320,7 @@ module virtualMachinesMultiple 'ts/modules:compute.virtualmachinesmultiple:1.0.0 pipConfiguration: { publicIpNameSuffix: '-pip-01' } - subnetId: '/subscriptions/[[subscriptionId]]/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-[[namePrefix]]-az-vnet-x-001/subnets/[[namePrefix]]-az-subnet-x-001' + subnetId: '/subscriptions/#_subscriptionId_#/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-#_namePrefix_#-az-vnet-x-001/subnets/#_namePrefix_#-az-subnet-x-001' } ] nicSuffix: '-nic-01' @@ -340,9 +343,9 @@ module virtualMachinesMultiple 'ts/modules:compute.virtualmachinesmultiple:1.0.0 } ] vmNames: [ - '[[namePrefix]]-vm-linux-vmnames-01' - '[[namePrefix]]-vm-linux-vmnames-02' - '[[namePrefix]]-vm-linux-vmnames-03' + '#_namePrefix_#-vm-linux-vmnames-01' + '#_namePrefix_#-vm-linux-vmnames-02' + '#_namePrefix_#-vm-linux-vmnames-03' ] } } @@ -381,7 +384,7 @@ module virtualMachinesMultiple 'ts/modules:compute.virtualmachinesmultiple:1.0.0 "pipConfiguration": { "publicIpNameSuffix": "-pip-01" }, - "subnetId": "/subscriptions/[[subscriptionId]]/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-[[namePrefix]]-az-vnet-x-001/subnets/[[namePrefix]]-az-subnet-x-001" + "subnetId": "/subscriptions/#_subscriptionId_#/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-#_namePrefix_#-az-vnet-x-001/subnets/#_namePrefix_#-az-subnet-x-001" } ], "nicSuffix": "-nic-01" @@ -416,9 +419,9 @@ module virtualMachinesMultiple 'ts/modules:compute.virtualmachinesmultiple:1.0.0 }, "vmNames": { "value": [ - "[[namePrefix]]-vm-linux-vmnames-01", - "[[namePrefix]]-vm-linux-vmnames-02", - "[[namePrefix]]-vm-linux-vmnames-03" + "#_namePrefix_#-vm-linux-vmnames-01", + "#_namePrefix_#-vm-linux-vmnames-02", + "#_namePrefix_#-vm-linux-vmnames-03" ] } } diff --git a/docs/wiki/Solution creation.md b/docs/wiki/Solution creation.md index 6c8e117bbf..3f4a1ee370 100644 --- a/docs/wiki/Solution creation.md +++ b/docs/wiki/Solution creation.md @@ -390,7 +390,7 @@ The example assumes you are using a [`bicepconfig.json`](https://learn.microsoft "moduleAliases": { "ts": { "modules": { - "subscription": "[[subscriptionId]]", + "subscription": "#_subscriptionId_#", "resourceGroup": "artifacts-rg" } } diff --git a/docs/wiki/The CI environment - Token replacement.md b/docs/wiki/The CI environment - Token replacement.md index 1158d6c62a..5a2cea4b39 100644 --- a/docs/wiki/The CI environment - Token replacement.md +++ b/docs/wiki/The CI environment - Token replacement.md @@ -17,7 +17,7 @@ This section provides details on the tokens replacement functionality that enabl Tokens allow you to test deploying modules in your own environment (i.e., using tokens for your naming conventions), or apply other customizations to your resources (i.e., injecting a subscription ID inside a Resource ID string). -The [module pipelines](./The%20CI%20environment%20-%20Pipeline%20design#module-pipelines) leverage a token replacement function that enables module test files to contain tokens (i.e., `[[subscriptionId]]`, `[[tenantId]]`) instead of using static values. This helps with the following: +The [module pipelines](./The%20CI%20environment%20-%20Pipeline%20design#module-pipelines) leverage a token replacement function that enables module test files to contain tokens (i.e., `#_subscriptionId_#`, `#_tenantId_#`) instead of using static values. This helps with the following: - Allows the repository to be portable without having static values from where it was cloned. - Enables dynamic updates of the tokens from single locations without having to modify all files. @@ -31,9 +31,9 @@ There are 2 types of tokens that can be applied on a module test file: These are tokens constructed from environment variables, which are defined in the workflow (Pipeline). Review [Getting Started - GitHub specific prerequisites](./Getting%20Started) for more information on these environment variables. -- `[[subscriptionId]]`: Will point to the Azure subscription. -- `[[managementGroupId]]`: Will point to the Azure an Azure Management Group. -- `[[tenantId]]`: Will point to the Azure Tenant ID. +- `#_subscriptionId_#`: Will point to the Azure subscription. +- `#_managementGroupId_#`: Will point to the Azure an Azure Management Group. +- `#_tenantId_#`: Will point to the Azure Tenant ID. ## (Optional) Local Custom Tokens @@ -86,15 +86,15 @@ The below diagram illustrates the Token Replacement Functionality via the [valid - **1A.** The user creates default tokens as [GitHub Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) or [Azure DevOps Pipeline Variables](https://learn.microsoft.com/en-us/azure/devops/pipelines/library/?view=azure-devops), that are injected as environment variables. - **1B.** The user can also create local custom Tokens in the [settings.yml](https://github.com/Azure/ResourceModules/blob/main/settings.yml). Tokens start with `localTokens_` and then followed by the actual token name (e.g. `tokenA`). This prefix gets removed by the CI leaving the original token name -- **2.** The module test files can now be tokenized as per required value. And the token format can look like `[[tokenA]]`. Example: +- **2.** The module test files can now be tokenized as per required value. And the token format can look like `#_tokenA_#`. Example: ```json "adminPassword": { "reference": { "keyVault": { - "id": "/subscriptions/[[subscriptionId]]/resourceGroups/validation-rg/providers/Microsoft.KeyVault/vaults/[[tokenA]]-keyVault" + "id": "/subscriptions/#_subscriptionId_#/resourceGroups/validation-rg/providers/Microsoft.KeyVault/vaults/#_tokenA_#-keyVault" }, - "secretName": "[[tokenB]]" + "secretName": "#_tokenB_#" } } ``` diff --git a/settings.yml b/settings.yml index 66f937a19b..b66e6b490e 100644 --- a/settings.yml +++ b/settings.yml @@ -12,7 +12,7 @@ variables: ######################## # the 'localToken_' prefix will be removed from the key name when the pipelines run. - # e.g. if you have a token in your parameter file as [[customKey]], then the token defined in this file looks like "localToken_customKey": 'value' + # e.g. if you have a token in your parameter file as #_customKey_# then the token defined in this file looks like "localToken_customKey": 'value' localToken_namePrefix: '' # A 3-5 character length unique string, included in the resources names (e.g. 'cntso'). Used for local module testing and pipelines. # this determines the starting prefix and ending suffix of the token in your file.