This commit is contained in:
Hattan Shobokshi 2022-05-17 16:39:21 -07:00
Родитель b0b16353f3
Коммит 7dacda8ba6
3 изменённых файлов: 38 добавлений и 16 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Compile-BicepFile([string]$path){
bicep $path
function Deploy-BicepFeature([string]$path, $params){
bicep build $path
$code = $?
if ($code -eq "True"){ # arm deployment was successful
New-AzSubscriptionDeployment -Location $params.location -TemplateFile examples/main.json -TemplateParameterObject $params
}
}
function Remove-BicepFeature($params){
Get-AzResourceGroup -Name $params.name | Remove-AzResourceGroup -Force
}

Просмотреть файл

@ -1,5 +1,6 @@
BeforeAll{
. $PSScriptRoot/BenchPress/Helpers/Azure/ResourceGroup.ps1
. $PSScriptRoot/BenchPress/Helpers/Azure/Bicep.ps1
}
Describe 'Verify Resource Group Exists' {
it 'Should contain a resource group named tflintrules' {
@ -14,15 +15,21 @@ Describe 'Verify Resource Group Exists' {
}
}
Describe 'Verify RG Bicep' {
Describe 'Spin up , Tear down Resource Group' {
it 'Should deploy a bicep file.' {
#arrange
$rgName = "tflintrules"
$bicepPath = "./main.bicep"
$bicepPath = "./examples/main.bicep"
$params = @{
name = "rgtestocw11"
location = "westus"
environment = "ocwtest"
}
#act
$exists = Get-ResourceGroupExists($rgName)
$deployment = Deploy-BicepFeature $bicepPath $params
#assert
$exists | Should -Be $true
$deployment.ProvisioningState| Should -Be "Succeeded"
#clean up
Remove-BicepFeature $params
}
}

Просмотреть файл

@ -1,10 +1,17 @@
resource symbolicname 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: 'string'
location: 'string'
targetScope = 'subscription'
param name string
param location string
param environment string
// https://docs.microsoft.com/en-us/azure/templates/microsoft.resources/resourcegroups?tabs=bicep
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: name
location: location
tags: {
tagName1: 'tagValue1'
tagName2: 'tagValue2'
'Env': environment
}
managedBy: 'string'
properties: {}
}
}
output name string = resourceGroup.name
output id string = resourceGroup.id