diff --git a/db/Task.go b/db/Task.go
index dbf186aa..6cc2b8d0 100644
--- a/db/Task.go
+++ b/db/Task.go
@@ -15,6 +15,7 @@ type DefaultTaskParams struct {
type TerraformTaskParams struct {
Plan bool `json:"plan"`
+ Destroy bool `json:"destroy"`
AutoApprove bool `json:"auto_approve"`
}
diff --git a/db/Template.go b/db/Template.go
index d04f8e6c..7fb90963 100644
--- a/db/Template.go
+++ b/db/Template.go
@@ -36,6 +36,11 @@ const (
SurveyVarEnum TemplateType = "enum"
)
+type TerraformTemplateParams struct {
+ AllowDestroy bool `json:"allow_destroy"`
+ AllowAutoApprove bool `json:"allow_auto_approve"`
+}
+
type SurveyVarEnumValue struct {
Name string `json:"name" backup:"name"`
Value string `json:"value" backup:"value"`
diff --git a/services/tasks/LocalJob.go b/services/tasks/LocalJob.go
index 61cd13b2..c0d46e62 100644
--- a/services/tasks/LocalJob.go
+++ b/services/tasks/LocalJob.go
@@ -238,11 +238,25 @@ func (t *LocalJob) getTerraformArgs(username string, incomingVersion *string) (a
return
}
+ var params db.TerraformTaskParams
+ err = t.Task.GetParams(¶ms)
+ if err != nil {
+ return
+ }
+
+ if params.Destroy {
+ args = append(args, "-destroy")
+ }
+
for name, value := range extraVars {
- if name == "semaphore_vars" {
- continue
+
+ var v []byte
+ v, err = json.Marshal(value)
+ if err != nil {
+ return
}
- args = append(args, "-var", fmt.Sprintf("%s=%s", name, value))
+
+ args = append(args, "-var", fmt.Sprintf("%s=%s", name, v))
}
for _, secret := range t.Environment.Secrets {
diff --git a/web/src/components/EnvironmentForm.vue b/web/src/components/EnvironmentForm.vue
index 6dfd967f..0b7b3327 100644
--- a/web/src/components/EnvironmentForm.vue
+++ b/web/src/components/EnvironmentForm.vue
@@ -20,243 +20,255 @@
class="mb-4"
>
- --extra-vars
(Ansible) or
-var
(Terraform/OpenTofu).
-