OpenStack Terraform Example
This guide provides an example of how to use Terraform with SysEleven's OpenStack service.
Prerequisites
- An OpenStack project
- A SysEleven Service Account with the
OpenStack Editorpermission
Steps
We will use Terraform in this example. Please refer to the official installation instructions to install Terraform.
- Create a new directory for your Terraform configuration:
- Navigate to the
simple-instancedirectory:
Here, execute the following command to patch the example:
- Configure OpenStack Access
unset HISTFILE
unset $(set | grep OS_ | sed 's/=.*//')
export KEYSTONE_ORIGIN="https://keystone.cloud.syseleven.net:5000"
export OS_AUTH_URL="$KEYSTONE_ORIGIN/v3"
export OS_REGION_NAME=dus2 # or ham1
export OS_AUTH_TYPE=v3applicationcredential
export OS_APPLICATION_CREDENTIAL_ID=s11auth:${PROJECT_ID}
export OS_APPLICATION_CREDENTIAL_SECRET="s11_orgsa_<uuid>_<secret>"
Of course, you can configure the OpenStack Provider via Terraform Files, too. Please refer to this documentation for more details. You will be using application_credential_id and application_credential_secret in the provider "openstack" block.
- Initialize Terraform
- Apply the Terraform configuration
When prompted, input your public SSH key. You should see the output of the Terraform configuration. Verify in the SysEleven Dashboard that the instances have been created.
- Destroy the Terraform configuration
Example Configuration
Here's an example Terraform configuration file using application credentials for authentication with the OpenStack provider, which you can use as a starting point for your own configurations.
variable "project_id" {
description = "Project ID for SysEleven"
type = string
default = "c86fbc858f9949e0ab3e8f8c3d40104b"
}
variable "s11_service_account" {
description = "Service Account credentials for SysEleven authentication"
type = string
default = "s11_orgsa_<uuid>_<secret>"
}
variable "region" {
description = "Region for SysEleven OpenStack"
type = string
default = "dus2"
}
# Define required providers
terraform {
required_version = ">= 0.14.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.53.0"
}
}
}
# Configure the OpenStack Provider
provider "openstack" {
auth_url = "https://keystone.cloud.syseleven.net:5000/v3"
region = var.region
application_credential_id = "s11auth:${var.project_id}"
application_credential_secret = var.s11_service_account
}
# Create a web server (example resource)
resource "openstack_compute_instance_v2" "test-server" {
# ... (resource configuration)
}