Authentication in Cloud Infrastructure via Terraform
Here we explain how to get started with Terraform — specifically, how to connect to the Peerobyte cloud infrastructure using Terraform. To do this, you will obtain authentication data from the OpenRC file and from the Peerobyte Cloud Infrastructure service control panel, insert these data into your Terraform configuration file, and authenticate against the cloud infrastructure. You can also refer to the official HashiCorp documentation on configuring the OpenStack Provider for Terraform, available at the provided link.
Prerequisites
- Peerobyte Account.
You must have an account in the Peerobyte client portal. For instructions on how to register, see “Creating an Account”. - Cloud Infrastructure service is enabled.
You must have ordered the “Cloud Infrastructure” service and received a notification of its readiness either via the email associated with your account or in your Peerobyte client portal. For instructions on ordering the service, see “How to Order Cloud Infrastructure”.
I. Obtaining the Password from the Service Control Panel
Password for authentication is only available in the control panel of the Peerobyte cloud infrastructure service and can be obtained as follows:
- Log in to the Peerobyte Control Panel. For instructions on how to do this, see:
- a. If 2FA is not used, see “Logging in to the Control Panel”.
- b. If 2FA is enabled, see “Logging in to the Control Panel with 2FA”.
- Click “Services” in the main menu to navigate to “My Products & Services”.
- Select the cloud infrastructure service you wish to authenticate to.
- In the “Management Panel” section, click the “Click to copy” button (two-sheet icon) next to “Password”.
The password will be copied to your clipboard, confirmed by the message “The data has been successfully copied to the clipboard.”
II. Obtaining the OpenRC File
You can download the OpenRC file from the cloud infrastructure control panel (Horizon) by following these steps:
- Log in to the cloud infrastructure control panel (Horizon). For details, see “Logging in to the Cloud Infrastructure Control Panel (Horizon)”.
- Click the user menu in the top-right corner of the Horizon interface.
A drop-down menu of user actions will appear. - Select “Get OpenRC file” from the dropdown.
The “Get OpenRC file” window will open. - In the “Get OpenRC file” dialog, click the “Type” dropdown.
- Choose “Password Type”.
- Click “OK”.
A save dialog will appear. - Save the OpenRC file locally.
Important: This file contains credentials required to connect to your infrastructure and must be kept confidential.
III. Creating the Configuration File for Authentication
Terraform configuration files (.tf) must be UTF-8 encoded in HCL format. Use a plain-text editor supporting UTF-8, for example:
- Windows: VS Code, Notepad++, Sublime Text, IntelliJ IDEA
- macOS: VS Code, Sublime Text, IntelliJ IDEA, Vim, Nano
- Linux: VS Code, Sublime Text, IntelliJ IDEA, Vim, Nano, Gedit, Kate
Do not use: office editors (Word, LibreOffice, WordPad, Google Docs) as they save files in incompatible formats.
- Create a directory for your Terraform configurations.
- Create a file with the “.tf” extension, for example, “main.tf”.
- Add the following HCL structure:
terraform { required_version = ">= 0.14.0" required_providers { openstack = { source = "terraform-provider-openstack/openstack" version = "~> 1.53.0" } } } provider "openstack" { user_name = "<user_name>" password = "<password>" auth_url = "https://cli.peerobyte.com:5000/v3/" region = "RegionOne" domain_name = "<domain_name>" tenant_name = "<tenant_name>" }
- Open the OpenRC file downloaded in Section II.
- Replace the placeholder values in angle brackets <...> with the actual values for your project, excluding the brackets themselves, for the following parameters:
- password – the password obtained in Section I.
- user_name – set to the “OS_USERNAME” value from the OpenRC file.
- domain_name – set to the “OS_USER_DOMAIN_NAME” value from the OpenRC file obtained in Section II.
- tenant_name – set to the “OS_PROJECT_NAME” value from the OpenRC file.
- password – the password obtained in Section I.
Example result:
terraform { required_version = ">= 0.14.0" required_providers { openstack = { source = "terraform-provider-openstack/openstack" version = "~> 1.53.0" } } } provider "openstack" { user_name = "quofcquo" password = "5pi81Xd5pi" auth_url = "https://cli.peerobyte.com:5000/v3/" region = "RegionOne" domain_name = "my-domain-31-705-731-1746522131" tenant_name = "my-project-31-705-731" }
- Save the configuration file.
IV. Checking Authentication
Ensure that the credentials you have entered are correct and that Terraform can manage the Peerobyte cloud infrastructure. To verify authentication, connect to the cloud and request the project ID – successfully obtaining the identifier indicates that authentication was successful.
To verify authentication, perform the following steps:
- Open your configuration file for editing.
- Add these blocks to retrieve and output your project ID:
# Retrieve data about the existing project in Identity v3 by name data "openstack_identity_project_v3" "current" { name = "<project_name>" # OS_PROJECT_NAME from the OpenRC file } # Output the found project IDoutput "project_id" { value = data.openstack_identity_project_v3.current.id # Unique project identifier }
- Specify the value of the “name” parameter by replacing the <project_name> placeholder with the “OS_PROJECT_NAME” value from your OpenRC file.
- Save the changes to the configuration file.
- Open a terminal (Windows: PowerShell or CMD; macOS/Linux: Bash, Zsh, etc.).
- Navigate to your configuration directory, e.g.:
Linux/macOS:
cd /home/user/terraform/conf
cd "C:\Program Files\terraform\conf"
- Initialize Terraform:
terraform init
You should see:
Terraform has been successfully initialized!
- Run the plan to verify authentication:
terraform plan
On success, you’ll see your project’s unique ID, e.g.:
project_id = "e905701a98324d3398b5365707905701"
- Remove the blocks added in step 2 (they are only needed for verification) and save your changes.
What’s Next?
You can now build out your cloud infrastructure by following the examples in the “Quick Start with Terraform".