Skip to content

Commit

Permalink
[CI Environment] Replaced default namePrefix (#3428)
Browse files Browse the repository at this point in the history
* First replacements

* Updated wiki

* Updated scripts

* Updated templates

* Updated module readmes

* Replaced remaining files

* Added missing regex escape
  • Loading branch information
AlexanderSehr committed Jul 17, 2023
1 parent 09ea5f5 commit ec3b1af
Show file tree
Hide file tree
Showing 480 changed files with 1,724 additions and 1,724 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
2 changes: 1 addition & 1 deletion modules/aad/domain-services/.test/common/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ param serviceShort string = 'aaddscom'
param enableDefaultTelemetry bool = true

@description('Optional. A token to inject into the name of each resource.')
param namePrefix string = '<<namePrefix>>'
param namePrefix string = '[[namePrefix]]'

// ============ //
// Dependencies //
Expand Down
18 changes: 9 additions & 9 deletions modules/aad/domain-services/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ tags: {
Follow the below PowerShell commands to get base64 encoded string of a self-signed certificate (with a `pfxCertificatePassword`)

```PowerShell
$pfxCertificatePassword = ConvertTo-SecureString '<<YourPfxCertificatePassword>>' -AsPlainText -Force
$pfxCertificatePassword = ConvertTo-SecureString '[[YourPfxCertificatePassword]]' -AsPlainText -Force
$certInputObject = @{
Subject = 'CN=*.<<YourDomainName>>'
DnsName = '*.<<YourDomainName>>'
Subject = 'CN=*.[[YourDomainName]]'
DnsName = '*.[[YourDomainName]]'
CertStoreLocation = 'cert:\LocalMachine\My'
KeyExportPolicy = 'Exportable'
Provider = 'Microsoft Enhanced RSA and AES Cryptographic Provider'
Expand Down Expand Up @@ -231,10 +231,10 @@ module domainServices './aad/domain-services/main.bicep' = {
name: '${uniqueString(deployment().name, location)}-test-aaddscom'
params: {
// Required parameters
domainName: '<<namePrefix>>.onmicrosoft.com'
domainName: '[[namePrefix]].onmicrosoft.com'
// Non-required parameters
additionalRecipients: [
'<<namePrefix>>@noreply.github.com'
'[[namePrefix]]@noreply.github.com'
]
diagnosticEventHubAuthorizationRuleId: '<diagnosticEventHubAuthorizationRuleId>'
diagnosticEventHubName: '<diagnosticEventHubName>'
Expand All @@ -243,7 +243,7 @@ module domainServices './aad/domain-services/main.bicep' = {
diagnosticWorkspaceId: '<diagnosticWorkspaceId>'
enableDefaultTelemetry: '<enableDefaultTelemetry>'
lock: 'CanNotDelete'
name: '<<namePrefix>>aaddscom001'
name: '[[namePrefix]]aaddscom001'
pfxCertificate: '<pfxCertificate>'
pfxCertificatePassword: '<pfxCertificatePassword>'
replicaSets: [
Expand Down Expand Up @@ -275,12 +275,12 @@ module domainServices './aad/domain-services/main.bicep' = {
"parameters": {
// Required parameters
"domainName": {
"value": "<<namePrefix>>.onmicrosoft.com"
"value": "[[namePrefix]].onmicrosoft.com"
},
// Non-required parameters
"additionalRecipients": {
"value": [
"<<namePrefix>>@noreply.github.com"
"[[namePrefix]]@noreply.github.com"
]
},
"diagnosticEventHubAuthorizationRuleId": {
Expand All @@ -305,7 +305,7 @@ module domainServices './aad/domain-services/main.bicep' = {
"value": "CanNotDelete"
},
"name": {
"value": "<<namePrefix>>aaddscom001"
"value": "[[namePrefix]]aaddscom001"
},
"pfxCertificate": {
"value": "<pfxCertificate>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ param serviceShort string = 'asscom'
param enableDefaultTelemetry bool = true

@description('Optional. A token to inject into the name of each resource.')
param namePrefix string = '<<namePrefix>>'
param namePrefix string = '[[namePrefix]]'

// ============ //
// Dependencies //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ param serviceShort string = 'assmax'
param enableDefaultTelemetry bool = true

@description('Optional. A token to inject into the name of each resource.')
param namePrefix string = '<<namePrefix>>'
param namePrefix string = '[[namePrefix]]'

// ============ //
// Dependencies //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ param serviceShort string = 'assmin'
param enableDefaultTelemetry bool = true

@description('Optional. A token to inject into the name of each resource.')
param namePrefix string = '<<namePrefix>>'
param namePrefix string = '[[namePrefix]]'

// ============ //
// Dependencies //
Expand Down
Loading

0 comments on commit ec3b1af

Please sign in to comment.