Skip to content

Add support for ephemeral variables in terraform >= 1.10.0 #687

Add support for ephemeral variables in terraform >= 1.10.0

Add support for ephemeral variables in terraform >= 1.10.0 #687

Workflow file for this run

name: Test terraform-output
on:
- pull_request
permissions:
contents: read
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
terraform-output:
runs-on: ubuntu-24.04
name: verify outputs
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Get outputs
uses: ./terraform-output
id: terraform-output
with:
path: tests/workflows/test-output
- name: Verify outputs
env:
MY_NUMBER: ${{ steps.terraform-output.outputs.my_number }}
MY_SENSITIVE_NUMBER: ${{ steps.terraform-output.outputs.my_sensitive_number }}
MY_STRING: ${{ steps.terraform-output.outputs.my_string }}
MY_SENSITIVE_STRING: ${{ steps.terraform-output.outputs.my_sensitive_string }}
MY_MULTILINE_STRING: ${{ steps.terraform-output.outputs.my_multiline_string }}
MY_SENSITIVE_MULTILINE_STRING: ${{ steps.terraform-output.outputs.my_sensitive_multiline_string }}
MY_BOOL: ${{ steps.terraform-output.outputs.my_bool }}
MY_SENSITIVE_BOOL: ${{ steps.terraform-output.outputs.my_sensitive_bool }}
AWKWARD_STRING: ${{ steps.terraform-output.outputs.awkward_string }}
AWKWARD_OBJ: ${{ join(fromJson(steps.terraform-output.outputs.awkward_compound_output).nested.thevalue) }}
MY_OBJECT_FIRST: ${{ fromJson(steps.terraform-output.outputs.my_object).first }}
MY_TUPLE: ${{ join(fromJson(steps.terraform-output.outputs.my_tuple)) }}
MY_SET: ${{ contains(fromJson(steps.terraform-output.outputs.my_set), 'one') }}
run: |
if [[ "$MY_NUMBER" != "5" ]]; then
echo "::error:: output my_number not set correctly"
exit 1
fi
if [[ "$MY_SENSITIVE_NUMBER" != "6" ]]; then
echo "::error:: output my_sensitive_number not set correctly"
exit 1
fi
if [[ "$MY_STRING" != "hello" ]]; then
echo "::error:: output my_string not set correctly"
exit 1
fi
if [[ "$MY_SENSITIVE_STRING" != "password" ]]; then
echo "::error:: output my_sensitive_string not set correctly"
exit 1
fi
if [[ "$MY_BOOL" != "true" ]]; then
echo "::error:: output my_bool not set correctly"
exit 1
fi
if [[ "$MY_SENSITIVE_BOOL" != "false" ]]; then
echo "::error:: output my_number not set correctly"
exit 1
fi
if [[ "$MY_OBJECT_FIRST" != "one" ]]; then
echo "::error:: fromJson(my_object).first not set correctly"
exit 1
fi
if [[ "$MY_TUPLE" != "one,two" ]]; then
echo "::error:: join(fromJson(my_set)) not set correctly"
exit 1
fi
if [[ "$MY_SET" != "true" ]]; then
echo "::error:: contains(fromJson(my_set)) not set correctly"
exit 1
fi
if [[ "$AWKWARD_STRING" != "hello \"there\", here are some 'quotes'." ]]; then
echo "::error:: awkward_string not set correctly"
exit 1
fi
if [[ "$AWKWARD_OBJ" != "hello \"there\", here are some 'quotes'." ]]; then
echo "::error:: fromJson(awkward_compound_output).nested.thevalue not set correctly"
exit 1
fi
expected_sensitive_multiline="qowicznobnad
trewptonopce
zxicvbnoberg"
if [[ "$expected_sensitive_multiline" != "$MY_SENSITIVE_MULTILINE_STRING" ]]; then
echo "::error:: steps.terraform-output.outputs.my_sensitive_multiline_string not set correctly"
exit 1
fi
expected_multiline="mcnbcvnxdgjt
iyriuytifdcv
pydrtdxfgcvj"
if [[ "$expected_multiline" != "$MY_MULTILINE_STRING" ]]; then
echo "::error:: steps.terraform-output.outputs.my_multiline_string not set correctly"
exit 1
fi