Using the Instaclustr Terraform Provider v2

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 v2? 

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. 

NOTE: Since Instaclustr Terraform Provider v1 has been deprecated, the focus of this documentation further on will be on the Instaclustr Terraform Provider v2.

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

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

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

Migrating from v1 to v2 of the Instaclustr Terraform Provider

If you have been using the first version of Instaclustr Terraform Provider and want to migrate to Instaclustr Terraform Provider v2, please refer to the Github documentation.

Examples and How-To

The Instaclustr Terraform Provider v2 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 repository as well as the Instaclsutr Terraform Provider v2 registry for additional configuration information.

Installing the Instaclustr Terraform Provider v2 

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

Authentication

To authenticate with Instaclustr, you first need to obtain your API key. It can be found within your Instaclustr account under the Account Settings ⇒ API Keys page; then locate the Provisioning role and click the Add button to generate a key.

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

1. Export the desired variable:

2. Create a variable in your Terraform file:

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

When running terraform operations, pipe in the variables as follows:

AWS Example 

Below is a quick example of how the Instaclustr Terraform Provider v2 can be used with AWS to provision an Instaclustr for Apache Kafka cluster – see the Instaclustr Terraform Provider v2 registry | instaclustr_kafka_cluster_v2 (Resource).

Multi-Data Centre Provisioning

It is possible to provision resources on multiple data centres in a single call. For multi-data centre provisioning, follow the pattern shown in the Instaclustr Terraform Provider v2 registry | instaclustr_cassandra_cluster_v2 (Resource).

Conclusion

Instaclustr Terraform Provider v2 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