-
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.
[Modules] Added waf-aligned test (#4193)
* waf folders * waf serviceshort * waf metadata * waf readme
- Loading branch information
Showing
339 changed files
with
43,386 additions
and
0 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
104 changes: 104 additions & 0 deletions
104
modules/aad/domain-service/tests/e2e/waf-aligned/dependencies.bicep
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,104 @@ | ||
@description('Optional. The location to deploy to.') | ||
param location string = resourceGroup().location | ||
|
||
@description('Required. The name of the Virtual Network to create.') | ||
param virtualNetworkName string | ||
|
||
@description('Required. The name of the Key Vault to create.') | ||
param keyVaultName string | ||
|
||
@description('Required. The name of the Managed Identity to create.') | ||
param managedIdentityName string | ||
|
||
@description('Required. The name of the Deployment Script to create for the Certificate generation.') | ||
param certDeploymentScriptName string | ||
|
||
var certPWSecretName = 'pfxCertificatePassword' | ||
var certSecretName = 'pfxBase64Certificate' | ||
var addressPrefix = '10.0.0.0/16' | ||
|
||
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2023-04-01' = { | ||
name: virtualNetworkName | ||
location: location | ||
properties: { | ||
addressSpace: { | ||
addressPrefixes: [ | ||
addressPrefix | ||
] | ||
} | ||
subnets: [ | ||
{ | ||
name: 'defaultSubnet' | ||
properties: { | ||
addressPrefix: cidrSubnet(addressPrefix, 16, 0) | ||
} | ||
} | ||
] | ||
} | ||
} | ||
|
||
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = { | ||
name: keyVaultName | ||
location: location | ||
properties: { | ||
sku: { | ||
family: 'A' | ||
name: 'standard' | ||
} | ||
tenantId: tenant().tenantId | ||
enablePurgeProtection: null | ||
enabledForTemplateDeployment: true | ||
enabledForDiskEncryption: true | ||
enabledForDeployment: true | ||
enableRbacAuthorization: true | ||
accessPolicies: [] | ||
} | ||
} | ||
|
||
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { | ||
name: managedIdentityName | ||
location: location | ||
} | ||
|
||
resource keyPermissions 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
name: guid('msi-${managedIdentity.name}-KeyVault-Admin-RoleAssignment') | ||
scope: keyVault | ||
properties: { | ||
principalId: managedIdentity.properties.principalId | ||
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '00482a5a-887f-4fb3-b363-3b7fe8e74483') // Key Vault Administrator | ||
principalType: 'ServicePrincipal' | ||
} | ||
} | ||
|
||
resource certDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = { | ||
name: certDeploymentScriptName | ||
location: location | ||
kind: 'AzurePowerShell' | ||
identity: { | ||
type: 'UserAssigned' | ||
userAssignedIdentities: { | ||
'${managedIdentity.id}': {} | ||
} | ||
} | ||
properties: { | ||
azPowerShellVersion: '3.0' | ||
retentionInterval: 'P1D' | ||
arguments: ' -KeyVaultName "${keyVault.name}" -ResourceGroupName "${resourceGroup().name}" -CertPWSecretName "${certPWSecretName}" -CertSecretName "${certSecretName}"' | ||
scriptContent: loadTextContent('../../../../../.shared/.scripts/Set-PfxCertificateInKeyVault.ps1') | ||
} | ||
} | ||
|
||
@description('The resource ID of the created Virtual Network Subnet.') | ||
output subnetResourceId string = virtualNetwork.properties.subnets[0].id | ||
|
||
@description('The resource ID of the created Key Vault.') | ||
output keyVaultResourceId string = keyVault.id | ||
|
||
@description('The name of the certification password secret.') | ||
output certPWSecretName string = certPWSecretName | ||
|
||
@description('The name of the certification secret.') | ||
output certSecretName string = certSecretName | ||
|
||
@description('The principal ID of the created Managed Identity.') | ||
output managedIdentityPrincipalId string = managedIdentity.properties.principalId |
109 changes: 109 additions & 0 deletions
109
modules/aad/domain-service/tests/e2e/waf-aligned/main.test.bicep
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,109 @@ | ||
targetScope = 'subscription' | ||
|
||
metadata name = 'WAF-aligned' | ||
metadata description = 'This instance deploys the module in alignment with the best-practices of the Azure Well-Architected Framework.' | ||
|
||
// ========== // | ||
// Parameters // | ||
// ========== // | ||
|
||
@description('Optional. The name of the resource group to deploy for testing purposes.') | ||
@maxLength(90) | ||
param resourceGroupName string = 'dep-${namePrefix}-aad.domainservices-${serviceShort}-rg' | ||
|
||
@description('Optional. The location to deploy resources to.') | ||
param location string = deployment().location | ||
|
||
@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.') | ||
param serviceShort string = 'aaddswaf' | ||
|
||
@description('Optional. Enable telemetry via a Globally Unique Identifier (GUID).') | ||
param enableDefaultTelemetry bool = true | ||
|
||
@description('Optional. A token to inject into the name of each resource.') | ||
param namePrefix string = '[[namePrefix]]' | ||
|
||
// ============ // | ||
// Dependencies // | ||
// ============ // | ||
|
||
// General resources | ||
// ================= | ||
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { | ||
name: resourceGroupName | ||
location: location | ||
} | ||
|
||
module nestedDependencies 'dependencies.bicep' = { | ||
scope: resourceGroup | ||
name: '${uniqueString(deployment().name, location)}-nestedDependencies' | ||
params: { | ||
virtualNetworkName: 'dep-${namePrefix}-vnet-${serviceShort}' | ||
keyVaultName: 'dep-${namePrefix}-kv-${serviceShort}' | ||
managedIdentityName: 'dep-${namePrefix}-msi-${serviceShort}' | ||
certDeploymentScriptName: 'dep-${namePrefix}-ds-${serviceShort}' | ||
} | ||
} | ||
|
||
// Diagnostics | ||
// =========== | ||
module diagnosticDependencies '../../../../../.shared/.templates/diagnostic.dependencies.bicep' = { | ||
scope: resourceGroup | ||
name: '${uniqueString(deployment().name, location)}-diagnosticDependencies' | ||
params: { | ||
storageAccountName: 'dep${namePrefix}diasa${serviceShort}01' | ||
logAnalyticsWorkspaceName: 'dep-${namePrefix}-law-${serviceShort}' | ||
eventHubNamespaceEventHubName: 'dep-${namePrefix}-evh-${serviceShort}' | ||
eventHubNamespaceName: 'dep-${namePrefix}-evhns-${serviceShort}' | ||
location: location | ||
} | ||
} | ||
|
||
// ============== // | ||
// Test Execution // | ||
// ============== // | ||
|
||
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = { | ||
name: last(split(nestedDependencies.outputs.keyVaultResourceId, '/')) | ||
scope: resourceGroup | ||
} | ||
|
||
module testDeployment '../../../main.bicep' = { | ||
scope: resourceGroup | ||
name: '${uniqueString(deployment().name, location)}-test-${serviceShort}' | ||
params: { | ||
enableDefaultTelemetry: enableDefaultTelemetry | ||
name: '${namePrefix}${serviceShort}001' | ||
domainName: '${namePrefix}.onmicrosoft.com' | ||
additionalRecipients: [ | ||
'${namePrefix}@noreply.github.com' | ||
] | ||
diagnosticSettings: [ | ||
{ | ||
name: 'customSetting' | ||
eventHubName: diagnosticDependencies.outputs.eventHubNamespaceEventHubName | ||
eventHubAuthorizationRuleResourceId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId | ||
storageAccountResourceId: diagnosticDependencies.outputs.storageAccountResourceId | ||
workspaceResourceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId | ||
} | ||
] | ||
lock: { | ||
kind: 'CanNotDelete' | ||
name: 'myCustomLockName' | ||
} | ||
pfxCertificate: keyVault.getSecret(nestedDependencies.outputs.certSecretName) | ||
pfxCertificatePassword: keyVault.getSecret(nestedDependencies.outputs.certPWSecretName) | ||
replicaSets: [ | ||
{ | ||
location: 'WestEurope' | ||
subnetId: nestedDependencies.outputs.subnetResourceId | ||
} | ||
] | ||
sku: 'Standard' | ||
tags: { | ||
'hidden-title': 'This is visible in the resource name' | ||
Environment: 'Non-Prod' | ||
Role: 'DeploymentValidation' | ||
} | ||
} | ||
} |
Oops, something went wrong.