New version of the Terraform-provider-leostream
Introducing Terraform Provider for Leostream v0.1.3
We are excited to announce the release of version 0.1.3 of the Terraform Provider for Leostream. This release brings enhancements and stability improvements that enable you to efficiently manage your Leostream environments with Infrastructure as Code (IaC). Whether you’re provisioning resources, managing configurations, or automating your workflows, this provider empowers you to integrate Leostream seamlessly into your Terraform-powered deployments.
What’s New in Version 0.1.3?
This release includes:
- New Leostream Resource: Added Leostream Pool Assigment
- New and improved Leostream Datasources: Added Leostream Policy lookup and fixed Center data lookups
- Improved Stability: Addressed bugs for smoother automation in production environments.
- Extensive Documentation: Clearer guidance and examples to help you onboard quickly.
Getting Started with the Leostream Provider
Below is a practical example of how to use the Leostream Terraform provider to define and provision resources. Let’s break down the example found in the .tf files.
Step 1: Setting Up the Provider
The terraform block contains the setup for the Leostream Provider:
terraform {
required_providers {
leostream = {
source = "registry.terraform.io/hocmodo/leostream"
}
}
}
The provider block specifies the Leostream provider configuration:
provider "leostream" {
host = var.api_url
username = var.username
password = var.password
}
host: The endpoint for your Leostream API.username&password: Authentication credentials for your Leostream deployment.
These variables are defined in variables.tf for easy reuse and centralized management. You can input them when running the Terraform CLI, or provide them via environment variables or a separate .tf file.
Step 2: Defining a Center
A center in Leostream represents a location where virtual machines or systems are hosted. Currently only amazon type centers are supported. Here’s how we define one:
resource "leostream_center" "example_center" {
name = "example-center"
type = "amazon"
allow_rogue_policy_id = 0
vc_datacenter = "us-east-1"
vc_name = var.center_aws_key
vc_password = var.center_password
vc_auth_method = "access_key"
}
name: Human-readable identifier for the center.type: Specifies the type of center (e.g.,vmware,azure,aws).allow_rogue_policy_id: A number value for the id of a policy for rogue user.vc_datacenter: Name of the AWS region for the centervc_name: AWS access keyvc_password: AWS secret keyvc_auth_method: Type of authentication
Step 3: Creating a Pool
Pools in Leostream group and manage resources for end-users. Below is an example of defining a pool:
resource "leostream_pool" "example_pool" {
name = "example-pool"
description = "Pool of VMs for development"
center_id = leostream_center.example_center.id
}
name: The name of the pool.center_id: Links the pool to the previously created center.
Step 4: Outputting Useful Information
To simplify debugging and resource referencing, use output blocks:
output "center_id" {
value = leostream_center.example_center.id
}
This outputs the id of the created center, which can be reused in other resources or modules.
Full Example
Here’s a complete snippet combining main.tf and variables.tf for managing Leostream resources:
main.tf
terraform {
required_providers {
leostream = {
source = "registry.terraform.io/hocmodo/leostream"
}
}
}
provider "leostream" {
host = var.api_url
username = var.username
password = var.password
}
resource "leostream_center" "example_center" {
name = "example-center"
type = "amazon"
allow_rogue_policy_id = 0
vc_datacenter = "us-east-1"
vc_name = var.center_aws_key
vc_password = var.center_password
vc_auth_method = "access_key"
}
resource "leostream_pool" "example_pool" {
name = "example-pool"
description = "Pool of VMs for development"
center_id = leostream_center.example_center.id
}
output "center_id" {
value = leostream_center.example_center.id
}
variables.tf
# Copyright (c) HashiCorp, Inc.
variable "center_name" {
description = "Name of LeoStream Center"
type = string
sensitive = false
default = "aws-center-us-east-1"
}
variable "pool_image_name" {
description = "Name of the image"
type = string
sensitive = false
default = "emr 5.23.0-ami-roller-7 hvm ebs"
}
variable "desktop_type" {
description = "Type of desktop"
type = string
sensitive = false
default = "t2.micro"
}
variable "aws_sec_group_id" {
description = "AWS security group"
type = string
sensitive = false
default = "sg-b1c127f6"
}
variable "aws_vpc_id" {
description = "AWS security group"
type = string
sensitive = false
default = "vpc-9c880fe6"
}
variable "aws_iam_name" {
description = "AWS IAM name"
type = string
sensitive = false
default = "leostream-desktop"
}
variable "aws_sub_net" {
description = "AWS subnet"
type = string
sensitive = false
default = "subnet-09bd8643/vpc-9c880fe6/us-east-1d/,subnet-15daf71a/vpc-9c880fe6/us-east-1f/"
}
variable "center_password" {
description = "AWS center password"
type = string
sensitive = true
}
variable "center_aws_key" {
description = "AWS center key"
type = string
sensitive = true
}
variable "leostream_api_password" {
description = "Leostream API password"
type = string
sensitive = true
}
Next Steps
- Install the Provider: Use
terraform initto download the provider. - Run the Example: Customize the
variables.tffile with your specific values. - Validate and Apply: Execute
terraform applyto provision your Leostream resources.
Learn More
For further details, refer to the official Terraform Registry documentation. Stay tuned for future updates and features!
Happy provisioning! 🚀