|
| 1 | +terraform { |
| 2 | + required_version = ">= 1.0" |
| 3 | + |
| 4 | + required_providers { |
| 5 | + coder = { |
| 6 | + source = "coder/coder" |
| 7 | + version = ">= 2.5" |
| 8 | + } |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +# Add required variables for your modules and remove any unneeded variables |
| 13 | +variable "agent_id" { |
| 14 | + type = string |
| 15 | + description = "The ID of a Coder agent." |
| 16 | +} |
| 17 | + |
| 18 | +variable "nextflow_version" { |
| 19 | + type = string |
| 20 | + description = "Nextflow version" |
| 21 | + default = "25.04.7" |
| 22 | +} |
| 23 | + |
| 24 | +variable "project_path" { |
| 25 | + type = string |
| 26 | + description = "The path to Nextflow project, it will be mounted in the container." |
| 27 | +} |
| 28 | + |
| 29 | +variable "http_server_port" { |
| 30 | + type = number |
| 31 | + description = "The port to run HTTP server on." |
| 32 | + default = 9876 |
| 33 | +} |
| 34 | + |
| 35 | +variable "http_server_reports_dir" { |
| 36 | + type = string |
| 37 | + description = "Subdirectory for HTTP server reports, relative to the project path." |
| 38 | + default = "reports" |
| 39 | +} |
| 40 | + |
| 41 | +variable "http_server_log_path" { |
| 42 | + type = string |
| 43 | + description = "HTTP server logs" |
| 44 | + default = "/tmp/nextflow_reports.log" |
| 45 | +} |
| 46 | + |
| 47 | +variable "stub_run" { |
| 48 | + type = bool |
| 49 | + description = "Execute a stub run?" |
| 50 | + default = false |
| 51 | +} |
| 52 | + |
| 53 | +variable "stub_run_command" { |
| 54 | + type = string |
| 55 | + description = "Nextflow command to be executed in the stub run." |
| 56 | + default = "run rnaseq-nf -with-report reports/report.html -with-trace reports/trace.txt -with-timeline reports/timeline.html -with-dag reports/flowchart.png" |
| 57 | +} |
| 58 | + |
| 59 | +variable "order" { |
| 60 | + type = number |
| 61 | + description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)." |
| 62 | + default = null |
| 63 | +} |
| 64 | + |
| 65 | +variable "share" { |
| 66 | + type = string |
| 67 | + default = "owner" |
| 68 | + validation { |
| 69 | + condition = var.share == "owner" || var.share == "authenticated" || var.share == "public" |
| 70 | + error_message = "Incorrect value. Please set either 'owner', 'authenticated', or 'public'." |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +variable "group" { |
| 75 | + type = string |
| 76 | + description = "The name of a group that this app belongs to." |
| 77 | + default = null |
| 78 | +} |
| 79 | + |
| 80 | +resource "coder_script" "nextflow" { |
| 81 | + agent_id = var.agent_id |
| 82 | + display_name = "nextflow" |
| 83 | + icon = "/icon/nextflow.svg" |
| 84 | + script = templatefile("${path.module}/run.sh", { |
| 85 | + NEXTFLOW_VERSION : var.nextflow_version, |
| 86 | + PROJECT_PATH : var.project_path, |
| 87 | + HTTP_SERVER_PORT : var.http_server_port, |
| 88 | + HTTP_SERVER_REPORTS_DIR : var.http_server_reports_dir, |
| 89 | + HTTP_SERVER_LOG_PATH : var.http_server_log_path, |
| 90 | + STUB_RUN : var.stub_run, |
| 91 | + STUB_RUN_COMMAND : var.stub_run_command, |
| 92 | + }) |
| 93 | + run_on_start = true |
| 94 | +} |
| 95 | + |
| 96 | +resource "coder_app" "nextflow" { |
| 97 | + agent_id = var.agent_id |
| 98 | + slug = "nextflow-reports" |
| 99 | + display_name = "Nextflow Reports" |
| 100 | + url = "http://localhost:${var.http_server_port}" |
| 101 | + icon = "/icon/nextflow.svg" |
| 102 | + subdomain = true |
| 103 | + share = var.share |
| 104 | + order = var.order |
| 105 | + group = var.group |
| 106 | +} |
0 commit comments