From 834825ff5389e94dd24d9fd202a017ba273ad82e Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Tue, 31 Oct 2023 23:20:28 +0100 Subject: [PATCH] Update tool to store output in JSON format in working directory --- tool.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tool.sh b/tool.sh index 654d0d8..a60893b 100644 --- a/tool.sh +++ b/tool.sh @@ -1,5 +1,14 @@ #!/bin/sh -cd "$PLUGIN_PATH" && \ - TF_TOKEN_app_terraform_io=$PLUGIN_API_TOKEN \ - terraform $PLUGIN_ARGS +working_dir=$(pwd) +cd "$PLUGIN_PATH" || exit 1 +terraform init +if [ "$PLUGIN_AUTO_APPROVE" = "true" ] +then + auto_approve=" -auto-approve" +else + auto_approve="" +fi +TF_TOKEN_app_terraform_io=$PLUGIN_API_TOKEN terraform apply -input=false"$auto_approve" +TF_TOKEN_app_terraform_io=$PLUGIN_API_TOKEN terraform output -json > "$working_dir/terraform_output" +cd "$working_dir" || exit 1