Skip to content

Terraform - Getting Started

OPENSTACK CLOUD

In this guide we will see how to use Terraform with Infomaniak Public Cloud infrastructure.

To get started you need some prerequisites:

  • Download your Openstack configuration from the Infomaniak Manager or Openstack Dashboard
  • The Terraform binary must be installed on your system
  • An existing SSH keypair

Create Terraform file and configure Openstack provider

Create a folder named like you want to contain all data generated by Terraform for your deployment

mkdir web-server

In this folder create a new file named main.tf

touch main.tf

Edit this file and copy the content bellow.

# Define required providers
terraform {
  required_providers {
    openstack = {
      source  = "terraform-provider-openstack/openstack"
      version = "1.44.0"
    }
  }
}

# Configure the OpenStack Provider
provider "openstack" {
  auth_url = "https://api.pub1.infomaniak.cloud/identity"
  region = "dc3-a"
  user_name = "PCU-XXXXXXX"
  password = "your_password"
  user_domain_name = "Default"
  project_domain_id = "default"
  tenant_id = "your_tenant_id"
  tenant_name = "PCP-XXXXXXX"
}

The first section defined the provider used by Terraform for this deployment, you don't need to do any change in this section.

The second section is the configuration of the provider. In this section you need to perform changes to use Infomaniak Public Cloud.

To complete informations on this section, open your Openstack configuration file and use values in this one to complete Openstack provider fields based on the matrix bellow.

Terraform provider field Openstack configuration Field
auth_url OS_AUTH_URL
region OS_REGION_NAME
user_name OS_USERNAME
password OS_PASSWORD
user_domain_name OS_USER_DOMAIN_NAME
project_domain_id OS_PROJECT_DOMAIN_ID
tenant_id OS_PROJECT_ID
tenant_name OS_PROJECT_NAME

Success

Once you have completed all informations for the proviver you can begin deploy resources.