Skip to content

citrix/terraform-provider-citrix

Repository files navigation

Plugin for Terraform Provider for Citrix®

Citrix has developed a custom Terraform provider for automating Citrix product deployments and configurations. Using Terraform with Citrix provider, you can manage your Citrix products via Infrastructure as Code, giving you higher efficiency and consistency on infrastructure management, as well as better reusability on infrastructure configuration. The provider is developed and maintained by Citrix. Please note that this provider is still in tech preview.

Table of Content

Contacting the Maintainers

This project uses GitHub to track all issues. See CONTRIBUTING.md for more information.

Plugin for Terraform Provider for Citrix® Documentation

Navigating the repository

  1. internal folder - Contains the following sub directories:
    • provider folder - Contains the Citrix provider implementation for Terraform
    • daas folder - Contains all the Citrix DaaS resources libraries that we support through Terraform.
    • test folder - Contains the Go tests for both provider and all resources that we have.
    • util folder - Contains general utility functions that can be reused.
  2. examples folder - Contains the examples for users to use various Citrix resources e.g zone folder contains the resources.tf that illustrates how citrix_zone resource can be used to create a DaaS Zone on target Citrix DaaS site. There are also examples for Citrix provider configuration for both Citrix Cloud customer and Citrix on-premises customers. Users can use the examples as a starting point to configure their own Citrix Terraform script.
  3. docs folder - resources - contains the documentation for all resource configurations supported through Terraform. Refer this to understand the properties, accepted values, and how various properties work together for each type of resource.

Provider Configuration

provider.tf contains the information on target DaaS site where you want to apply configuration.

Depending on whether its managing a Citrix Cloud site, or a Citrix on-premises site, Citrix provider should be configured differently.

Example for on-premises site:

provider "citrix" {
    hostname      = "10.71.136.250"  # Optionally set with `CITRIX_HOSTNAME` environment variable.
    client_id     = "${var.domain_admin_id}"  # Optionally set with `CITRIX_CLIENT_ID` environment variable.
    client_secret = "${var.domain_admin_secret}"  # Optionally set with `CITRIX_CLIENT_SECRET` environment variable.
}

Example for Cloud site:

provider "citrix" {
    region        = "US"  # Optionally set with `CITRIX_REGION` environment variable.
    environment   = "Production"  # Optionally set with `CITRIX_ENVIRONMENT` environment variable.
    customer_id   = "${var.customer_id}"  # Optionally set with `CITRIX_CUSTOMER_ID` environment variable.
    client_id     = "${var.api_key_clientId}"  # Optionally set with `CITRIX_CLIENT_ID` environment variable.
    client_secret = "${var.api_key_clientSecret}"  # Optionally set with `CITRIX_CLIENT_SECRET` environment variable.
}

You can also set hostname for cloud site to force override the Citrix DaaS service URL for a cloud customer.

You can use environment variables as stated in the comments above. When running Go tests, always use environment variables so that no credentials or other sensitive information are checked-in to the code.

Below is a table to show the difference between on-premises and Cloud provider configuration:

Cloud On-Premises
region US / EU / AP-S / JP N/A
environment Production / Staging N/A
customerId Cloud Customer Id N/A
hostname (Optional) Cloud DDC hostname On-Premises DDC Hostname / IP address
clientId Citrix Cloud API Key clientId Domain Admin Username
clientSecret Citrix Cloud API Key clientSecret Domain Admin Password

Resource Configuration

Resources.tf can be used to configure the desired state of the resources that you want to create and manage in your Citrix Services. The example below shows how you can configure a Citrix DaaS Zone in Citrix DaaS service in resource.tf.

citrix_zone

resource "citrix_zone" "example-zone" {
    name                = "example-zone"
    description         = "zone example"
    metadata            = [
        {
            name    = "key1"
            value   = "value1"
        }
    ]
}

Please refer the Plugin for Terraform Provider for Citrix DaaS™ documentation such as docs/resources/zone.md to find out the configurable properties of each type of resources, understand what they do, and what option values are supported.


Using the Plugin for Terraform Provider for Citrix DaaS™

Install Terraform

Refer the Hashicorp documentation for installing Terraform CLI for your own environment.

(On-Premises Only) Enable Web Studio

For on-premises sites with version >= 2308 are supported. Web Studio needs to be installed and configured for the provider to work.

Configure your Plugin for Terraform Provider for Citrix DaaS™

Refer section Understanding Provider Configuration or Provider documentation to configure the provider for the Citrix DaaS site you want to manage with Terraform.

Start writing Terraform for managing your Citrix DaaS site

To find all the Citrix DaaS resources manageable via Terraform, understand all the configurable properties for each resource and how they work together, refer documentations for DaaS resources that has daas_ as resource name prefix in Citrix Terraform resource documentation. To better understand how the resource is managed via Citrix DaaS Rest API, you can refer the Citrix DaaS Rest API documentation.

Create a Zone in Citrix DaaS as the first step

Refer the DaaS Zone documentation to configure a zone via terraform.

Create a Hypervisor

Hypervisor is needed to use your preferred public cloud provider with Citrix DaaS. Refer the DaaS Hypervisor documentation to configure an Azure hypervisor in a zone via terraform.

Create a Hypervisor Resource Pool

The hypervisor resource pool defines the network configuration for a hypervisor connection. Refer the DaaS Hypervisor Resource Pool documentaion to configure a hypervisr resource pool via terraform.

Create a Machine Catalog

A machine catalog is a collection of machines managed as a single entity. Refer the DaaS Machine Catalog documentation to configure a machine catalog via terraform.

Create a Delivery Group

A delivery group is a collection of machines selected from one or more machine catalogs. The delivery group can also specify which users can use those machines, plus the applications and desktops available to those users. Refer the DaaS Delivery Group documentation to configure a delivery group via terraform.

Frequently Asked Questions

What resource is supported for different connection types?

Connection Type Hypervisor Resource Pool MCS Power Managed MCS Provisioning
AzureRM ✔️ ✔️ ✔️ ✔️
AWS EC2 ✔️ ✔️ ✔️ ✔️
GCP ✔️ ✔️ ✔️ ✔️
Vsphere ✔️ ✔️ ✔️ ✔️
XenServer ✔️ ✔️ ✔️ ✔️
Nutanix ✔️ ✔️ ✔️ ✔️

What provisioning types are supported for machine catalog?

  • MCS provisioning
    • Azure
    • GCP
    • AWS EC2
    • Vsphere
    • XenServer
    • Nutanix
  • Manual Power Managed
    • Azure
    • GCP
    • AWS EC2
    • Vsphere
    • XenServer
    • Nutanix
  • Manual / Remote PC

Attributions

The code in this repository makes use of the following packages:

License

This project is Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2023. Citrix Systems, Inc.