Skip to content

Commit 306798b

Browse files
committed
Add Terragrunt support
1 parent 1e8ef56 commit 306798b

File tree

8 files changed

+55
-55
lines changed

8 files changed

+55
-55
lines changed

src/terragrunt_apply.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
#!/bin/bash
22

3-
function terraformApply {
4-
# Gather the output of `terraform apply`.
5-
echo "apply: info: applying Terraform configuration in ${tfWorkingDir}"
6-
applyOutput=$(terraform apply -auto-approve -input=false ${*} 2>&1)
3+
function terragruntApply {
4+
# Gather the output of `terragrunt apply`.
5+
echo "apply: info: applying Terragrunt configuration in ${tfWorkingDir}"
6+
applyOutput=$(terragrunt apply -auto-approve -input=false ${*} 2>&1)
77
applyExitCode=${?}
88
applyCommentStatus="Failed"
99

1010
# Exit code of 0 indicates success. Print the output and exit.
1111
if [ ${applyExitCode} -eq 0 ]; then
12-
echo "apply: info: successfully applied Terraform configuration in ${tfWorkingDir}"
12+
echo "apply: info: successfully applied Terragrunt configuration in ${tfWorkingDir}"
1313
echo "${applyOutput}"
1414
echo
1515
applyCommentStatus="Success"
1616
fi
1717

1818
# Exit code of !0 indicates failure.
1919
if [ ${applyExitCode} -ne 0 ]; then
20-
echo "apply: error: failed to apply Terraform configuration in ${tfWorkingDir}"
20+
echo "apply: error: failed to apply Terragrunt configuration in ${tfWorkingDir}"
2121
echo "${applyOutput}"
2222
echo
2323
fi
2424

2525
# Comment on the pull request if necessary.
2626
if [ "$GITHUB_EVENT_NAME" == "pull_request" ] && [ "${tfComment}" == "1" ]; then
27-
applyCommentWrapper="#### \`terraform apply\` ${applyCommentStatus}
27+
applyCommentWrapper="#### \`terragrunt apply\` ${applyCommentStatus}
2828
<details><summary>Show Output</summary>
2929
3030
\`\`\`

src/terragrunt_destroy.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
#!/bin/bash
22

3-
function terraformDestroy {
4-
# Gather the output of `terraform destroy`.
5-
echo "destroy: info: destroying Terraform-managed infrastructure in ${tfWorkingDir}"
6-
destroyOutput=$(terraform destroy -auto-approve -input=false ${*} 2>&1)
3+
function terragruntDestroy {
4+
# Gather the output of `terragrunt destroy`.
5+
echo "destroy: info: destroying Terragrunt-managed infrastructure in ${tfWorkingDir}"
6+
destroyOutput=$(terragrunt destroy -auto-approve -input=false ${*} 2>&1)
77
destroyExitCode=${?}
88
destroyCommentStatus="Failed"
99

1010
# Exit code of 0 indicates success. Print the output and exit.
1111
if [ ${destroyExitCode} -eq 0 ]; then
12-
echo "destroy: info: successfully destroyed Terraform-managed infrastructure in ${tfWorkingDir}"
12+
echo "destroy: info: successfully destroyed Terragrunt-managed infrastructure in ${tfWorkingDir}"
1313
echo "${destroyOutput}"
1414
echo
1515
destroyCommentStatus="Success"
1616
fi
1717

1818
# Exit code of !0 indicates failure.
1919
if [ ${destroyExitCode} -ne 0 ]; then
20-
echo "destroy: error: failed to destroy Terraform configuration in ${tfWorkingDir}"
20+
echo "destroy: error: failed to destroy Terragrunt configuration in ${tfWorkingDir}"
2121
echo "${destroyOutput}"
2222
echo
2323
fi
2424

2525
# Comment on the pull request if necessary.
2626
if [ "$GITHUB_EVENT_NAME" == "pull_request" ] && [ "${tfComment}" == "1" ]; then
27-
destroyCommentWrapper="#### \`terraform destroy\` ${destroyCommentStatus}
27+
destroyCommentWrapper="#### \`terragrunt destroy\` ${destroyCommentStatus}
2828
<details><summary>Show Output</summary>
2929
3030
\`\`\`

src/terragrunt_fmt.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
#!/bin/bash
22

3-
function terraformFmt {
4-
# Eliminate `-recursive` option for Terraform 0.11.x.
3+
function terragruntFmt {
4+
# Eliminate `-recursive` option for Terragrunt 0.11.x.
55
fmtRecursive="-recursive"
66
if hasPrefix "0.11" "${tfVersion}"; then
77
fmtRecursive=""
88
fi
99

10-
# Gather the output of `terraform fmt`.
11-
echo "fmt: info: checking if Terraform files in ${tfWorkingDir} are correctly formatted"
12-
fmtOutput=$(terraform fmt -check=true -write=false -diff ${fmtRecursive} ${*} 2>&1)
10+
# Gather the output of `terragrunt fmt`.
11+
echo "fmt: info: checking if Terragrunt files in ${tfWorkingDir} are correctly formatted"
12+
fmtOutput=$(terragrunt fmt -check=true -write=false -diff ${fmtRecursive} ${*} 2>&1)
1313
fmtExitCode=${?}
1414

1515
# Exit code of 0 indicates success. Print the output and exit.
1616
if [ ${fmtExitCode} -eq 0 ]; then
17-
echo "fmt: info: Terraform files in ${tfWorkingDir} are correctly formatted"
17+
echo "fmt: info: Terragrunt files in ${tfWorkingDir} are correctly formatted"
1818
echo "${fmtOutput}"
1919
echo
2020
exit ${fmtExitCode}
2121
fi
2222

2323
# Exit code of 2 indicates a parse error. Print the output and exit.
2424
if [ ${fmtExitCode} -eq 2 ]; then
25-
echo "fmt: error: failed to parse Terraform files"
25+
echo "fmt: error: failed to parse Terragrunt files"
2626
echo "${fmtOutput}"
2727
echo
2828
exit ${fmtExitCode}

src/terragrunt_import.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
#!/bin/bash
22

3-
function terraformImport {
4-
# Gather the output of `terraform import`.
5-
echo "import: info: importing Terraform configuration in ${tfWorkingDir}"
6-
importOutput=$(terraform import -input=false ${*} 2>&1)
3+
function terragruntImport {
4+
# Gather the output of `terragrunt import`.
5+
echo "import: info: importing Terragrunt configuration in ${tfWorkingDir}"
6+
importOutput=$(terragrunt import -input=false ${*} 2>&1)
77
importExitCode=${?}
88
importCommentStatus="Failed"
99

1010
# Exit code of 0 indicates success with no changes. Print the output and exit.
1111
if [ ${importExitCode} -eq 0 ]; then
12-
echo "import: info: successfully imported Terraform configuration in ${tfWorkingDir}"
12+
echo "import: info: successfully imported Terragrunt configuration in ${tfWorkingDir}"
1313
echo "${importOutput}"
1414
echo
1515
exit ${importExitCode}
1616
fi
1717

1818
# Exit code of !0 indicates failure.
1919
if [ ${importExitCode} -ne 0 ]; then
20-
echo "import: error: failed to import Terraform configuration in ${tfWorkingDir}"
20+
echo "import: error: failed to import Terragrunt configuration in ${tfWorkingDir}"
2121
echo "${importOutput}"
2222
echo
2323
fi
2424

2525
# Comment on the pull request if necessary.
2626
if [ "$GITHUB_EVENT_NAME" == "pull_request" ] && [ "${tfComment}" == "1" ] && [ "${importCommentStatus}" == "Failed" ]; then
27-
importCommentWrapper="#### \`terraform import\` ${importCommentStatus}
27+
importCommentWrapper="#### \`terragrunt import\` ${importCommentStatus}
2828
<details><summary>Show Output</summary>
2929
3030
\`\`\`

src/terragrunt_init.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
#!/bin/bash
22

3-
function terraformInit {
4-
# Gather the output of `terraform init`.
5-
echo "init: info: initializing Terraform configuration in ${tfWorkingDir}"
6-
initOutput=$(terraform init -input=false ${*} 2>&1)
3+
function terragruntInit {
4+
# Gather the output of `terragrunt init`.
5+
echo "init: info: initializing Terragrunt configuration in ${tfWorkingDir}"
6+
initOutput=$(terragrunt init -input=false ${*} 2>&1)
77
initExitCode=${?}
88

99
# Exit code of 0 indicates success. Print the output and exit.
1010
if [ ${initExitCode} -eq 0 ]; then
11-
echo "init: info: successfully initialized Terraform configuration in ${tfWorkingDir}"
11+
echo "init: info: successfully initialized Terragrunt configuration in ${tfWorkingDir}"
1212
echo "${initOutput}"
1313
echo
1414
exit ${initExitCode}
1515
fi
1616

1717
# Exit code of !0 indicates failure.
18-
echo "init: error: failed to initialize Terraform configuration in ${tfWorkingDir}"
18+
echo "init: error: failed to initialize Terragrunt configuration in ${tfWorkingDir}"
1919
echo "${initOutput}"
2020
echo
2121

2222
# Comment on the pull request if necessary.
2323
if [ "$GITHUB_EVENT_NAME" == "pull_request" ] && [ "${tfComment}" == "1" ]; then
24-
initCommentWrapper="#### \`terraform init\` Failed
24+
initCommentWrapper="#### \`terragrunt init\` Failed
2525
2626
\`\`\`
2727
${initOutput}

src/terragrunt_output.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/bin/bash
22

3-
function terraformOutput {
4-
# Gather the output of `terraform output`.
5-
echo "output: info: gathering all the outputs for the Terraform configuration in ${tfWorkingDir}"
6-
outputOutput=$(terraform output -json ${*} 2>&1)
3+
function terragruntOutput {
4+
# Gather the output of `terragrunt output`.
5+
echo "output: info: gathering all the outputs for the Terragrunt configuration in ${tfWorkingDir}"
6+
outputOutput=$(terragrunt output -json ${*} 2>&1)
77
outputExitCode=${?}
88

99
# Exit code of 0 indicates success. Print the output and exit.
1010
if [ ${outputExitCode} -eq 0 ]; then
11-
echo "output: info: successfully gathered all the outputs for the Terraform configuration in ${tfWorkingDir}"
11+
echo "output: info: successfully gathered all the outputs for the Terragrunt configuration in ${tfWorkingDir}"
1212
echo "${outputOutput}"
1313
echo
1414

@@ -22,7 +22,7 @@ function terraformOutput {
2222
fi
2323

2424
# Exit code of !0 indicates failure.
25-
echo "output: error: failed to gather all the outputs for the Terraform configuration in ${tfWorkingDir}"
25+
echo "output: error: failed to gather all the outputs for the Terragrunt configuration in ${tfWorkingDir}"
2626
echo "${outputOutput}"
2727
echo
2828
exit ${outputExitCode}

src/terragrunt_taint.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
#!/bin/bash
22

3-
function terraformTaint {
4-
# Gather the output of `terraform taint`.
5-
echo "taint: info: tainting Terraform configuration in ${tfWorkingDir}"
6-
#taintOutput=$(terraform taint ${*} 2>&1)
7-
taintOutput=$(for resource in ${*}; do terraform taint -allow-missing $resource; done 2>&1)
3+
function terragruntTaint {
4+
# Gather the output of `terragrunt taint`.
5+
echo "taint: info: tainting terragrunt configuration in ${tfWorkingDir}"
6+
#taintOutput=$(terragrunt taint ${*} 2>&1)
7+
taintOutput=$(for resource in ${*}; do terragrunt taint -allow-missing $resource; done 2>&1)
88
taintExitCode=${?}
99
taintCommentStatus="Failed"
1010

1111
# Exit code of 0 indicates success with no changes. Print the output and exit.
1212
if [ ${taintExitCode} -eq 0 ]; then
1313
taintCommentStatus="Success"
14-
echo "taint: info: successfully tainted Terraform configuration in ${tfWorkingDir}"
14+
echo "taint: info: successfully tainted Terragrunt configuration in ${tfWorkingDir}"
1515
echo "${taintOutput}"
1616
echo
1717
exit ${taintExitCode}
1818
fi
1919

2020
# Exit code of !0 indicates failure.
2121
if [ ${taintExitCode} -ne 0 ]; then
22-
echo "taint: error: failed to taint Terraform configuration in ${tfWorkingDir}"
22+
echo "taint: error: failed to taint Terragrunt configuration in ${tfWorkingDir}"
2323
echo "${taintOutput}"
2424
echo
2525
fi

src/terragrunt_validate.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
#!/bin/bash
22

3-
function terraformValidate {
4-
# Gather the output of `terraform validate`.
5-
echo "validate: info: validating Terraform configuration in ${tfWorkingDir}"
6-
validateOutput=$(terraform validate ${*} 2>&1)
3+
function terragruntValidate {
4+
# Gather the output of `terragrunt validate`.
5+
echo "validate: info: validating Terragrunt configuration in ${tfWorkingDir}"
6+
validateOutput=$(terragrunt validate ${*} 2>&1)
77
validateExitCode=${?}
88

99
# Exit code of 0 indicates success. Print the output and exit.
1010
if [ ${validateExitCode} -eq 0 ]; then
11-
echo "validate: info: successfully validated Terraform configuration in ${tfWorkingDir}"
11+
echo "validate: info: successfully validated Terragrunt configuration in ${tfWorkingDir}"
1212
echo "${validateOutput}"
1313
echo
1414
exit ${validateExitCode}
1515
fi
1616

1717
# Exit code of !0 indicates failure.
18-
echo "validate: error: failed to validate Terraform configuration in ${tfWorkingDir}"
18+
echo "validate: error: failed to validate Terragrunt configuration in ${tfWorkingDir}"
1919
echo "${validateOutput}"
2020
echo
2121

2222
# Comment on the pull request if necessary.
2323
if [ "$GITHUB_EVENT_NAME" == "pull_request" ] && [ "${tfComment}" == "1" ]; then
24-
validateCommentWrapper="#### \`terraform validate\` Failed
24+
validateCommentWrapper="#### \`terragrunt validate\` Failed
2525
2626
\`\`\`
2727
${validateOutput}

0 commit comments

Comments
 (0)