Skip to content

Commit 3945576

Browse files
committed
Add Terraform Enterprise support
- New TF_ACTION_TFE_TOKEN environment variable for specifying the terraform enteprise token. - New TF_ACTION_TFE_HOSTNAME environment variable for specifying the hostname of your TFE installation. Defaults to app.terraform.io - Don't use workspace select unless workspace is not equal to "default". We need to do this because the remote backend doesn't support calling workspace select "default".
1 parent 5942461 commit 3945576

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

init/entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
set -e
33
cd "${TF_ACTION_WORKING_DIR:-.}"
44

5+
if [[ ! -z "$TF_ACTION_TFE_TOKEN" ]]; then
6+
cat > ~/.terraformrc << EOF
7+
credentials "${TF_ACTION_TFE_HOSTNAME:-app.terraform.io}" {
8+
token = "$TF_ACTION_TFE_TOKEN"
9+
}
10+
EOF
11+
fi
12+
513
set +e
614
OUTPUT=$(sh -c "terraform init -no-color -input=false $*" 2>&1)
715
SUCCESS=$?

plan/entrypoint.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,17 @@ set -e
2626

2727
cd "${TF_ACTION_WORKING_DIR:-.}"
2828

29-
WORKSPACE=${TF_ACTION_WORKSPACE:-default}
30-
terraform workspace select "$WORKSPACE"
29+
if [[ ! -z "$TF_ACTION_TFE_TOKEN" ]]; then
30+
cat > ~/.terraformrc << EOF
31+
credentials "${TF_ACTION_TFE_HOSTNAME:-app.terraform.io}" {
32+
token = "$TF_ACTION_TFE_TOKEN"
33+
}
34+
EOF
35+
fi
36+
37+
if [[ ! -z "$TF_ACTION_WORKSPACE" ]] && [[ "$TF_ACTION_WORKSPACE" != "default" ]]; then
38+
terraform workspace select "$TF_ACTION_WORKSPACE"
39+
fi
3140

3241
set +e
3342
OUTPUT=$(sh -c "TF_IN_AUTOMATION=true terraform plan -no-color -input=false $*" 2>&1)

validate/entrypoint.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
set -e
33
cd "${TF_ACTION_WORKING_DIR:-.}"
44

5-
WORKSPACE=${TF_ACTION_WORKSPACE:-default}
6-
terraform workspace select "$WORKSPACE"
5+
if [[ ! -z "$TF_ACTION_WORKSPACE" ]] && [[ "$TF_ACTION_WORKSPACE" != "default" ]]; then
6+
terraform workspace select "$TF_ACTION_WORKSPACE"
7+
fi
78

89
set +e
910
OUTPUT=$(sh -c "terraform validate -no-color $*" 2>&1)

0 commit comments

Comments
 (0)