Skip to content

Commit

Permalink
updates to CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoore-msft committed Jul 15, 2019
1 parent 1a20083 commit 635aaf2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ test/ci-scripts/.config.json
test/AzTemplateToolKit.zip
test/pipeline/QuickStarts-Az-CI-Public-Export.json
test/pipeline/QuickStarts-Az-CI-Public-Import.json
test/pipeline/validation policy (template).json
37 changes: 35 additions & 2 deletions test/ci-gen-setup/Create-GEN-Artifacts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ param(
[string] $CertPass = $("cI#" + (New-Guid).ToString().Substring(0, 17)),
[string] $CertDNSName = 'azbot-cert-dns',
[string] $KeyVaultSelfSignedCertName = 'azbot-sscert',
[string] $KeyVaultNotSecretName = 'notSecretPassword'
[string] $KeyVaultNotSecretName = 'notSecretPassword',
[string] $ServicePrincipalObjectId #if not provided assigning perms to the Vault must be done manually

)

Expand All @@ -35,6 +36,7 @@ $json.Add("VNET-SUBNET1-NAME", $vNet.Subnets[0].Name)

<#
Creat a KeyVault and add:
0) The principal deploying templates will need access to the vault (if needed for vm deployments)
1) Sample Password
2) Service Fabric Cert
3) Disk Encryption Key
Expand All @@ -45,7 +47,38 @@ Creat a KeyVault and add:
# Create the Vault
$vault = Get-AzureRMKeyVault -VaultName $KeyVaultName -verbose -ErrorAction SilentlyContinue
if($vault -eq $null) {
$vault = New-AzureRMKeyVault -VaultName $KeyVaultName -ResourceGroupName $ResourceGroupName -Location $Location -EnabledForTemplateDeployment -EnabledForDiskEncryption -Verbose
$vault = New-AzureRMKeyVault -VaultName $KeyVaultName `
-ResourceGroupName $ResourceGroupName `
-Location $Location `
-EnabledForTemplateDeployment -EnabledForDiskEncryption -EnabledForDeployment `
-Verbose
}

# 0) Give the svc principal that will be deploying templates RBAC and Access Policy Access to the Vault

if($ServicePrincipalObjectId){

$roleDef = New-Object -TypeName "Microsoft.Azure.Commands.Resources.Models.Authorization.PSRoleDefinition"

$roleDef.Id = $null
$roleDef.Name = "KeyVault Deployment Action"
$roleDef.Description = "KeyVault Deploy Action for Template Reference Parameter Use"
$roleDef.Actions = @("Microsoft.KeyVault/vaults/deploy/action")
$roleDef.AssignableScopes = @("/subscriptions/$((Get-AzureRMContext).Subscription.Id)")

$roleDef | Out-String

$role = New-AzureRMRoleDefinition -Role $roleDef -Verbose

New-AzureRMRoleAssignment -RoleDefinitionId $role.Id -ObjectId $ServicePrincipalObjectId -Scope $vault.ResourceId -Verbose

# Set the Data Plane Access Policy for the Principal

Set-AzureRMKeyVaultAccessPolicy -VaultName $KeyVaultName -ObjectId $ServicePrincipalObjectId `
-PermissionsToKeys get,restore `
-PermissionsToSecrets get,set `
-PermissionsToCertificates get

}

# 1) Create a sample password
Expand Down
1 change: 1 addition & 0 deletions test/ci-scripts/Get-SampleFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ Write-Host "##vso[task.setvariable variable=sample.folder]$FolderString"
# Generate a resourceGroup Name
$resourceGroupName = "azdo-$(New-Guid)"
Write-Host "##vso[task.setvariable variable=resourceGroup.name]$resourceGroupName"
Write-Host "##vso[task.setvariable variable=prereq.resourceGroup.name]$resourceGroupName-prereqs"
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ foreach ($av in $allApiVersions) { # Then walk over each object containing an Ap
$timeSinceApi = [DateTime]::Now - $apiDate
if ($timeSinceApi.TotalDays -gt 730) { # If it's older than a year
# write a warning
Write-Error "Api versions should be under a year old ($FullResourceType is $([Math]::Floor($timeSinceApi.TotalDays)) days old)"
Write-Error "Api versions should be under 2 years old (730 days) - ($FullResourceType is $([Math]::Floor($timeSinceApi.TotalDays)) days old)"
}
}

0 comments on commit 635aaf2

Please sign in to comment.