Rubrik's API-first architecture enables organizations to embrace and integrate Rubrik functionality into their existing automation processes. While Rubrik APIs can be consumed natively, companies are at various stages in their automation journey with different levels of automation knowledge on staff. The Rubrik Terraform Provider transforms the Rubrik RESTful API functionality into easy-to-consume Terraform configuration, which eliminates the need to understand how to consume raw Rubrik APIs and extends upon one of Rubrik's main design centers - simplicity.
Requirements: Terraform has been successfully installed.
-
Download the latest compiled binary from GitHub releases.
macOS: terraform-provider-rubrik-darwin-amd64 Linux: terraform-provider-rubrik-linux-amd64 Windows: terraform-provider-rubrik-windows-amd64.exe
-
Move the Rubrik provider into the correct Terraform plugin directory
For Terraform 0.12 and earlier:
macOS: ~/.terraform.d/plugins/darwin_amd64 Linux: ~/.terraform.d/plugins/linux_amd64 Windows: %APPDATA%\terraform.d\plugins\windows_amd64
Note: You may need to create the plugins directory.
For Terraform 0.13 and later:
macOS cp terraform-provider-rubrik-darwin-amd64 ~/.terraform.d/plugins/rubrikinc/rubrik/rubrik/<release_version>/darwin_amd64/terraform-provider-rubrik Linux: cp terraform-provider-rubrik-linux-amd64 ~/.terraform.d/plugins/rubrikinc/rubrik/rubrik/<release_version>/linux_amd64/terraform-provider-rubrik Windows: copy terraform-provider-rubrik-windows-amd64.exe %APPDATA%\terraform.d\plugins\rubrikinc\rubrik\rubrik\<release_version>\windows_amd64\terraform-provider-rubrik.exe
Note: You may need to create the containing directory structure.
Note: Replace <release_version> with the release number of the provider as found in GitHub releases.
Note:
terraform-provider-rubrik
andterraform-provider-rubrik.exe
are file names not directories. -
For MacOS and Linux only, make the
terraform-provider-rubrik
file executable.macOS chmod 755 ~/.terraform.d/plugins/rubrikinc/rubrik/rubrik/<release_version>/darwin_amd64/terraform-provider-rubrik Linux: chmod 755 ~/.terraform.d/plugins/rubrikinc/rubrik/rubrik/<release_version>/linux_amd64/terraform-provider-rubrik
-
Run
terraform init
in the directory that contains your Terraform configuration file (main.tf
)
The Rubrik provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below:
- Environment variables
- Static credentials
Storing credentials in environment variables is a more secure process than storing them in your source code, and it ensures that your credentials are not accidentally shared if your code is uploaded to an internal or public version control system such as GitHub.
- RUBRIK_CDM_NODE_IP (Contains the IP/FQDN of a Rubrik node)
- RUBRIK_CDM_USERNAME (Contains a username with configured access to the Rubrik cluster)
- RUBRIK_CDM_PASSWORD (Contains the password for the above user).
provider "rubrik" {}
For Microsoft Windows-based operating systems, the environment variables can be set utilizing the setx command as follows:
setx RUBRIK_CDM_NODE_IP "192.168.0.100"
setx RUBRIK_CDM_USERNAME "user@domain.com"
setx RUBRIK_CDM_PASSWORD "SecretPassword"
Run set without any other parameters to view current environment variables. Using setx saves the environment variables permanently, and the variables defined in the current shell will not be available until a new shell is opened. Using set instead of setx will define variables in the current shell session, but they will not be saved between sessions.
For macOS and *nix based operating systems the environment variables can be set utilizing the export command as follows:
export RUBRIK_CDM_NODE_IP=192.168.0.100
export RUBRIK_CDM_USERNAME=user@domain.com
export RUBRIK_CDM_PASSWORD=SecretPassword
Run export without any other parameters to view current environment variables. In order for the environment variables to persist across terminal sessions, add the above three export commands to the ~\.bash_profile
or ~\.profile
file.
Static credentials can be provided by adding a node_ip
, username
and password
in-line in the
Rubrik provider block:
Usage:
provider "rubrik" {
node_ip = "192.168.100.100"
username = "admin"
password = "RubrikTFDemo2019"
}
This section provides sample syntax to help you get started. For additional information and examples, see the Rubrik Provider for Terraform Documentation.
The following demonstrates configuring the time zone on a Rubrik cluster:
provider "rubrik" {}
resource "rubrik_configure_timezone" "LA-Timezone" {
timezone = "America/Los_Angeles"
}
The following demonstrates an example of bootstrapping a new Rubrik cluster:
resource "rubrik_bootstrap" "example" {
cluster_name = "tf-demo"
admin_email = "tf@demo.com"
admin_password = "RubrikTFDemo2019"
management_gateway = "192.168.100.1"
management_subnet_mask = "255.255.255.0"
dns_search_domain = "demo.com"
dns_name_servers = ["192.168.100.5". "192.168.100.6"]
ntp_server1_name = "8.8.8.8"
ntp_server2_name = "8.8.4.4"
node_config = {
tf-node01 = "192.168.100.100"
}
}
The following demonstrates an example of bootstrapping a new Rubrik cluster:
resource "rubrik_bootstrap_cces_aws" "example" {
cluster_name = "tf-demo"
admin_email = "tf@demo.com"
admin_password = "RubrikTFDemo2019"
management_gateway = "192.168.100.1"
management_subnet_mask = "255.255.255.0"
dns_search_domain = "demo.com"
dns_name_servers = ["192.168.100.5". "192.168.100.6"]
ntp_server1_name = "8.8.8.8"
ntp_server2_name = "8.8.4.4"
node_config = {
tf-node01 = "192.168.100.100"
}
bucket_name = "tf-demo-bucket"
enable_immutability = true
}
The following demonstrates an example of bootstrapping a new Rubrik cluster:
resource "rubrik_bootstrap_cces_azure" "example" {
cluster_name = "tf-demo"
admin_email = "tf@demo.com"
admin_password = "RubrikTFDemo2019"
management_gateway = "192.168.100.1"
management_subnet_mask = "255.255.255.0"
dns_search_domain = "demo.com"
dns_name_servers = ["192.168.100.5". "192.168.100.6"]
ntp_server1_name = "8.8.8.8"
ntp_server2_name = "8.8.4.4"
node_config = {
tf-node01 = "192.168.100.100"
}
connection_string = "DefaultEndpointsProtocol=https;AccountName=storageaccountforccesazuregosdk;AccountKey=abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890abcdefghijklm==;EndpointSuffix=core.windows.net"
container_name = "container-for-cces-azure"
enable_immutability = true
}
This guide acts only as a quick start to get up and running with the Terraform Provider for Rubrik. For detailed information on all of the functions and features included, see the complete Terraform Provider for Rubrik documentation.
The Rubrik Provider for Terraform supports much of the configuration for deploying the Rubrik CDM software as well as preparing AWS and Azure for CloudOut and CloudOn. However, keep in mind that the release cycles between the Provider and Rubrik CDM are not simultaneous. This means there may be times when new features or enhancements are added to the product but resources and functions to utilize them may be missing from the SDK. In these situations Terraform may be used to make native calls to Rubrik's RESTful API.
Rubrik prides itself upon its API-first architecture, ensuring everything available within the HTML5 interface, and more, is consumable via a RESTful API. For more information on Rubrik's API architecture and its documentation, please see the Rubrik API Documentation.
The Rubrik Provider for Terraform is hosted on a public repository on GitHub. If you would like to get involved and contribute to the Rubrik Provider please follow the below guidelines.
-
Clone the Rubrik Provider for Terraform repository
git clone https://github.com/rubrikinc/rubrik-provider-for-terraform.git
-
Change to the repository root directory
cd rubrik-provider-for-terraform
-
Switch to the devel branch
git checkout devel
The /rubrik-provider-for-terraform/rubrikcdm
directory contains all of the Rubrik Terraform resources. You can also utilize the following file as a template for all new resource functions:
rubrik-modules-for-ansible/blob/master/docs/rubrik_module_template.py
To add parameters specific to the new resource you can update the following section which starts on line 67
:
func resourceRubrikAWSNativeAccountCreate(d *schema.ResourceData, meta interface{}) error {
After the new variables have been defined you can start adding any new required logic after the code block section.
##################################
######### Code Block #############
##################################
##################################
Once the resource and functions have been fully coded, please update or add to Rubrik Provider for Terraform documentation. The directory is located here.