Initial commit
						commit
						7d89f2a56f
					
				@ -0,0 +1,41 @@
 | 
			
		||||
terraform {
 | 
			
		||||
  required_version = ">= 1.0"
 | 
			
		||||
 | 
			
		||||
  required_providers {
 | 
			
		||||
    aws = {
 | 
			
		||||
      source  = "coder/coder"
 | 
			
		||||
      version = ">= 0.11"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "agent_id" {
 | 
			
		||||
    type = string
 | 
			
		||||
    description = "The ID of a Coder agent."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "extensions" {
 | 
			
		||||
    type = list(string)
 | 
			
		||||
    description = "A list of extensions to install."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "port" {
 | 
			
		||||
    type = number
 | 
			
		||||
    description = "The port to run code-server on."
 | 
			
		||||
    default = 13337
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "settings" {
 | 
			
		||||
    type = map(string)
 | 
			
		||||
    description = "A map of settings to apply to code-server."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
data "http" "code-server-install" {
 | 
			
		||||
    url = "https://raw.githubusercontent.com/coder/code-server/main/install.sh"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
resource "coder_script" "code-server" {
 | 
			
		||||
    agent_id = var.agent_id
 | 
			
		||||
    script = data.http.code-server-install.body
 | 
			
		||||
    run_on_start = true
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,31 @@
 | 
			
		||||
terraform {
 | 
			
		||||
  required_version = ">= 1.0"
 | 
			
		||||
 | 
			
		||||
  required_providers {
 | 
			
		||||
    coder = {
 | 
			
		||||
      source  = "terraform.local/coder/coder"
 | 
			
		||||
      version = ">= 0.12"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "agent_id" {
 | 
			
		||||
    type = string
 | 
			
		||||
    description = "The ID of a Coder agent."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "path" {
 | 
			
		||||
    type = string
 | 
			
		||||
    description = "The path to a script that will be ran on start enabling a user to personalize their workspace."
 | 
			
		||||
    default = "~/personalize"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
resource "coder_script" "personalize" {
 | 
			
		||||
    agent_id = var.agent_id
 | 
			
		||||
    source = templatefile("run.sh", {
 | 
			
		||||
        path: var.path,
 | 
			
		||||
    })
 | 
			
		||||
    display_name = "Personalize"
 | 
			
		||||
    icon = "/emojis/1f58c.png"
 | 
			
		||||
    run_on_start = true
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,23 @@
 | 
			
		||||
#!/usr/bin/env sh
 | 
			
		||||
 | 
			
		||||
PERSONALIZE_PATH=${path}
 | 
			
		||||
 | 
			
		||||
# If the personalize script doesn't exist, educate
 | 
			
		||||
# the user how they can customize their environment!
 | 
			
		||||
if [ ! -f ${PERSONALIZE_PATH}/personalize.sh ]; then
 | 
			
		||||
    echo "✨ You don't have a personalize script!"
 | 
			
		||||
    echo "Run \`touch ${PERSONALIZE_PATH}\` to create one."
 | 
			
		||||
    echo "Developers typically install their favorite packages here that may not be included in the base image."
 | 
			
		||||
    exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Check if the personalize script is executable, if not,
 | 
			
		||||
# try to make it executable and educate the user if it fails.
 | 
			
		||||
if [ ! -x ${PERSONALIZE_PATH}/personalize.sh ]; then
 | 
			
		||||
    echo "🔐 Your personalize script isn't executable!"
 | 
			
		||||
    echo "Run \`chmod +x ${PERSONALIZE_PATH}\` to make it executable."
 | 
			
		||||
    exit 0
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Run the personalize script!
 | 
			
		||||
exec $PERSONALIZE_PATH
 | 
			
		||||
@ -0,0 +1,30 @@
 | 
			
		||||
terraform {
 | 
			
		||||
  required_version = ">= 1.0"
 | 
			
		||||
 | 
			
		||||
  required_providers {
 | 
			
		||||
    aws = {
 | 
			
		||||
      source  = "coder/coder"
 | 
			
		||||
      version = ">= 0.11"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
variable "agent_id" {
 | 
			
		||||
  type        = string
 | 
			
		||||
  description = "The ID of a Coder agent."
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
data "coder_workspace" "me" {}
 | 
			
		||||
 | 
			
		||||
resource "coder_app" "vscode" {
 | 
			
		||||
	agent_id = var.agent_id
 | 
			
		||||
	external = true
 | 
			
		||||
	url = join("", [
 | 
			
		||||
		"vscode://coder.coder-remote/open?owner=",
 | 
			
		||||
		data.coder_workspace.me.owner,
 | 
			
		||||
		"&workspace=",
 | 
			
		||||
		data.coder_workspace.me.name,
 | 
			
		||||
		"&token=",
 | 
			
		||||
		data.coder_workspace.me.owner_session_token,
 | 
			
		||||
	])
 | 
			
		||||
}  
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue