adding terraform prereqs

This commit is contained in:
Hare Sudhan
2023-05-24 00:33:17 -04:00
parent c3438e27b7
commit 17859b19ef
3 changed files with 58 additions and 1 deletions
+24 -1
View File
@@ -79,18 +79,41 @@ atomic_tests:
default: null
dependency_executor_name: powershell
dependencies:
- description: |
Check if terraform is installed.
prereq_command: |
terraform version
get_prereq_command: |
echo Please install the terraform.
- description: |
Install-Module -Name Az
prereq_command: |
try {if (Get-InstalledModule -Name Az -ErrorAction SilentlyContinue) {exit 0} else {exit 1}} catch {exit 1}
get_prereq_command: |
Install-Module -Name Az -Scope CurrentUser -Force
- description: |
Check if the user is logged into Azure.
prereq_command: |
az account show
get_prereq_command: |
echo Configure your Azure account using: az login.
- description: |
Create dependency resources using terraform
prereq_command: |
try {if (Test-Path $PathToAtomicsFolder/T1078.004/src/T1078.004-2/terraform.tfstate ){ exit 0 } else {exit 1}} catch {exit 1}
get_prereq_command: |
cd $PathToAtomicsFolder/T1078.004/src/T1078.004-2/
terraform init
terraform apply -auto-approve
executor:
command: |
$secure_pwd = "#{password}" | ConvertTo-SecureString -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential -ArgumentList "#{username}", $secure_pwd
Connect-AzAccount -Credential $creds
New-AzAutomationRunbook -Name #{runbook_name} -Type PowerShell -ResourceGroupName #{resource_group} -Description 'my-test-runbook' -AutomationAccountName #{automation_account_name}
Remove-AzAutomationRunbook -AutomationAccountName #{automation_account_name} -Name #{runbook_name} -ResourceGroupName #{resource_group} -Force
name: powershell
elevation_required: false
cleanup_command: |
Remove-AzAutomationRunbook -AutomationAccountName #{automation_account_name} -Name #{runbook_name} -ResourceGroupName #{resource_group} -Force
cd $PathToAtomicsFolder/T1078.004/src/T1078.004-2/
terraform destroy -auto-approve
@@ -0,0 +1,31 @@
terraform {
required_version = ">= 0.12"
}
provider "azurerm" {
features {
}
skip_provider_registration = true
}
variable "resource_group" {
}
variable "runbook_name" {
}
variable "automation_account_name" {
}
resource "azurerm_resource_group" "rg" {
name = var.resource_group
location = "East US"
}
resource "azurerm_automation_account" "account" {
name = var.automation_account_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
sku_name = "Basic"
}
@@ -0,0 +1,3 @@
automation_account_name=""
resource_group=""
runbook_name=""