I'm very new to terraform and to rundeck. I am trying to use the option block to capture the input and use it in the command, but I only get errors when using "terraform plan".
What I have tried is the following:
resource "rundeck_job" "my_first_rundeck" {
name = var.job_name
project_name = var.project_name
description = var.job_description
schedule = var.job_schedule
#give the option of choosing from a dropdown list of nicknames
option {
name = var.nickname
label = var.nickname
required = true
value_choices = var.nickname_choices
}
#give the option of choosing from a dropdown list of scripts,
#to reduce the error of user input
option {
name = var.scripts
label = var.scripts
required = true
value_choices_url = ""
}
command {
description = "Testing for ${option.scripts}"
}
}
I'm trying to figure out how the line description = "Testing for ${option.scripts}" works.
When I use terraform plan it gives me the following error:
╷
│ Error: Reference to undeclared resource
│
│ on main.tf line 38, in resource "rundeck_job" "my_first_rundeck":
│ 38: description = "Testing for ${option.scripts}"
│
│ A managed resource "option" "scripts" has not been declared in the root module.
I have another file (variables.tf) where the var.* variables exists
How can I achieve what I'm looking for?
You need to "parse" the $
character following this. So, use $${option.opt1}
instead of ${option.opt1}
It works in the following way:
command {
shell_command = "echo $${option.opt1}"
}
Tested on Rundeck 5.6.0.