Skip to content

Commit

Permalink
Minor updates in README and Terraform scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ravired5 committed Oct 10, 2023
1 parent 8f42f73 commit 0db2bcf
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 205 deletions.
254 changes: 100 additions & 154 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions example/autoscale/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
* Confirm changes by clicking 'OK' and close all open windows.
* Open a new terminal and verify that Terraform has been successfully installed.

* Install **DO CLI** https://docs.digitalocean.com/reference/doctl/how-to/install/
* Install **Digital Ocean CLI** https://docs.digitalocean.com/reference/doctl/how-to/install/
* Install **jq** Linux or Mac OS only - `apt install jq` or `brew install jq` (It is using in bash scripts to create/delete Stream Manager node group using API)
* Download Red5 Pro server build: (Example: red5pro-server-0.0.0.b0-release.zip) https://account.red5pro.com/downloads
* Download Red5 Pro Terraform controller for DO: (Example: terraform-cloud-controller-0.0.0.jar) https://account.red5pro.com/downloads
* Download Red5 Pro Terraform controller for Digital Ocean: (Example: terraform-cloud-controller-0.0.0.jar) https://account.red5pro.com/downloads
* Download Red5 Pro Terraform Service : (Example: terraform-service-0.0.0.zip) https://account.red5pro.com/downloads
* Get Red5 Pro License key: (Example: 1111-2222-3333-4444) https://account.red5pro.com
* Get DO API key or use existing (To access Digital Ocean Cloud)
* Get Digital Ocean API key or use existing (To access Digital Ocean Cloud)
* Copy Red5 Pro server build, Terraform service and Terraform controller to the root folder of your project

Example:
Expand Down
14 changes: 7 additions & 7 deletions example/autoscale/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ provider "digitalocean" {
}

module "red5pro_autoscale" {
source = "../../"
do_token = "" # Digital Ocean token
do_region = "" # Digital Ocean region where resources will create eg: blr1
type = "autoscaling" # Deployment type: single, cluster, autoscaling
name = "" # Name to be used on all the resources as identifier
do_project = true # Create a new project in Digital Ocean
project_name = "Example-Project" # New Project name in digital Ocean
source = "../../"
digital_ocean_token = "" # Digital Ocean token
digital_ocean_region = "" # Digital Ocean region where resources will create eg: blr1
type = "autoscaling" # Deployment type: single, cluster, autoscaling
name = "" # Name to be used on all the resources as identifier
digital_ocean_project = true # Create a new project in Digital Ocean
project_name = "Example-Project" # New Project name in digital Ocean

path_to_red5pro_build = "./red5pro-server-0.0.0.0-release.zip" # Absolute path or relative path to Red5 Pro server ZIP file
path_to_terraform_cloud_controller = "./terraform-cloud-controller-0.0.0.jar" # Absolute path or relative path to terraform cloud controller jar file
Expand Down
6 changes: 3 additions & 3 deletions example/clustered/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
* Confirm changes by clicking 'OK' and close all open windows.
* Open a new terminal and verify that Terraform has been successfully installed.

* Install **DO CLI** https://docs.digitalocean.com/reference/doctl/how-to/install/
* Install **Digital Ocean CLI** https://docs.digitalocean.com/reference/doctl/how-to/install/
* Install **jq** Linux or Mac OS only - `apt install jq` or `brew install jq` (It is using in bash scripts to create/delete Stream Manager node group using API)
* Download Red5 Pro server build: (Example: red5pro-server-0.0.0.b0-release.zip) https://account.red5pro.com/downloads
* Download Red5 Pro Terraform controller for DO: (Example: terraform-cloud-controller-0.0.0.jar) https://account.red5pro.com/downloads
* Download Red5 Pro Terraform controller for Digital Ocean: (Example: terraform-cloud-controller-0.0.0.jar) https://account.red5pro.com/downloads
* Download Red5 Pro Terraform Service : (Example: terraform-service-0.0.0.zip) https://account.red5pro.com/downloads
* Get Red5 Pro License key: (Example: 1111-2222-3333-4444) https://account.red5pro.com
* Get DO API key or use existing (To access Digital Ocean Cloud)
* Get Digital Ocean API key or use existing (To access Digital Ocean Cloud)
* Copy Red5 Pro server build, Terraform service and Terraform controller to the root folder of your project

Example:
Expand Down
15 changes: 7 additions & 8 deletions example/clustered/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ provider "digitalocean" {
}

module "red5pro_cluster" {
source = "../../"
do_token = "" # Digital Ocean token
do_region = "" # Digital Ocean region where resources will create eg: blr1

type = "cluster" # Deployment type: single, cluster, autoscaling
name = "" # Name to be used on all the resources as identifier
do_project = true # Create a new project in Digital Ocean
project_name = "Example-Project" # New Project name in digital Ocean
source = "../../"
digital_ocean_token = "" # Digital Ocean token
digital_ocean_region = "" # Digital Ocean region where resources will create eg: blr1
type = "cluster" # Deployment type: single, cluster, autoscaling
name = "" # Name to be used on all the resources as identifier
digital_ocean_project = true # Create a new project in Digital Ocean
project_name = "Example-Project" # New Project name in digital Ocean


path_to_red5pro_build = "./red5pro-server-0.0.0.0-release.zip" # Absolute path or relative path to Red5 Pro server ZIP file
Expand Down
4 changes: 2 additions & 2 deletions example/single/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
* Confirm changes by clicking 'OK' and close all open windows.
* Open a new terminal and verify that Terraform has been successfully installed.

* Install **DO CLI** https://docs.digitalocean.com/reference/doctl/how-to/install/
* Install **Digital Ocean CLI** https://docs.digitalocean.com/reference/doctl/how-to/install/
* Install **jq** Linux or Mac OS only - `apt install jq` or `brew install jq` (It is using in bash scripts to create/delete Stream Manager node group using API)
* Download Red5 Pro server build: (Example: red5pro-server-0.0.0.b0-release.zip) https://account.red5pro.com/downloads
* Get Red5 Pro License key: (Example: 1111-2222-3333-4444) https://account.red5pro.com
* Get DO API key or use existing (To access Digital Ocean Cloud)
* Get Digital Ocean API key or use existing (To access Digital Ocean Cloud)
* Copy Red5 Pro server build to the root folder of your project

Example:
Expand Down
12 changes: 6 additions & 6 deletions example/single/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ provider "digitalocean" {
}

module "red5pro" {
source = "../../"
do_region = "" # Digital Ocean region where resources will create eg: blr1
source = "../../"
digital_ocean_region = "" # Digital Ocean region where resources will create eg: blr1

type = "single" # Deployment type: single, cluster, autoscaling
name = "" # Name to be used on all the resources as identifier
do_project = true # Create a new project in Digital Ocean
project_name = "Exaple-Project" # New Project name in digital Ocean
type = "single" # Deployment type: single, cluster, autoscaling
name = "" # Name to be used on all the resources as identifier
digital_ocean_project = true # Create a new project in Digital Ocean
project_name = "Exaple-Project" # New Project name in digital Ocean

path_to_red5pro_build = "./red5pro-server-0.0.0.0-release.zip" # Absolute path or relative path to Red5 Pro server ZIP file

Expand Down
36 changes: 18 additions & 18 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ locals {
# PROJECT SETUP IN DIGITAL OCEAN
################################################################################
resource "digitalocean_project" "do_project" {
count = var.do_project ? 1 : 0
count = var.digital_ocean_project ? 1 : 0
name = var.project_name
purpose = "Red5Pro Deployments"
environment = "Production"
Expand Down Expand Up @@ -104,7 +104,7 @@ data "digitalocean_ssh_key" "ssh_key_pair" {
resource "digitalocean_vpc" "red5pro_vpc" {
count = var.vpc_create ? 1 : 0
ip_range = "10.5.0.0/16"
region = var.do_region
region = var.digital_ocean_region
name = "${var.name}-vpc"
}

Expand All @@ -120,7 +120,7 @@ data "digitalocean_vpc" "selected" {
resource "digitalocean_droplet" "red5pro_single" {
count = local.single ? 1 : 0
name = "${var.name}-red5-single"
region = var.do_region
region = var.digital_ocean_region
size = var.single_droplet_size
image = "ubuntu-20-04-x64"
ssh_keys = [local.ssh_key]
Expand Down Expand Up @@ -245,7 +245,7 @@ resource "digitalocean_firewall" "red5pro_sm_fw" {
resource "digitalocean_droplet" "red5pro_sm" {
count = local.cluster || local.autoscaling ? 1 : 0
name = "${var.name}-red5-sm"
region = var.do_region
region = var.digital_ocean_region
size = var.stream_manager_droplet_size
image = "ubuntu-20-04-x64"
ssh_keys = [local.ssh_key]
Expand Down Expand Up @@ -301,7 +301,7 @@ resource "digitalocean_droplet" "red5pro_sm" {
"export TERRA_HOST='${local.terra_host}'",
"export TERRA_API_TOKEN='${var.terra_api_token}'",
"export TERRA_PARALLELISM='${var.terra_parallelism}'",
"export DO_API_TOKEN='${var.do_token}'",
"export DO_API_TOKEN='${var.digital_ocean_token}'",
"export SSH_KEY_NAME='${local.ssh_key_name}'",
"export DB_HOST='${local.mysql_host}'",
"export DB_PORT='${local.mysql_port}'",
Expand Down Expand Up @@ -335,7 +335,7 @@ resource "digitalocean_droplet" "red5pro_sm" {
resource "digitalocean_database_cluster" "red5pro_mysql" {
count = local.mysql_db_system_create ? 1 : 0
name = "${var.name}-mysql-sm-db"
region = var.do_region
region = var.digital_ocean_region
version = "8"
size = var.mysql_database_size
node_count = 1
Expand Down Expand Up @@ -364,7 +364,7 @@ resource "digitalocean_database_firewall" "database_fw" {
resource "digitalocean_droplet" "red5pro_terraform_service" {
count = local.dedicated_terra_host_create ? 1 : 0
name = "${var.name}-red5-terraform-service"
region = var.do_region
region = var.digital_ocean_region
size = var.terraform_service_droplet_size
image = "ubuntu-20-04-x64"
ssh_keys = [local.ssh_key]
Expand Down Expand Up @@ -396,7 +396,7 @@ resource "digitalocean_droplet" "red5pro_terraform_service" {
inline = [
"sudo iptables -F",
"sudo cloud-init status --wait",
"export DO_API_TOKEN='${var.do_token}'",
"export DO_API_TOKEN='${var.digital_ocean_token}'",
"export SSH_KEY_NAME='${local.ssh_key_name}'",
"export TERRA_HOST='${self.ipv4_address}'",
"export TERRA_API_TOKEN='${var.terra_api_token}'",
Expand Down Expand Up @@ -450,7 +450,7 @@ resource "digitalocean_firewall" "red5pro_terraform_service_fw" {
resource "digitalocean_loadbalancer" "red5pro_lb" {
count = local.autoscaling ? 1 : 0
name = "${var.name}-red5pro-lb"
region = var.do_region
region = var.digital_ocean_region
size_unit = var.lb_size_count

forwarding_rule {
Expand Down Expand Up @@ -505,7 +505,7 @@ resource "digitalocean_certificate" "new_lb_cert" {
resource "digitalocean_droplet" "red5pro_origin_node" {
count = var.origin_image_create ? 1 : 0
name = "${var.name}-node-origin-image"
region = var.do_region
region = var.digital_ocean_region
size = var.origin_image_droplet_size
image = "ubuntu-20-04-x64"
ssh_keys = [local.ssh_key]
Expand Down Expand Up @@ -570,7 +570,7 @@ resource "digitalocean_droplet" "red5pro_origin_node" {
resource "digitalocean_droplet" "red5pro_edge_node" {
count = var.edge_image_create ? 1 : 0
name = "${var.name}-node-edge-image"
region = var.do_region
region = var.digital_ocean_region
size = var.edge_image_droplet_size
image = "ubuntu-20-04-x64"
ssh_keys = [local.ssh_key]
Expand Down Expand Up @@ -635,7 +635,7 @@ resource "digitalocean_droplet" "red5pro_edge_node" {
resource "digitalocean_droplet" "red5pro_transcoder_node" {
count = var.transcoder_image_create ? 1 : 0
name = "${var.name}-node-transcoder-image"
region = var.do_region
region = var.digital_ocean_region
size = var.transcoder_image_droplet_size
image = "ubuntu-20-04-x64"
ssh_keys = [local.ssh_key]
Expand Down Expand Up @@ -700,7 +700,7 @@ resource "digitalocean_droplet" "red5pro_transcoder_node" {
resource "digitalocean_droplet" "red5pro_relay_node" {
count = var.relay_image_create ? 1 : 0
name = "${var.name}-node-relay-image"
region = var.do_region
region = var.digital_ocean_region
size = var.relay_image_droplet_size
image = "ubuntu-20-04-x64"
ssh_keys = [local.ssh_key]
Expand Down Expand Up @@ -803,31 +803,31 @@ resource "digitalocean_droplet_snapshot" "relay-snapshot" {
resource "null_resource" "stop_node_origin" {
count = var.origin_image_create ? 1 : 0
provisioner "local-exec" {
command = "doctl compute droplet delete ${digitalocean_droplet.red5pro_origin_node[0].id} -f --access-token ${var.do_token}"
command = "doctl compute droplet delete ${digitalocean_droplet.red5pro_origin_node[0].id} -f --access-token ${var.digital_ocean_token}"
}
depends_on = [digitalocean_droplet_snapshot.origin-snapshot]
}
# Stop Edge Node droplet using DO CLI
resource "null_resource" "stop_node_edge" {
count = var.edge_image_create ? 1 : 0
provisioner "local-exec" {
command = "doctl compute droplet delete ${digitalocean_droplet.red5pro_edge_node[0].id} -f --access-token ${var.do_token}"
command = "doctl compute droplet delete ${digitalocean_droplet.red5pro_edge_node[0].id} -f --access-token ${var.digital_ocean_token}"
}
depends_on = [digitalocean_droplet_snapshot.edge-snapshot]
}
# Stop Transcoder Node droplet using DO CLI
resource "null_resource" "stop_node_transcoder" {
count = var.transcoder_image_create ? 1 : 0
provisioner "local-exec" {
command = "doctl compute droplet delete ${digitalocean_droplet.red5pro_transcoder_node[0].id} -f --access-token ${var.do_token}"
command = "doctl compute droplet delete ${digitalocean_droplet.red5pro_transcoder_node[0].id} -f --access-token ${var.digital_ocean_token}"
}
depends_on = [digitalocean_droplet_snapshot.transcoder-snapshot]
}
# Stop Relay Node droplet using DO CLI
resource "null_resource" "stop_node_relay" {
count = var.relay_image_create ? 1 : 0
provisioner "local-exec" {
command = "doctl compute droplet delete ${digitalocean_droplet.red5pro_relay_node[0].id} -f --access-token ${var.do_token}"
command = "doctl compute droplet delete ${digitalocean_droplet.red5pro_relay_node[0].id} -f --access-token ${var.digital_ocean_token}"
}
depends_on = [digitalocean_droplet_snapshot.relay-snapshot]
}
Expand All @@ -850,7 +850,7 @@ resource "null_resource" "node_group" {
NAME = "${var.name}"
SM_IP = "${local.stream_manager_ip}"
SM_API_KEY = "${var.stream_manager_api_key}"
NODE_GROUP_REGION = "${var.do_region}"
NODE_GROUP_REGION = "${var.digital_ocean_region}"
NODE_GROUP_NAME = "${var.node_group_name}"
ORIGINS = "${var.node_group_origins}"
EDGES = "${var.node_group_edges}"
Expand Down
2 changes: 1 addition & 1 deletion output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ output "node_relay_image" {

output "digital_ocean_project" {
description = "Digital Ocean project where resources will be created"
value = var.do_project ? var.project_name : null
value = var.digital_ocean_project ? var.project_name : null
}

output "ssh_key_name" {
Expand Down
6 changes: 3 additions & 3 deletions variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ variable "name" {
}
}

variable "do_project" {
variable "digital_ocean_project" {
description = "Create a new project in Digital Ocean to access all created resources. true = create new project, false = use default project in DO."
default = true
}
Expand Down Expand Up @@ -40,12 +40,12 @@ variable "path_to_red5pro_build" {
}

# Digital Ocean configuration
variable "do_region" {
variable "digital_ocean_region" {
description = "DO region to deploy the resources"
default = ""
}

variable "do_token" {
variable "digital_ocean_token" {
description = "DO token to access the services of cloud"
default = ""
}
Expand Down

0 comments on commit 0db2bcf

Please sign in to comment.