Using the Instaclustr Terraform Provider

What Is Terraform? 

Terraform is an open source platform that allows you to create, manage, and delete cloud resources in different cloud providers. It allows you to manage your cloud resources via command line interface (CLI) and code rather than having to log into a cloud provider like AWS and manually provision resources through their dashboard. 

Instaclustr provides what is known as a “Terraform Provider” that allows users to interact with their Instaclustr resources through Terraform without having to write custom API scripts themselves. It acts as a wrapper that makes provisioning resources in the customer’s Instaclustr account a plug-and-play experience. 

What Is a Terraform Provider?

In technical terms, a Terraform provider is a logical abstraction of an upstream API. Instead of having to write custom API calls, you can use a Terraform provider. In other terms, you can use a provider to use Terraform to interact with an API without writing any of the API calls yourself. 

There is a list of Terraform providers that are used for common platforms such as GCP, AWS, Azure, Kubernetes, and more that can be viewed here.

What Can You Do With Instaclustr’s Terraform Provider? 

Instaclustr provides a Terraform Provider that allows users to interact directly with and provision cloud resources for their Instaclustr infrastructure via Terraform without writing their own code to connect the APIs together. This makes it simpler for customers to integrate Instaclustr provisioning and management into their current workflows. It is also easier and quicker to do all the actions needed such as creating and deleting clusters. 

Currently, the Instaclustr Terraform provider works with all three major cloud providers: AWS, Azure, and GCP. The different clouds can be switched by changing the cluster_provider variable within the Terraform code. 

Our Terraform Provider works with open source technologies we currently offer, including Apache Cassandra, Apache Kafka, Apache Spark, OpenSearch, Redis, Apache ZooKeeper, Cadence and Kafka add-ons.

The Instaclustr Terraform Provider works by making use of the Instaclustr Provisioning API, and makes the necessary calls to be able to provision and manage resources through Terraform. 

Examples and How-To

The Instaclustr Terraform Provider is easy to install and start using with Terraform. Below we have a few code snippets so you can quickly get started with it. For additional information please see the Github as well as the registry for additional configuration information.

Installing the Instaclustr Terraform Provider 

To install the Instaclustr Terraform provider, paste this code into your Terraform configuration and run Terraform in it:

Authentication

In order to authenticate with Instaclustr, you first need to obtain your API key. It can be found within your Instaclustr account under the Account SettingsAPI Keys page; then locate the Provisioning role and click Generate Key.

Your username and key can then be placed in the following snippet as an example: 

In order to keep the api_key variable secret in the ENV, instead of stored in your terraform file like the username, use the following method:

In console export the desired variable:

In your terraform file create a variable:

When running terraform plan/apply, pipe in the variables as follows:

AWS Example 

Below is a quick example of how the Instaclustr Terraform Provider can be used with AWS to provision Instaclustr resources. 

Multi-Data Center Provisioning

It is possible to provision resources on multiple data centers in a single call using the node_sizerack_allocationprovider, and bundle variables. 

For examples on multi-data center provisioning, please refer to the Instaclustr Terraform Provider Github. 

Conclusion

The Instaclustr Terraform Provider allows you to use Terraform to provision and manage your Instaclustr resources without needing to use the Console. This lets you easily integrate Instaclustr resource provisioning and managing into your current Terraform setup. In this blog we’ve covered how to quickly get started; for additional information please see the resources below. 

Additional Resources: 

 

By Instaclustr Support
Need Support?
Experiencing difficulties on the website or console?
Already have an account?
Need help with your cluster?
Contact Support
Why sign up?
To experience the ease of creating and managing clusters via the Instaclustr Console
Spin up a cluster in minutes