Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Azure/ResourceModules into …
Browse files Browse the repository at this point in the history
…users/fabmas/3418-
  • Loading branch information
elanzel committed Jul 21, 2023
2 parents f02ef3a + f497978 commit 1b71920
Show file tree
Hide file tree
Showing 513 changed files with 2,192 additions and 2,011 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 @@ -187,7 +187,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 @@ -220,7 +220,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
38 changes: 19 additions & 19 deletions constructs/Compute/virtualMachinesMultiple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,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 @@ -245,8 +245,8 @@ You can specify multiple user assigned identities to a resource by providing add
```json
"userAssignedIdentities": {
"value": {
"/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-001": {},
"/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-002": {}
"/subscriptions/[[subscriptionId]]/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-001": {},
"/subscriptions/[[subscriptionId]]/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-002": {}
}
}
```
Expand All @@ -259,8 +259,8 @@ You can specify multiple user assigned identities to a resource by providing add

```bicep
userAssignedIdentities: {
'/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-001': {}
'/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-002': {}
'/subscriptions/[[subscriptionId]]/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-001': {}
'/subscriptions/[[subscriptionId]]/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-002': {}
}
```

Expand Down Expand Up @@ -312,7 +312,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 @@ -335,7 +335,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 @@ -374,7 +374,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 @@ -411,7 +411,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 @@ -449,7 +449,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 @@ -472,9 +472,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 @@ -513,7 +513,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 @@ -548,9 +548,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
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"value": [
{
"peeringName": "sxx-az-peering-x-002-sxx-az-peering-x-003",
"remoteVirtualNetworkId": "/subscriptions/<<subscriptionId>>/resourceGroups/dependencies-rg/providers/Microsoft.Network/virtualNetworks/sxx-az-vnet-x-003",
"remoteVirtualNetworkId": "/subscriptions/[[subscriptionId]]/resourceGroups/dependencies-rg/providers/Microsoft.Network/virtualNetworks/sxx-az-vnet-x-003",
"useRemoteGateways": false
},
{
"remoteVirtualNetworkId": "/subscriptions/<<subscriptionId>>/resourceGroups/dependencies-rg/providers/Microsoft.Network/virtualNetworks/peeringNetwork",
"remoteVirtualNetworkId": "/subscriptions/[[subscriptionId]]/resourceGroups/dependencies-rg/providers/Microsoft.Network/virtualNetworks/peeringNetwork",
"useRemoteGateways": false
}
]
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
18 changes: 9 additions & 9 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 All @@ -52,14 +52,14 @@ Let's say you'd want to use this token inside a Key Vault module test file, to d
```json
"parameters": {
"name": {
"value": "<<tokenA>>-keyVault-<<tokenB>>"
"value": "[[tokenA]]-keyVault-[[tokenB]]"
}
}
```

Once the Key Vault is deployed, you'll notice that the Key Vault name in Azure will be `foo-keyVault-bar`

The token prefix `'<<'` and suffix `'>>'` in the above example are also configurable in the [settings.yml](https://github.com/Azure/ResourceModules/blob/main/settings.yml) file and are used to identify the tokens in the files.
The token prefix `'[['` and suffix `']]'` in the above example are also configurable in the [settings.yml](https://github.com/Azure/ResourceModules/blob/main/settings.yml) file and are used to identify the tokens in the files.

The solution comes with one predefined local token `namePrefix`. This token is leveraged in most of the parameter & test files for deployments. It allows using a consistent naming prefix that is applied to all resources being tested. There are two ways this token can be set and one will take precedence over the other:

Expand All @@ -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
Loading

0 comments on commit 1b71920

Please sign in to comment.