Skip to content
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

chore: lint using tflint #7

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ jobs:

- name: Terraform Validate
run: make validate

- uses: terraform-linters/setup-tflint@v4
with:
tflint_version: v0.49.0

- name: Lint
run: make lint
10 changes: 10 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugin "terraform" {
enabled = true
preset = "recommended"
}

plugin "aws" {
enabled = true
version = "0.28.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
TF_DIRS = $(patsubst %/main.tf, %, $(shell find . -type d -name .terraform -prune -o -name 'main.tf' -print))
VALIDATE_TF_DIRS = $(addprefix validate-,$(TF_DIRS))
LINT_TF_DIRS = $(addprefix lint-,$(TF_DIRS))
DOCS_TF_DIRS = $(addprefix docs-,$(TF_DIRS))


Expand Down Expand Up @@ -31,3 +32,16 @@ $(VALIDATE_TF_DIRS): validate-%:
# Validate all terraform directories
validate: $(VALIDATE_TF_DIRS)
@echo "All validated"

# Lint a terraform directories
$(LINT_TF_DIRS): lint-%:
@echo "Lint $*"
tflint --config "$(PWD)/.tflint.hcl" --chdir="$*"

# Initialize tflint
lint-init:
tflint --init

# Lint all terraform directories
lint: lint-init $(LINT_TF_DIRS)
@echo "All linted"
4 changes: 3 additions & 1 deletion examples/redis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| aws | ~> 5.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| aws | ~> 5.0 |
| humanitec | n/a |
| humanitec | ~> 0 |

## Modules

Expand Down
1 change: 1 addition & 0 deletions examples/redis/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module "redis" {

access_key = var.access_key
secret_key = var.secret_key
resource_packs_aws_url = var.resource_packs_aws_url
resource_packs_aws_rev = var.resource_packs_aws_rev
region = var.region

Expand Down
5 changes: 4 additions & 1 deletion examples/redis/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ terraform {
version = "~> 5.0"
}
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}

required_version = ">= 1.3.0"
}

provider "aws" {
Expand Down
8 changes: 6 additions & 2 deletions examples/sqs/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | n/a |
| humanitec | ~> 0 |

## Modules

Expand Down Expand Up @@ -37,7 +42,6 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| access\_key | n/a | `string` | n/a | yes |
| humanitec\_organization | n/a | `string` | n/a | yes |
| oidc\_provider | n/a | `string` | n/a | yes |
| oidc\_provider\_arn | n/a | `string` | n/a | yes |
| secret\_key | n/a | `string` | n/a | yes |
Expand Down
9 changes: 0 additions & 9 deletions examples/sqs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ variable "region" {
default = "eu-central-1"
}

variable "humanitec_organization" {
type = string
}

variable "resource_packs_aws_rev" {
type = string
default = "refs/heads/main"
Expand Down Expand Up @@ -65,7 +61,6 @@ module "s3_basic" {
access_key = var.access_key
secret_key = var.secret_key
resource_packs_aws_rev = var.resource_packs_aws_rev
humanitec_organization = var.humanitec_organization
region = var.region
policy_classes = [local.s3_admin_policy_class]

Expand All @@ -84,7 +79,6 @@ module "iam_policy_s3_admin" {
access_key = var.access_key
secret_key = var.secret_key
resource_packs_aws_rev = var.resource_packs_aws_rev
humanitec_organization = var.humanitec_organization
region = var.region

prefix = local.res_def_prefix
Expand All @@ -110,7 +104,6 @@ module "sqs_basic" {
access_key = var.access_key
secret_key = var.secret_key
resource_packs_aws_rev = var.resource_packs_aws_rev
humanitec_organization = var.humanitec_organization
region = var.region
policy_classes = [local.sqs_admin_policy_class]

Expand All @@ -129,7 +122,6 @@ module "iam_policy_sqs_admin" {
access_key = var.access_key
secret_key = var.secret_key
resource_packs_aws_rev = var.resource_packs_aws_rev
humanitec_organization = var.humanitec_organization
region = var.region

prefix = local.res_def_prefix
Expand All @@ -148,7 +140,6 @@ module "iam_role_service_account" {
access_key = var.access_key
secret_key = var.secret_key
resource_packs_aws_rev = var.resource_packs_aws_rev
humanitec_organization = var.humanitec_organization
region = var.region

oidc_provider = var.oidc_provider
Expand Down
5 changes: 4 additions & 1 deletion examples/sqs/providers.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}

required_version = ">= 1.3.0"
}


Expand Down
1 change: 0 additions & 1 deletion examples/sqs/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
access_key = ""
humanitec_organization = ""
name = "item-list"
oidc_provider = ""
oidc_provider_arn = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | n/a |
| humanitec | ~> 0 |

## Resources

Expand All @@ -18,7 +23,6 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| access\_key | n/a | `string` | n/a | yes |
| humanitec\_organization | n/a | `string` | n/a | yes |
| prefix | n/a | `string` | n/a | yes |
| region | n/a | `string` | n/a | yes |
| resource\_packs\_aws\_rev | n/a | `string` | n/a | yes |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}

required_version = ">= 1.3.0"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
access_key = ""
humanitec_organization = ""
prefix = ""
region = ""
resource_packs_aws_rev = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
variable "humanitec_organization" {
type = string
}

variable "prefix" {
type = string
}
Expand Down
8 changes: 6 additions & 2 deletions humanitec-resource-defs/iam-policy/s3-admin/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | n/a |
| humanitec | ~> 0 |

## Resources

Expand All @@ -18,7 +23,6 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| access\_key | n/a | `string` | n/a | yes |
| humanitec\_organization | n/a | `string` | n/a | yes |
| prefix | n/a | `string` | n/a | yes |
| region | n/a | `string` | n/a | yes |
| resource\_packs\_aws\_rev | n/a | `string` | n/a | yes |
Expand Down
5 changes: 4 additions & 1 deletion humanitec-resource-defs/iam-policy/s3-admin/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}

required_version = ">= 1.3.0"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
access_key = ""
humanitec_organization = ""
prefix = ""
region = ""
resource_packs_aws_rev = ""
Expand Down
4 changes: 0 additions & 4 deletions humanitec-resource-defs/iam-policy/s3-admin/variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
variable "humanitec_organization" {
type = string
}

variable "prefix" {
type = string
}
Expand Down
8 changes: 6 additions & 2 deletions humanitec-resource-defs/iam-policy/sqs-admin/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | n/a |
| humanitec | ~> 0 |

## Resources

Expand All @@ -18,7 +23,6 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| access\_key | n/a | `string` | n/a | yes |
| humanitec\_organization | n/a | `string` | n/a | yes |
| prefix | n/a | `string` | n/a | yes |
| region | n/a | `string` | n/a | yes |
| resource\_packs\_aws\_rev | n/a | `string` | n/a | yes |
Expand Down
5 changes: 4 additions & 1 deletion humanitec-resource-defs/iam-policy/sqs-admin/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}

required_version = ">= 1.3.0"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
access_key = ""
humanitec_organization = ""
prefix = ""
region = ""
resource_packs_aws_rev = ""
Expand Down
4 changes: 0 additions & 4 deletions humanitec-resource-defs/iam-policy/sqs-admin/variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
variable "humanitec_organization" {
type = string
}

variable "prefix" {
type = string
}
Expand Down
8 changes: 6 additions & 2 deletions humanitec-resource-defs/iam-role/service-account/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| terraform | >= 1.3.0 |
| humanitec | ~> 0 |

## Providers

| Name | Version |
|------|---------|
| humanitec | n/a |
| humanitec | ~> 0 |

## Resources

Expand All @@ -18,7 +23,6 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| access\_key | n/a | `string` | n/a | yes |
| humanitec\_organization | n/a | `string` | n/a | yes |
| oidc\_provider | n/a | `string` | n/a | yes |
| oidc\_provider\_arn | n/a | `string` | n/a | yes |
| policy\_classes | n/a | `list(string)` | n/a | yes |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
terraform {
required_providers {
humanitec = {
source = "humanitec/humanitec"
source = "humanitec/humanitec"
version = "~> 0"
}
}

required_version = ">= 1.3.0"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
access_key = ""
humanitec_organization = ""
oidc_provider = ""
oidc_provider_arn = ""
policy_classes = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
variable "humanitec_organization" {
type = string
}

variable "prefix" {
type = string
}
Expand Down
Loading