-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable terraform validate pre-commit hook #90
Conversation
This hook should now work as expected in most, if not all of our repos now that we are finally updating to terraform 0.13.x (on our way to 1.0.x).
…f_0.13 This change will be reverted when testing is completed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I look forward to the day when terraform validate
is again looking out for us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense. I think we should remove
skeleton-generic/.github/workflows/build.yml
Lines 87 to 93 in 6a7fbf0
- name: Find and initialize Terraform directories | |
run: | | |
for path in $(find . -not \( -type d -name ".terraform" -prune \) \ | |
-type f -iname "*.tf" -exec dirname "{}" \; | sort -u); do \ | |
echo "Initializing '$path'..."; \ | |
terraform init -input=false -backend=false "$path"; \ | |
done |
from the workflow because this is handled by the
terraform_validate
hook per these lines.
Initialization will now be done during the "terraform validate" step.
Good call- I had forgotten about that! See 895a692. |
…upport_tf_0.13" This reverts commit 6a7fbf0.
@mcdonnnj - please review this when you can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it doesn't seem to barf in this branch, do we want to add
- package-ecosystem: "terraform"
directory: "/"
schedule:
interval: "weekly"
to .github/dependabot.yml
since we are hitting the minimum version of Terraform needed to support Dependabot alerts? This would resolve cisagov/skeleton-tf-module#59 downstream and also cover (with modification of the directory
when doing PRs) the same need in cisagov/skeleton-packer and cisagov/skeleton-ansible-role-with-test-user.
My gut says to push that dependabot change to an upcoming Kraken and separate it from this TF 0.13 business. What do you think? |
I'm ok with that. I only mentioned it because I would also be willing to consider it part of Terraform 0.13 jazz. |
👍 Please reference this PR when you create a new PR with that dependabot change and we will decide when it makes the most sense to roll that one out. |
🗣 Description
This PR enables the
terraform validate
pre-commit hook.💭 Motivation and context
That pre-commit hook had been disabled in all of our repositories because of issues related to proxy providers and Terraform code that uses remote state. We believe that those issues (see hashicorp/terraform#24887 and hashicorp/terraform#24896) have been corrected in Terraform 0.13.x, which we are in the process of migrating to, so this hook should now work as expected in most, if not all of our repos.
This PR will remain
blocked
until the following conditions have been met:This PR is a part of cisagov/cool-system#94.
Similar PRs are:
🧪 Testing
I verified that running
terraform validate
with Terraform 0.13.7 works without any errors in this repository. I also confirmed that all pre-commit hooks (including the newly-enabledterraform validate
hook) run successfully.After I confirmed that pre-commit with Terraform 0.13.7 ran successfully in GitHub Actions via 6a7fbf0, I reverted that commit (see b51dbb5) in preparation for when this PR becomes unblocked at the end of downstream testing.
Further testing will be done in all downstream repositories.
✅ Checklist