Open matifali opened 1 year ago
Thanks for raising @matifali
What is your terraform configuration, are you able to share your terraform
files?
I think, given where it's broken, it's failing to find a user which an email address you provided in the provider "render"
block. Can you confirm if there's an existing user with that email address?
I've pushed up a new version with additional logging and error handling around this area to avoid the nil reference error
Yes sure. I am actually trying to write a terraform template for https://github.com/coder/coder. I will post my terraform code later today.
Sorry for being late; I had been quite busy. Here is my complete terraform code; I am getting the same error.
terraform {
required_providers {
render = {
source = "jackall3n/render"
# version = "1.1.1"
}
coder = {
source = "coder/coder"
}
}
}
provider "render" {
# setting empty values to null will cause the provider to use the environment variables
api_key = var.render_api_key == "" ? null : var.render_api_key
email = var.render_email == "" ? null : var.render_email
}
provider "coder" {
feature_use_managed_variables = true
}
variable "render_api_key" {
type = string
description = <<-EOF
Your Render api key, created in the render.com Account Settings. If not supplied, RENDER_API_KEY is used.
You can generate one by going to: Account Settings > API Keys > Create API Key
EOF
sensitive = true
}
variable "render_email" {
type = string
description = <<-EOF
Your Render email. This is used as a default owner in all services where no owner is specified. If not supplied, RENDER_EMAIL is used.
EOF
sensitive = true
}
resource "render_service" "workspace" {
count = data.coder_workspace.me.start_count
name = data.coder_workspace.me.name
repo = "https://github.com/matifali/render-docker-build"
type = "private_service"
private_service_details = {
env = "docker"
disk = {
name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}-home"
mount_path = "/home/coder"
size_gb = data.coder_parameter.volume-size.value
}
}
}
data "coder_parameter" "volume-size" {
name = "Volume Size"
description = "The size of the volume to create for the workspace in GB (1-20)"
type = "number"
default = "1"
icon = "https://raw.githubusercontent.com/matifali/logos/main/database.svg"
validation {
min = 1
max = 20
}
}
data "coder_parameter" "region" {
name = "Region"
description = "The region to deploy the workspace in"
default = "oregon"
icon = "/emojis/1f30e.png"
option {
name = "Frankfurt, Germany"
value = "frankfurt"
icon = "/emojis/1f1e9-1f1ea.png"
}
option {
name = "Oregon, USA"
value = "oregon"
icon = "/emojis/1f1fa-1f1f8.png"
}
}
resource "coder_app" "code-server" {
count = 1
agent_id = coder_agent.main.id
display_name = "Code Server"
slug = "code-server"
url = "http://localhost:8080?folder=/home/coder/"
icon = "/icon/code.svg"
subdomain = false
share = "owner"
healthcheck {
url = "http://localhost:8080/healthz"
interval = 3
threshold = 10
}
}
resource "coder_agent" "main" {
arch = data.coder_provisioner.me.arch
os = "linux"
login_before_ready = false
startup_script_timeout = 180
startup_script = <<-EOT
set -e
# Start code-server
code-server --auth none >/tmp/code-server.log 2>&1 &
# Set the hostname to the workspace name
sudo hostname -b "${data.coder_workspace.me.name}-render"
EOT
}
data "coder_provisioner" "me" {
}
data "coder_workspace" "me" {
}
@matifali, found a workaround of sorts:
variable "render_api_token" {
sensitive = true
}
variable "render_user_email" {
sensitive = true
}
provider "render" {
api_key = var.render_api_token
}
data "render_owner" "render_owner" {
email = var.render_user_email
}
resource "render_service" "my_service" {
name = "my_service"
repo = var.my_service_repo
branch = var.my_service_branch
owner = data.render_owner.render_owner.id
...