started coder-login
parent
5e805fef02
commit
aac27055e6
@ -0,0 +1,18 @@
|
||||
---
|
||||
display_name: Coder Login
|
||||
description: Automatically logs the user into Coder on their workspace
|
||||
icon: /emojis/1f511.png
|
||||
maintainer_github: coder
|
||||
verified: true
|
||||
tags: [helper]
|
||||
---
|
||||
|
||||
# Coder Login
|
||||
|
||||
Automatically logs the user into Coder when creating their workspace.
|
||||
|
||||
```hcl
|
||||
module "coder-login" {
|
||||
agent_id = coder_agent.example.id
|
||||
}
|
||||
```
|
@ -0,0 +1,39 @@
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
coder = {
|
||||
source = "coder/coder"
|
||||
version = ">= 0.12"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "agent_id" {
|
||||
type = string
|
||||
description = "The ID of a Coder agent."
|
||||
}
|
||||
|
||||
variable "coder_user_token" {
|
||||
type = string
|
||||
description = "Coder user token for authentication. Replace with second agent?"
|
||||
}
|
||||
|
||||
variable "coder_deployment_url" {
|
||||
type = string
|
||||
description = "Coder Deployment URL,"
|
||||
}
|
||||
|
||||
|
||||
resource "coder_script" "personalize" {
|
||||
agent_id = var.agent_id
|
||||
script = templatefile("${path.module}/run.sh", {
|
||||
CODER_USER_TOKEN : var.coder_user_token,
|
||||
CODER_DEPLOYMENT_URL : var.coder_deployment_url
|
||||
})
|
||||
display_name = "Personalize"
|
||||
icon = "/icon/personalize.svg"
|
||||
log_path = var.log_path
|
||||
run_on_start = true
|
||||
start_blocks_login = true
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Logs the coder user in
|
||||
|
||||
echo "Logging into Coder..."
|
||||
|
||||
# Automatically authenticate the user if they are not
|
||||
# logged in to another deployment
|
||||
if ! coder list >/dev/null 2>&1; then
|
||||
set +x; coder login --token=$CODER_USER_TOKEN --url=$CODER_DEPLOYMENT_URL
|
||||
else
|
||||
echo "You are already authenticated with coder"
|
||||
fi
|
Loading…
Reference in New Issue