This automation script is designed to onboard an existing site to Terraform. It collects the list of resources from DDC, imports them into Terraform, and generates the Terraform skeletons for the site resources. Please note that this onboarding script is still in tech preview.
- PowerShell version
5.0
or higher - Citrix Provider version
1.0.14
- For On-Premises Customers: CVAD DDC
version 2311
or newer.
- Create a new folder for your Terraform project.
- Initialize Terraform in the newly created folder by running the following command:
terraform init
- Set up the Citrix Terraform provider locally. For instructions, refer to the Citrix Provider Documentation.
- (Cloud only) create a Citrix Cloud service principal with at least the
Read Only Administrator
role to the DDC. This will be used for theClientId
andClientSecret
in the next step.
- Create a new folder for your Terraform project.
- Copy the
terraform-onboarding.ps1
script andterraform.tf
to the terraform project directory created in step 1. - Open a PowerShell session with Administrator privileges.
- Navigate to the directory where the
terraform-onboarding.ps1
script is located. - Set the execution policy by running the following command in the PowerShell session:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force
- Run the script with the following command:
- For Citrix Cloud customers
.\terraform-onboarding.ps1 -CustomerId "{CustomerId}" -ClientId "{ClientId}" -ClientSecret "{ClientSecret}" -Environment "{Environment}"
- For Citrix on-premises customers
Replace the placeholders
.\terraform-onboarding.ps1 -ClientId "{ClientId}" -ClientSecret "{ClientSecret}" -DomainFqdn "{Domain FQDN}" -HostName "{HostName}"
{...}
with your actual values. Here's what each parameter means:CustomerId
:- For Citrix Cloud customers only (Required): Your Citrix Cloud customer ID. This is only applicable for Citrix Cloud customers.
ClientId
: Your client ID for Citrix DaaS service authentication.- For Citrix On-Premises customers: Use this to specify a DDC administrator username.
- For Citrix Cloud customers: Use this to specify a Citrix Cloud service principal ID.
ClientSecret
: Your client secret for Citrix DaaS service authentication.- For Citrix on-premises customers: Use this to specify a DDC administrator password.
- For Citrix Cloud customers: Use this to specify Citrix Cloud service principal secret.
DomainFqdn
: Your client secret for Citrix DaaS service authentication.- For Citrix on-premises customers only (Required): Use this to specify Domain FQDN.
HostName
: The host name or base URL of your Citrix DaaS service.- For Citrix on-premises customers (Required): Use this to specify Delivery Controller hostname.
- For Citrix Cloud customers (Optional): Use this to force override the Citrix DaaS service hostname.
Environment
:- For Citrix Cloud customers only (Optional): Your Citrix Cloud environment. The available options are
Production
andStaging
. The default value isProduction
.
- For Citrix Cloud customers only (Optional): Your Citrix Cloud environment. The available options are
SetDependencyRelationship
(Switch): Add this switch to create dependency relationships between resources by replacing resouce ID with resource references.DisableSSLValidation
(Switch):- For Citrix on-premises customers only: Add this switch to disable SSL validation on both the PowerShell session and the provider client. SSL validation has to be disabled for this script to work if your on-premises DDC does not have a valid SSL certificate.
-
Wait for the script to complete. The execution time will depend on the complexity of the onboarding process and the resources being imported.
-
Once the script has finished running, check the
.tf
files for the output. The Terraform state file should also be updated with the site terraform resources. -
Please note that the onboarding script masks out values for all sensitive attributes present in the generated terraform files. Please update these placeholders with the appropriate values.
-
At this point if you run
terraform plan
, you should only see the sensitive attributes from step 9 being updated. -
Run
terraform apply
. This will synchronize the state file with the values of the sensitive attributes updated in step 9. -
If you run
terraform plan
again, you should see the following message:No changes. Your infrastructure matches the configuration.
. This indicates that all the Citrix resources have been successfully onboarded.
- While running the script for On-Premises customers if it throws an exception as stated below:
Invoke-WebRequest : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
Solution :
Disable SSL validation by adding -DisableSSLValidation
to the command.
.\terraform-onboarding.ps1 -ClientId "{ClientId}" -ClientSecret "{ClientSecret}" -DomainFqdn "{Domain FQDN}" -HostName "{HostName}" -DisableSSLValidation