Terraform Infrastructure as Code with Zadara zCompute


As organizations continue to embrace cloud computing, the need for flexible and scalable infrastructure solutions becomes paramount. Zadara, a pioneer in enterprise storage-as-a-service (STaaS), offers zCompute, a cutting-edge cloud computing service that combines the best of cloud and on-premises environments. To further enhance the efficiency and agility of managing infrastructure, integrating Infrastructure as Code with Zadara zCompute becomes a game-changer. In this blog, we will explore how to leverage Terraform’s Infrastructure as Code (IaC) capabilities to deploy and manage resources on Zadara zCompute seamlessly.

What is Zadara zCompute?

Zadara’s zCompute is a fully managed cloud compute service that provides virtual servers with enterprise-grade performance and security. With zCompute, organizations can rapidly scale resources, customize server configurations, and gain seamless integration with other Zadara Edge Cloud services. This level of flexibility makes zCompute an ideal choice for a wide range of workloads, from development and testing to production applications.

What is Infrastructure as Code?

Terraform, developed by HashiCorp, is an Infrastructure as Code (IaC) tool that allows developers and system administrators to define, manage, and provision infrastructure resources in a declarative way. 

OpenTofu is an open-source alternative to HashiCorp’s Terraform, a popular infrastructure as code (IaC) tool. It’s essentially a fork of Terraform version 1.5.6, created in response to HashiCorp’s switch from an open-source license to a Business Source License (BSL).

Instead of manually setting up servers, databases, and other resources, both Terraform and OpenTofu let you define your infrastructure as code using a simple and human-readable configuration language.

How Does Terraform Work?

Terraform works based on the principle of resource “declarations.” You define the desired state of your infrastructure resources, and Terraform handles the complexities of creating, updating, and destroying resources to achieve that state. It does this by leveraging the APIs provided by cloud service providers (such as AWS, Azure, Google Cloud) and other infrastructure providers (like Kubernetes) to manage resources efficiently.

Key Concepts in Terraform

  • Declarative Configuration: Terraform uses a declarative approach, where you specify what you want your infrastructure to look like, rather than describing how to achieve that state. This makes Terraform configurations easy to read and understand.
  • Resources: In Terraform, resources represent the infrastructure components you want to create or manage. For instance, you can define resources for virtual machines, networks, security groups, databases, and more.
  • State: Terraform maintains a state file that keeps track of the current state of your infrastructure. This state file helps Terraform understand the differences between the desired state and the actual state, enabling it to make the necessary changes to achieve the desired state.
  • Providers: Providers are plugins in Terraform that interact with different infrastructure platforms. Each provider handles the creation and management of resources for a specific platform. For example, there are providers for AWS, Azure, Google Cloud, Kubernetes, and more.


Why Do You Need Terraform?

  • Automation and Consistency: Terraform enables you to automate the provisioning of infrastructure resources, ensuring consistent and reproducible setups across different environments. This consistency eliminates human errors and reduces the chances of configuration drift.
  • Version Control and Collaboration: Terraform configurations are just text files, which means you can store them in version control systems like Git. This makes it easy to track changes, collaborate with team members, and roll back changes if necessary.
  • Multi-Cloud Support: Terraform provides a unified approach to managing resources across multiple cloud providers. This flexibility allows you to avoid vendor lock-in and choose the best services from different providers for your applications.
  • Infrastructure as Code (IaC): Terraform embraces the IaC paradigm, which treats infrastructure configuration as software code. This approach enables you to apply software development best practices like testing, code reviews, and continuous integration to your infrastructure.
  • Scalability and Flexibility: With Terraform, you can easily scale your infrastructure up or down to meet changing demands. It also provides a powerful interpolation language that allows you to use dynamic values and expressions in your configurations.


In the following, we will only look at Terraform as an example. The scripts are the same for Terraform or OpenTofu

Using Terraform’s AWS Provider on Zadara zCompute

Step 1: Installing Terraform and Configuring AWS Provider

First, ensure you have Terraform installed on your local machine. You can download Terraform from the official website (https://www.terraform.io).

Next, configure the AWS provider in your Terraform configuration file, using your editor of choice, Visual Studio Code, Atom, Notepad++, Brackets, etc.:

provider “aws” {


access_key = your access key

secret_key =your secret key

#zCompute endpoints

endpoints {

     ec2 = “https://<your zCompute url>/api/v2/aws/ec2″

     elb = “https://<your zCompute url>/api/v2/aws/elb”

     route53 = “https://<your zCompute url>/api/v2/aws/route53″


version = “3.33”

region = “us-east-1”



Note: Make sure to specify the AWS provider version to 3.33, this is the current version that Zadara supports at the time of writing.


You can find all related endpoints in the Zadara cloud console on the right top “?* button.


Step 2: Define AWS Resources

With the AWS provider configured, you can now define AWS resources in your Terraform configuration file. For example, let’s create an EC2 instance:

resource "aws_instance" "manager" {
  ami = "<AMI ID>”
  instance_type = "z4.large"
  subnet_id = "<Subnet ID>"
  vpc_security_group_id = "<Security Group ID>"
  key_name = "<your keypair name>”
  user_data = <<-EOF
#! /bin/bash
#<your specific bash command’s>
  root_block_device {
volume_size       = "50"
  tags = {
  Name = "<Servername>"


Ensure you replace all ID’s with the appropriate ID for your preferred operating system, VPC, Subnet, Security Group and Keypair. You can find the information by clicking on the related section in the Zadara cloud portal.

Step 3: Initialize and Apply Terraform

Open up your terminal application where your configuration files exist.

Before applying the configuration, run terraform init to initialise the AWS provider and download the necessary plugins. terraform plan then and use terraform apply to create the AWS resources:

terraform init
terraform plan 
terraform apply


Terraform will display the planned changes and prompt you to confirm. Type “yes” to proceed, and Terraform will create the AWS resources specified in the configuration.

 Step 4: Utilize Zadara zCompute Features

Now that you have created AWS-compatible resources using Terraform, you can take advantage of Zadara’s zCompute capabilities to further enhance your cloud infrastructure. You can integrate your applications with Zadara’s storage services, security features, and networking solutions to create a comprehensive and efficient cloud environment.

 Why not explore the Zadara User Guides and API Guides 


Integrating Terraform’s AWS provider with Zadara zCompute empowers organizations to automate the deployment and management of cloud resources seamlessly. By defining AWS-compatible resources as code, developers gain the agility and scalability needed for modern cloud infrastructures. The combination of AWS services for your hyperscaler workloads and Zadara’s zCompute cloud compute capabilities brings flexibility and efficiency to infrastructure management, ensuring businesses can meet the ever-evolving demands of their workloads. 

With Terraform and Zadara’s zCompute, organizations can build a powerful cloud infrastructure that propels them toward success in the digital age. 

Additional Information

Introduction To Zadara zCompute Services available here: 

Example Terraform Scripts can be found in our Zadara Github Repository: https://github.com/zadarastorage/zadara-terraform 

Picture of Marco Schneider

Marco Schneider

Marco is a staff solution architect at Zadara. He has over 25 years of experience in solution architecture, sales, and infrastructure management. He possesses a strong track record of success creating customer-centric solutions, drive revenue growth, and deliver cutting-edge cloud solutions.

Share This Post

More To Explore