File tree 3 files changed +60
-1
lines changed
3 files changed +60
-1
lines changed Original file line number Diff line number Diff line change @@ -126,4 +126,17 @@ The usual [Terraform environment variables](https://www.terraform.io/docs/comman
126
126
127
127
Other environment variables may be configured to pass data into Terraform. If the data is sensitive, consider using [secrets](#secrets) instead.
128
128
129
+
130
+ # # Testing
131
+
132
+ If you want to test these scripts locally, its possible after installing docker in your test environment
133
+
134
+ 1. Open `test/local-test.sh` and modify the GLOBAL variables (in caps) according to your needs
135
+ 2. Run it with : ` test/local-test.sh` or `test/local-test.sh run-all plan`
136
+ 3. The above command :
137
+ - Builds a docker container with image tag `tg`
138
+ - Starts that container with those global variables
139
+
140
+
141
+
129
142
**This is a fork of [Terraform Github Actions](https://github.com/hashicorp/terraform-github-actions).**
Original file line number Diff line number Diff line change @@ -32,7 +32,11 @@ function parseInputs {
32
32
fi
33
33
34
34
if [ " ${INPUT_TF_ACTIONS_SUBCOMMAND} " != " " ]; then
35
- tfSubcommand=${INPUT_TF_ACTIONS_SUBCOMMAND}
35
+ if [[ " ${INPUT_TF_ACTIONS_SUBCOMMAND} " = run-all* ]]; then
36
+ tfSubcommand=$( echo $INPUT_TF_ACTIONS_SUBCOMMAND | cut -d ' ' -f 2 )
37
+ else
38
+ tfSubcommand=${INPUT_TF_ACTIONS_SUBCOMMAND}
39
+ fi
36
40
else
37
41
echo " Input terraform_subcommand cannot be empty"
38
42
exit 1
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # This is a script for easily running the local testing
4
+ # Comes very handy in local development
5
+
6
+ TF_VERSION=' 0.14.6'
7
+ TG_VERSION=' v0.28.4'
8
+ TF_WORKING_DIR=' /var/opt'
9
+ TF_SUBCOMMAND=' run-all init'
10
+ TG_LOCAL_WORK_DIR=" $( pwd) " # TODO, provide some path which has the terragrunt code
11
+
12
+ function build_docker {
13
+ echo " INFO: Building docker image"
14
+ docker build -t tg .
15
+ }
16
+
17
+ function run_docker {
18
+ echo " INFO: Test running docker"
19
+ docker run -it \
20
+ -e INPUT_TF_ACTIONS_VERSION=$TF_VERSION \
21
+ -e INPUT_TG_ACTIONS_VERSION=$TG_VERSION \
22
+ -e INPUT_TF_ACTIONS_SUBCOMMAND=" $TF_SUBCOMMAND " \
23
+ -e INPUT_TF_ACTIONS_WORKING_DIR=" $TF_WORKING_DIR " \
24
+ -v $TG_LOCAL_WORK_DIR :$TF_WORKING_DIR \
25
+ tg
26
+ }
27
+
28
+ function main {
29
+
30
+ # validate cli
31
+ if [ " $1 " != " " ]; then
32
+ TF_SUBCOMMAND=$*
33
+ fi
34
+
35
+ # Build the image
36
+ build_docker
37
+
38
+ # test run it
39
+ run_docker
40
+ }
41
+
42
+ main $*
You can’t perform that action at this time.
0 commit comments