mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-22 07:12:11 -05:00
feat: add support for Terraform modules in tflint (#2297)
* fix: support tflint relative module references * chore: add test for relative module imports * chore: add terraform binary * chore: move tests * chore: add newlines to tests * chore: add newlines to tests * refactor: move terraform get * refactor: put terraform get back where it was Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
This commit is contained in:
parent
9434520fdf
commit
09b571b1b0
4 changed files with 39 additions and 0 deletions
|
@ -0,0 +1,10 @@
|
|||
module "s3_bucket" {
|
||||
source = "terraform-aws-modules/s3-bucket/aws"
|
||||
version = "2.11.1"
|
||||
|
||||
bucket = "test-bucket"
|
||||
}
|
||||
|
||||
module "good_relative_reference" {
|
||||
source = "../modules/ec2_instance"
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
resource "aws_instance" "good" {
|
||||
ami = "ami-0ff8a91507f77f867"
|
||||
instance_type = "t2.small"
|
||||
associate_public_ip_address = false
|
||||
|
||||
vpc_security_group_ids = ["sg-12345678901234567"]
|
||||
metadata_options {
|
||||
http_endpoint = "disabled"
|
||||
}
|
||||
|
||||
ebs_block_device {
|
||||
encrypted = true
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ FROM yoheimuta/protolint:v0.35.2 as protolint
|
|||
FROM golangci/golangci-lint:v1.43.0 as golangci-lint
|
||||
FROM koalaman/shellcheck:v0.8.0 as shellcheck
|
||||
FROM ghcr.io/terraform-linters/tflint-bundle:v0.34.1.1 as tflint
|
||||
FROM hashicorp/terraform:1.1.2 as terraform
|
||||
FROM alpine/terragrunt:1.1.2 as terragrunt
|
||||
FROM mvdan/shfmt:v3.4.2 as shfmt
|
||||
FROM accurics/terrascan:1.13.0 as terrascan
|
||||
|
@ -129,6 +130,11 @@ COPY --from=shellcheck /bin/shellcheck /usr/bin/
|
|||
#####################
|
||||
COPY --from=golangci-lint /usr/bin/golangci-lint /usr/bin/
|
||||
|
||||
#####################
|
||||
# Install Terraform #
|
||||
#####################
|
||||
COPY --from=terraform /bin/terraform /usr/bin/
|
||||
|
||||
##################
|
||||
# Install TFLint #
|
||||
##################
|
||||
|
|
|
@ -257,6 +257,15 @@ function LintCodebase() {
|
|||
cd "${DIR_NAME}" || exit
|
||||
${LINTER_COMMAND} "${FILE_NAME}" 2>&1
|
||||
)
|
||||
############################################################################################
|
||||
# Corner case for TERRAFORM_TFLINT as it cant use the full path and needs to fetch modules #
|
||||
############################################################################################
|
||||
elif [[ ${FILE_TYPE} == "TERRAFORM_TFLINT" ]]; then
|
||||
LINT_CMD=$(
|
||||
cd "${DIR_NAME}" || exit
|
||||
terraform get 2>&1
|
||||
${LINTER_COMMAND} "${FILE_NAME}" 2>&1
|
||||
)
|
||||
else
|
||||
################################
|
||||
# Lint the file with the rules #
|
||||
|
|
Loading…
Reference in a new issue