diff --git a/terraform-v2/apply.sh b/terraform-v2/apply.sh index 454aa033..a91aac09 100644 --- a/terraform-v2/apply.sh +++ b/terraform-v2/apply.sh @@ -28,7 +28,13 @@ function update_status() { function apply() { set +e - terraform -chdir=${module_path} apply -input=false -no-color -auto-approve -lock-timeout=300s plan.out | $TFMASK + + if [[ "<< parameters.timeout >>" -gt 0 ]]; then + timeout "<< parameters.timeout >>" terraform -chdir=${module_path} apply -input=false -no-color -auto-approve -lock-timeout=300s plan.out | $TFMASK + else + terraform -chdir=${module_path} apply -input=false -no-color -auto-approve -lock-timeout=300s plan.out | $TFMASK + fi + local TF_EXIT=${PIPESTATUS[0]} set -e diff --git a/terraform-v2/orb.yml b/terraform-v2/orb.yml index 77548024..76068995 100644 --- a/terraform-v2/orb.yml +++ b/terraform-v2/orb.yml @@ -81,6 +81,11 @@ aliases: type: "string" description: "Path to the json file to save the output variables to" default: "" + timeout: &timeout + timeout: + type: "integer" + description: "Timeout in seconds applied to terraform apply. Default is 0 (no timeout)" + default: 0 init-parameter-passthrough: &init-parameter-passthrough path: << parameters.path >> @@ -152,6 +157,7 @@ commands: <<: *target <<: *output_path <<: *reuse_plan + <<: *timeout steps: - run: name: "terraform apply << parameters.path >> << parameters.label >>"