forked from coder/modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
86 lines (73 loc) · 2.14 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
terraform {
required_version = ">= 1.0"
required_providers {
coder = {
source = "coder/coder"
version = ">= 0.17"
}
}
}
variable "share" {
type = string
default = "owner"
validation {
condition = var.share == "owner" || var.share == "authenticated" || var.share == "public"
error_message = "Incorrect value. Please set either 'owner', 'authenticated', or 'public'."
}
}
variable "agent_id" {
type = string
description = "The ID of a Coder agent."
}
variable "resource_id" {
type = string
description = "The ID of the primary Coder resource (e.g. VM)."
}
variable "admin_username" {
type = string
default = "Administrator"
}
variable "admin_password" {
type = string
default = "coderRDP!"
sensitive = true
}
resource "coder_script" "windows-rdp" {
agent_id = var.agent_id
display_name = "windows-rdp"
icon = "/icon/desktop.svg"
script = templatefile("${path.module}/powershell-installation-script.tftpl", {
admin_username = var.admin_username
admin_password = var.admin_password
# Wanted to have this be in the powershell template file, but Terraform
# doesn't allow recursive calls to the templatefile function. Have to feed
# results of the JS template replace into the powershell template
patch_file_contents = templatefile("${path.module}/devolutions-patch.js", {
CODER_USERNAME = var.admin_username
CODER_PASSWORD = var.admin_password
})
})
run_on_start = true
}
resource "coder_app" "windows-rdp" {
agent_id = var.agent_id
share = var.share
slug = "web-rdp"
display_name = "Web RDP"
url = "http://localhost:7171"
icon = "/icon/desktop.svg"
subdomain = true
healthcheck {
url = "http://localhost:7171"
interval = 5
threshold = 15
}
}
resource "coder_app" "rdp-docs" {
agent_id = var.agent_id
display_name = "Local RDP"
slug = "rdp-docs"
icon = "https://raw.githubusercontent.com/matifali/logos/main/windows.svg"
url = "https://coder.com/docs/ides/remote-desktops#rdp-desktop"
external = true
}