From 629a2a16a9184fc9aea8fce6a7018f3ee11470a2 Mon Sep 17 00:00:00 2001 From: Yash Ravindra Bhokare Date: Wed, 22 Jan 2025 10:23:51 -0500 Subject: [PATCH] v1.0.9-hotfix --- scripts/onboarding-helper/README.md | 2 +- .../terraform-onboarding.ps1 | 83 +++++++++---------- scripts/onboarding-helper/terraform.tf | 2 +- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/scripts/onboarding-helper/README.md b/scripts/onboarding-helper/README.md index 38362c8..75a9dac 100644 --- a/scripts/onboarding-helper/README.md +++ b/scripts/onboarding-helper/README.md @@ -5,7 +5,7 @@ This automation script is designed to onboard an existing site to Terraform. It ## Environment Requirements - PowerShell version `5.0` or higher -- Citrix Provider version `1.0.8` +- Citrix Provider version `1.0.9` - For On-Premises Customers: CVAD DDC `version 2311` or newer. ## Workflow: diff --git a/scripts/onboarding-helper/terraform-onboarding.ps1 b/scripts/onboarding-helper/terraform-onboarding.ps1 index 6cd17c8..43b3230 100644 --- a/scripts/onboarding-helper/terraform-onboarding.ps1 +++ b/scripts/onboarding-helper/terraform-onboarding.ps1 @@ -374,6 +374,13 @@ function Get-ResourceList { continue } + #Handle special case for Built-in Admin Roles + if($requestPath -eq "Admin/Roles"){ + if($item.IsBuiltIn){ + continue; + } + } + # Handle special case for Policies if ($item.policySetGuid -and $item.policySetType -like "*Policies*") { $resourceList += $item.policySetGuid @@ -737,49 +744,22 @@ function InjectPlaceHolderSensitiveValues { [string] $content ) - Write-Verbose "Injecting placeholder for sensitive values in terraform output." - ### hypervisor secrets ### - ###### Azure ###### - $content = InjectSecretValues -targetProperty "application_id" -newProperty "application_secret" -content $content - ###### AWS ###### - $content = InjectSecretValues -targetProperty "api_key" -newProperty "secret_key" -content $content - ###### GCP ###### - $content = InjectSecretValues -targetProperty "service_account_id" -newProperty "service_account_credentials" -content $content - ###### XenServer / vSphere ###### - $content = InjectSecretValues -targetProperty "username" -newProperty "password" -content $content - - ### machine catalog service accounts ### - $content = InjectSecretValues -targetProperty "domain" -newProperty "service_account" -content $content - $content = InjectSecretValues -targetProperty "domain" -newProperty "service_account_password" -content $content - - return $content -} - -function ExtractAndSaveApplicationIcons { - param( - [parameter(Mandatory = $true)] - [string] $content - ) - - # Check if application icon exists; if not, then exit - if ($content -notmatch 'citrix_application_icon') { - return $content - } - - Write-Verbose "Extracting and saving application icons into icons folder." - $filteredOutput = @() $lines = $content -split "`r?`n" $iconCounter = 0 - - # Create the icons folder $iconsFolder = Join-Path -Path $PSScriptRoot -ChildPath "icons" - if (-not (Test-Path -Path $iconsFolder)) { - New-Item -ItemType Directory -Path $iconsFolder | Out-Null + + # Check if application icon exists; if not, then exit + if ($content -match 'citrix_application_icon') { + + # Create the icons folder + if (-not (Test-Path -Path $iconsFolder)) { + New-Item -ItemType Directory -Path $iconsFolder | Out-Null + } } foreach ($line in $lines) { - if ($line -match '.*raw_data\s*=.*') { + if ($line -match 'raw_data\s*=\s*"([^"]+)"') { $rawDataValue = $matches[1] $iconBytes = [System.Convert]::FromBase64String($rawDataValue) $iconFileName = "$iconsFolder\app_icon_$iconCounter.ico" @@ -798,12 +778,34 @@ function ExtractAndSaveApplicationIcons { $iconCounter++ # Replace raw_data value with icon file path using filebase64 to encode a file's content in base64 format $line = 'raw_data = filebase64("' + $iconFileName + '")' + $filteredOutput += $line + } + elseif ($line -match "application_id") { + $filteredOutput += $line + $filteredOutput += 'application_secret = ""' + } + elseif ($line -match "service_account_id") { + $filteredOutput += $line + $filteredOutput += 'service_account_credentials = ""' + } + elseif ($line -match "api_key") { + $filteredOutput += $line + $filteredOutput += 'secret_key = ""' + } + elseif ($line -match "username") { + $filteredOutput += $line + $filteredOutput += 'password = ""' + } + elseif ($line -match "domain_ou") { + $filteredOutput += $line + $filteredOutput += 'service_account = ""' + $filteredOutput += 'service_account_password = ""' + } + else { + $filteredOutput += $line } - $filteredOutput += $line } - $content = $filteredOutput -join "`n" - Write-Verbose "Extracted and saved $iconCounter application icons." return $content } @@ -854,9 +856,6 @@ function PostProcessTerraformOutput { # Inject placeholder for sensitive values in tf $content = InjectPlaceHolderSensitiveValues -content $content - # Extract and save citrix application icons - $content = ExtractAndSaveApplicationIcons -content $content - # Overwrite extracted terraform with processed value Set-Content -Path ".\resource.tf" -Value $content diff --git a/scripts/onboarding-helper/terraform.tf b/scripts/onboarding-helper/terraform.tf index ad1585e..1e95c1f 100644 --- a/scripts/onboarding-helper/terraform.tf +++ b/scripts/onboarding-helper/terraform.tf @@ -4,7 +4,7 @@ terraform { required_providers { citrix = { source = "citrix/citrix" - version = "=1.0.8" + version = "=1.0.9" } }