Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# iac-github
# iac-github

```
./tf.sh github/johnko fmt

./tf.sh github/johnko validate

./tf.sh github/johnko plan

./tf.sh github/johnko apply

./tf.sh github/johnko auto
```
40 changes: 32 additions & 8 deletions tf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if [[ ! -d $WORKSPACE ]]; then
echo "ERROR: invalid 'WORKSPACE', received '$WORKSPACE'"
exit 1
fi
echo "WORKSPACE=$WORKSPACE"
pushd "$WORKSPACE"

ACTION="$2"
Expand All @@ -34,30 +35,52 @@ case $SAFE_ACTION in
;;
esac
echo "SAFE_ACTION=$SAFE_ACTION"

set -ux
$IAC_BIN fmt

set +x
if [[ "APPLY" == "$SAFE_ACTION" || "AUTO" == "$SAFE_ACTION" || "PLAN" == "$SAFE_ACTION" || "VALIDATE" == "$SAFE_ACTION" ]]; then
if [[ "FMT" == "$SAFE_ACTION" ]]; then
set -x
$IAC_BIN init
exit 0
fi

set -x
$IAC_BIN init

set +x
if [[ "INIT" == "$SAFE_ACTION" ]]; then
set -x
exit 0
fi

set -x
$IAC_BIN validate

set +x
if [[ "VALIDATE" == "$SAFE_ACTION" ]]; then
set -x
exit 0
fi

set +x
if [[ "APPLY" == "$SAFE_ACTION" || "AUTO" == "$SAFE_ACTION" || "PLAN" == "$SAFE_ACTION" ]]; then
if [[ -e import.sh ]]; then
set -x
bash -ex import.sh
fi
fi

set +x
if [[ "PLAN" == "$SAFE_ACTION" ]]; then
set -x
set +e
$IAC_BIN plan -detailed-exitcode -input=false -parallelism=5
TF_PLAN_EXIT_CODE=$?
set -e
set +x
if [[ "PLAN" == "$SAFE_ACTION" ]]; then
set -x
exit $TF_PLAN_EXIT_CODE
fi
exit $TF_PLAN_EXIT_CODE
fi

set +x
if [[ "APPLY" == "$SAFE_ACTION" || "AUTO" == "$SAFE_ACTION" ]]; then
AUTO_APPROVE_ARG=""
Expand All @@ -68,7 +91,8 @@ if [[ "APPLY" == "$SAFE_ACTION" || "AUTO" == "$SAFE_ACTION" ]]; then
set +e
$IAC_BIN apply $AUTO_APPROVE_ARG -input=false -parallelism=5
TF_APPLY_EXIT_CODE=$?
set -e
exit $TF_APPLY_EXIT_CODE
fi
set -e

popd