User Guide: Terraform - EyevinnOSC/community GitHub Wiki
How to get started with Terraform for cloud automation with Eyevinn Open Source Cloud
A complete documentation for the OSC Terraform provider can be found at https://registry.terraform.io/providers/EyevinnOSC/osc/latest/docs
- An Open Source Cloud account
- Terraform or OpenTofu installed
The following example describes a simple OSC Terraform configuration file.
It should be written to a file with the extension .tf
in your working directory.
terraform {
required_providers {
osc = {
source = "EyevinnOSC/osc"
version = "0.1.3"
}
}
}
variable "osc_pat" {
type = string
sensitive = true
}
provider "osc" {
pat = var.osc_pat
// Optional
// environment = "prod"
}
resource "osc_encore_instance" "my_instance" {
name = "terraform_test"
profiles_url = "https://raw.githubusercontent.com/Eyevinn/encore-test-profiles/refs/heads/main/profiles.yml"
}
Terraform uses variables to handle sensitive input such as secrets and tokens. To use OSC you will need to provide your OSC Personal Access Token.
It can either be provided inline using the -var
flag or as an environment variable.
The enviroment variable must be prefixed with TF_VAR_
followed by the variable name. In our case it should be export TF_VAR_osc_pat=<PAT>
.
In your working directory, enter the following lines and answer the prompts to download the OSC provider and create your resources.
terraform init
terraform apply -var <PAT>
When completed you should be able to find your running instance in the web app.
When you want to tear down your running instances simply enter the following command while in your working directory.
terraform destroy
As an example, the following configuration can be used to quickly set up an Encore video transcoding pipeline. Notice that this configuration also requires AWS credentials as well as an S3 output provided as variables.
terraform {
required_providers {
osc = {
source = "EyevinnOSC/osc"
version = "0.1.3"
}
}
}
variable "osc_pat" {
type = string
sensitive = true
}
variable "osc_environment" {
type = string
default = "prod"
}
variable "aws_keyid" {
type = string
sensitive = true
}
variable "aws_secret" {
type = string
sensitive = true
}
variable "aws_output" {
type = string
}
provider "osc" {
pat = var.osc_pat
environment = var.osc_environment
}
resource "osc_encore_instance" "example" {
name = "ggexample"
profiles_url = "https://raw.githubusercontent.com/Eyevinn/encore-test-profiles/refs/heads/main/profiles.yml"
}
resource "osc_valkey_instance" "example" {
name = "ggexample"
}
resource "osc_encore_callback_instance" "example" {
name = "ggexample"
redis_url = format("redis://%s:%s", osc_valkey_instance.example.external_ip, osc_valkey_instance.example.external_port)
encore_url = trimsuffix(osc_encore_instance.example.url, "/")
redis_queue = "transfer"
}
resource "osc_secret" "keyid" {
service_ids = ["eyevinn-docker-retransfer"]
secret_name = "awsaccesskeyid"
secret_value = var.aws_keyid
}
resource "osc_secret" "secret" {
service_ids = ["eyevinn-docker-retransfer"]
secret_name = "awssecretaccesskey"
secret_value = var.aws_secret
}
resource "osc_encore_transfer_instance" "example" {
name = "ggexample"
redis_url = osc_encore_callback_instance.example.redis_url
redis_queue = osc_encore_callback_instance.example.redis_queue
output = var.aws_output
aws_keyid = osc_secret.keyid.secret_name
aws_secret = osc_secret.secret.secret_name
osc_token = var.osc_pat
}
output "encore_url" {
value = trimsuffix(osc_encore_instance.example.url, "/")
}
output "encore_name" {
value = osc_encore_instance.example.name
}
output "callback_url" {
value = trimsuffix(osc_encore_callback_instance.example.url, "/")
}