Skip to content

Commit

Permalink
Add shell action
Browse files Browse the repository at this point in the history
  • Loading branch information
Zordrak committed Oct 29, 2021
1 parent c97d9a9 commit eb230b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.7.0 (29/10/2021)

* Added custom action `shell`: a bash login shell between component init and cleanup

## 1.6.1 (24/05/2021)

FEATURES:
Expand Down
9 changes: 7 additions & 2 deletions bin/terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
##
# Set Script Version
##
readonly script_ver="1.6.1";
readonly script_ver="1.7.0";

##
# Standardised failure function
Expand Down Expand Up @@ -52,6 +52,7 @@ action:
* apply / destroy
* graph
* taint / untaint
* shell
- Generic actions:
* See https://www.terraform.io/docs/commands/
Expand Down Expand Up @@ -679,7 +680,7 @@ case "${action}" in
|| error_and_die "Terraform verbose graph generation failed";
exit 0;
;;
'apply'|'destroy')
'apply'|'destroy'|'refresh')

# Support for terraform <0.10 is now deprecated
if [ "${action}" == "apply" ]; then
Expand Down Expand Up @@ -763,6 +764,10 @@ case "${action}" in
'import')
terraform "${action}" ${tf_var_params} ${extra_args} || error_and_die "Terraform ${action} failed.";
;;
'shell')
echo -e "Here's a shell for the ${component} component.\nIf you want to run terraform actions specific to the ${environment} environment, pass the following options to your terraform commands:\n\n${tf_var_params} ${extra_args}\n\n'exit 0' / 'Ctrl-D' to continue, other exit codes will abort tfscaffold with the same code.";
bash -l || exit "${?}";
;;
*)
echo -e "Generic action case invoked. Only the additional arguments will be passed to terraform, you break it you fix it:";
echo -e "\tterraform ${action} ${extra_args}";
Expand Down

0 comments on commit eb230b2

Please sign in to comment.