Skip to main content

Getting Started

How to Configure Terraform for E2E

To use Terraform with E2E, you need to install Terraform and configure a provider file.

Install Terraform

You can install the latest version of Terraform on most operating systems from the command line using various package managers. Click your operating system’s tab below to view instructions on how to install Terraform.

Linux

To install Terraform on Ubuntu, add the HashiCorp GPG key to your system:

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -

Next, add the official HashiCorp Terraform Linux repository to apt:

sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"

Then update apt and install Terraform:

    sudo apt-get update && sudo apt-get install terraform

Once installed, verify the installation:

    terraform -v

MacOS :-

To install Terraform on MacOS using Homebrew, run the following command in a terminal:

  brew install terraform

Once installed, verify Terraform’s installation:

    terraform -v

Windows :-

To install Terraform on Windows using Chocolatey, run the following command from the command prompt:

   choco install terraform

Once installed, verify Terraform’s installation:

  terraform -v

CentOS :-

To install Terraform on CentOS, install the yum-config-manager to manage your repositories:

   sudo yum install -y yum-utils

Use yum-config-manager to add the official HashiCorp Linux repository:

  sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo 

Then install Terraform:

  sudo yum -y install terraform

Once installed, verify Terraform’s installation:

  terraform -v

To use the e2e provider with Terraform, you have to configure the plugin using a provider file. This file tells Terraform which provider you’re using (e2e) and where to find the necessary credentials (your e2e API token, and your auth To start, create and move into a directory from which you will configure and deploy your infrastructure. This is also where you create the provider file. To install this provider, copy and paste this code into your Terraform configuration. Then, run terraform init. Checkout the terraform registry for e2e provider here <https://registry.terraform.io/providers/e2eterraformprovider/e2e/latest>_ and choose the latest version.

    terraform {
required_providers {
e2e = {
source = "e2eterraformprovider/tir"
version = "1.0.6" # checkout the latest version from terraform registry
}
}
}

provider "tir" {
# Configuration options
api_key = ""
auth_token = ""
}

Provider Configuration Schema

Argument Reference

Example usage

    terraform {
required_providers {
e2e = {
source = "e2eterraformprovider/tir"
version = "1.0.6" # use latest version
}
}
}

provider "tir" {
api_key = "your api_key"
auth_token = "your auth_token"
}

Execute Terraform

Once you have configured your Terraform files, you can deploy all of the resources you have configured from the command line. Terraform requires three steps for deployment: initializing the directory, reviewing an execution plan, and applying (executing) the Terraform plan. Initialization prepares the working directory for use by accounting for any changes in Terraform’s backend configuration. The planning step provides you a detailed manifest of the resources for you to review before execution. Lastly, the terraform apply command executes the deployment of the resources into your account. To initialize the working directory:

    terraform init

If Terraform was successful in initializing the directory, you receive the message Terraform has been successfully initialized!. Next, you need to create and view your Terraform plan. To create your Terraform plan:

    terraform plan 

Terraform returns a manifest of resources it will deploy when you apply the plan.After reviewing the plan, you can apply it and deploy the resources to your account. To execute the plan: Before applying terraform will prompt you to confirm by typing yes. You must checkout the changes in the configuration before applying.

    terraform apply

You can checkout the current terraform state:

    terraform show

You can also delete your resource created by terraform

   terraform destroy 

But it will destroy all the resources. To destroy a target resource use the command below

  terraform destroy  —- target e2e_node.demo_node_name

Here resource of type e2e_node and name demo_node_name is deleted. Or you can simply clear the resource from configuration file and then command terraform apply. The resource will be deleted.

Create Terraform Configuration Files

Once you have configured Terraform to access your e2e account, you can begin developing Terraform files that describe and declare the e2e resources that you want to deploy into your account. Terraform configuration files are text files stored with .tf extensions. They are human-readable and they support comments. During deployment, Terraform loads all files with a .tf extension and creates a manifest of resources to deploy called a “plan”. You can divide resource configurations between as many or as few .tf files as you want. Below is the sample terraform file for launching a node. You can copy paste the file into your working directory as a new .tf file. The fields inside the resource e2e_node is discussed in the next section. example.tf

terraform {
required_providers {
e2e = {
source = "e2eterraformprovider/tir"
version = "1.0.6"
}
}
}

provider "tir" {
api_key = "your e2e api key"
auth_token = "your e2e auth bearer token"
}

resource "tir_eos" "example_eos" {
name = "demo_eos"
disk_size = 100 // this is to be given only in case of storage_type as "disk"
storage_type = "new_bucket"
pvc_type = "custom_pvc" // this must be custom_pvc in case of disk otherwise you can leave it
team_id = ""
project_id = ""
active_iam = ""
}

TIR Iams

Example Usage

data "tir_iams" "iams" {
// it will be blank
}

Schema

Read-Only

  • id (String) : The ID of this resource.
  • iams (List of iams)

TIR Teams

Example Usage

data "tir_teams" "teams" {
active_iam = <active_iam : string>
}

Schema

Required

  • active_iam (String) : This will be string value which you can find in state file after running data sources for iams.

Read-Only

  • id (String) : The ID of this resource.
  • teams (List of teams)

TIR Projects

Example Usage

data "tir_projects" "projects" {
active_iam = <active_iam:string> // this is you can find in state file
team_id = <team_id : string> // this is you can find in state file
}

Schema

Required

  • active_iam (String) This is you will find in state and imply in which particular account you want to create resource.
  • team_id (String) This is you will find in state and imply in which particular team you want to create resource

Read-Only

  • id (String) : The ID of this resource.
  • projects (List of projects)