Add Terraform validation workflow with tflint for all modules#8
Closed
devin-ai-integration[bot] wants to merge 2 commits into
Closed
Add Terraform validation workflow with tflint for all modules#8devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
- Add GitHub Actions workflow (.github/workflows/terraform-validate.yml) that runs on every PR touching terraform/ files - Workflow dynamically discovers modules under terraform/modules/ - Runs terraform fmt check, terraform init + validate via test fixtures - Runs tflint with AWS ruleset against each module - Add .tflint.hcl config with terraform recommended preset and AWS plugin - Add test fixtures for all 5 modules (dns, ecr, eks-cluster, namespaces, networking) with mock providers for CI validation
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…tflint rules - Run terraform fmt on namespaces/variables.tf to fix alignment - Disable terraform_required_providers and terraform_required_version tflint rules since existing modules don't declare these yet
Contributor
Author
|
Closing: this PR is older than 3 weeks. Reopen if still needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a GitHub Actions workflow that runs
terraform validateandtflintagainst every module underterraform/modules/on each PR. The workflow dynamically discovers modules so new modules are automatically picked up without workflow changes.What's included:
.github/workflows/terraform-validate.yml— Three-job workflow: (1) discover modules, (2) matrixterraform fmt -check+terraform init+terraform validateper module via test fixtures, (3) matrixtflintper module with the AWS ruleset.terraform/.tflint.hcl— Shared tflint config using therecommendedpreset andtflint-ruleset-awsv0.35.0. Theterraform_required_providersandterraform_required_versionrules are explicitly disabled because existing modules don't declare these yet (see comment in file).terraform/tests/fixtures/{dns,ecr,eks-cluster,namespaces,networking}/main.tf— Minimal fixture configs per module that declare mock providers (no real credentials needed) and call the module with dummy values, enablingterraform init+validateto run in CI without cloud access.terraform/modules/namespaces/variables.tf— Whitespace-only reformatting viaterraform fmtto pass thefmt -checkstep (pre-existing alignment was inconsistent).Design decisions:
skip_credentials_validation/ mock keys for the AWS provider and a localhost Kubernetes provider so validation can run without secrets.ls terraform/modules/*/), so adding a new module without a corresponding fixture will intentionally fail CI, enforcing test coverage.fail-fast: falseensures all modules are checked even if one fails.Review & Testing Checklist for Human
namespaces/variables.tfformatting change is whitespace-only — This PR reformats an existing module file. Diff should show only alignment changes (extra spaces), no semantic changes. Confirm no variable defaults or types were altered.access_key = "mock-access-key"/secret_key = "mock-secret-key"strings. These are not real secrets and are required forterraform validatewithout cloud access, but confirm this aligns with your security posture.terraform_required_providersandterraform_required_versionare disabled to avoid failing on pre-existing module gaps. Consider whether you'd prefer to fix the modules instead and re-enable these rules.~> 1.5. Confirm this matches the version your team targets (modules don't currently declarerequired_version).terraform/and confirm all three jobs (discover, validate matrix, tflint matrix) trigger and pass. The path filter means PRs not touchingterraform/won't trigger this workflow.Suggested test plan: Create a trivial PR that adds a comment to one of the modules (e.g.,
terraform/modules/dns/main.tf). Verify the workflow triggers and all 11 checks (1 discover + 5 validate + 5 tflint) pass. Then introduce an intentional error (e.g., an invalid resource attribute) and confirm the corresponding validate job fails.Notes
terraform init -backend=false+terraform validatepass for each.Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/f0cb89c9a9b54a62aeee3bbe64c5b70d