Skip to content

Commit

Permalink
More renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
krbar committed Feb 24, 2024
1 parent 9a4547a commit 4675230
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"value": "validation-rg"
},
"subscriptionId": {
"value": "[[subscriptionId]]"
"value": "#_subscriptionId_#"
},
"roleAssignments": {
"value": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ module roleAssignments-multiRolesMultiPrincipals './Microsoft.Authorization/role
roleDefinitionIdOrName: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'
}
]
subscriptionId: '[[subscriptionId]]'
subscriptionId: '#_subscriptionId_#'
}
}
```
Expand Down Expand Up @@ -161,7 +161,7 @@ module roleAssignments-multiRolesMultiPrincipals './Microsoft.Authorization/role
]
},
"subscriptionId": {
"value": "[[subscriptionId]]"
"value": "#_subscriptionId_#"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"value": 1
},
"vmNamePrefix": {
"value": "[[namePrefix]]-vm-linux-prefix"
"value": "#_namePrefix_#-vm-linux-prefix"
},
"vmNumberOfInstances": {
"value": 3
Expand Down Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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"
}
Expand Down
43 changes: 23 additions & 20 deletions constructs/Compute/virtualMachinesMultiple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
]
}
```
Expand Down Expand Up @@ -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'
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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'
]
}
}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/wiki/Solution creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
14 changes: 7 additions & 7 deletions docs/wiki/The CI environment - Token replacement.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -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_#"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4675230

Please sign in to comment.