Skip to content
Closed
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
10 changes: 5 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

## Accepted Rules

Terraform Language rules implement recommendations from the [Terraform Language documentation](https://www.terraform.io/language). This ruleset _does not_ provide configurable rules for personal/team style or usage preferences. If you'd like to enforce stylistic rules beyond the official Terraform Language recommendations, you should [author your own ruleset plugin](https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/plugins.md).
OpenTofu Language rules implement recommendations from the [OpenTofu Language documentation](https://opentofu.org/docs/language/). This ruleset _does not_ provide configurable rules for personal/team style or usage preferences. If you'd like to enforce stylistic rules beyond the official OpenTofu Language recommendations, you should [author your own ruleset plugin](https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/plugins.md).

In rare circumstances, we may also accept rules that detect language usage errors that are _not_ already detected by `terraform validate`.
In rare circumstances, we may also accept rules that detect language usage errors that are _not_ already detected by `tofu validate`.

If you are unsure whether your proposed rule meets these criteria, [open a discussion](https://github.com/terraform-linters/tflint-ruleset-terraform/discussions/new?category=ideas) thread first before authoring a pull request.
If you are unsure whether your proposed rule meets these criteria, [open a discussion](https://github.com/diofeher/tflint-ruleset-opentofu/discussions/new?category=ideas) thread first before authoring a pull request.

## Authoring a Rule

Each rule should have:

* A source file implementing the rule
* Tests that check expected issues against different Terraform configurations to cover applicable cases
* Tests that check expected issues against different OpenTofu configurations to cover applicable cases
* Documentation explaining the rule, its motivation, and how users should fix their configuration

You will also need to add your rule to applicable [presets](https://github.com/terraform-linters/tflint-ruleset-terraform/blob/main/rules/preset.go).
You will also need to add your rule to applicable [presets](https://github.com/terraform-linters/tflint-ruleset-opentofu/blob/main/rules/preset.go).
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:

install: build
mkdir -p ~/.tflint.d/plugins
mv ./tflint-ruleset-terraform ~/.tflint.d/plugins
mv ./tflint-ruleset-opentofu ~/.tflint.d/plugins

release:
cd tools/release; go run main.go
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# TFLint Ruleset for Terraform Language
[![Build Status](https://github.com/terraform-linters/tflint-ruleset-terraform/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/terraform-linters/tflint-ruleset-terraform/actions)
[![GitHub release](https://img.shields.io/github/release/terraform-linters/tflint-ruleset-terraform.svg)](https://github.com/terraform-linters/tflint-ruleset-terraform/releases/latest)
# TFLint Ruleset for OpenTofu Language
[![Build Status](https://github.com/diofeher/tflint-ruleset-opentofu/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/diofeher/tflint-ruleset-opentofu/actions)
[![GitHub release](https://img.shields.io/github/release/terraform-linters/tflint-ruleset-terraform.svg)](https://github.com/diofeher/tflint-ruleset-opentofu/releases/latest)
[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-blue.svg)](LICENSE)

TFLint ruleset plugin for Terraform Language
TFLint ruleset plugin for OpenTofu Language

This ruleset focus on possible errors and best practices about Terraform Language.
This project is forked from https://github.com/terraform-linters/tflint-ruleset-terraform

This ruleset focus on possible errors and best practices about OpenTofu Language.

## Requirements

Expand All @@ -19,16 +21,16 @@ This ruleset is built into TFLint, so you usually don't need to worry about how
```
$ tflint -v
TFLint version 0.52.0
+ ruleset.terraform (0.8.0-bundled)
+ ruleset.opentofu (0.8.0-bundled)
```

If you want to use a version different from the built-in version, you can declare `plugin` in `.tflint.hcl` as follows and install it with `tflint --init`:

```hcl
plugin "terraform" {
plugin "opentofu" {
enabled = true
version = "0.13.0"
source = "github.com/terraform-linters/tflint-ruleset-terraform"
source = "github.com/diofeher/tflint-ruleset-opentofu"
}
```

Expand All @@ -55,7 +57,7 @@ $ make install
Note that if you install the plugin with `make install`, you must omit the `version` and `source` attributes in` .tflint.hcl`:

```hcl
plugin "terraform" {
plugin "opentofu" {
enabled = true
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Warning: Single line comments should begin with # (terraform_comment_syntax)
on main.tf line 2:
2: // Bad

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_comment_syntax.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_comment_syntax.md
```

## Why
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Warning: List items should be accessed using square brackets (terraform_deprecat
on example.tf line 3:
3: value = list.0

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_deprecated_index.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_deprecated_index.md
```

```hcl
Expand All @@ -41,7 +41,7 @@ Warning: List items should be accessed using square brackets (terraform_deprecat
on example.tf line 3:
3: value = list.*.a

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_deprecated_index.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_deprecated_index.md
```

## Why
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Warning: Interpolation-only expressions are deprecated in Terraform v0.12.14 (te
on example.tf line 2:
2: instance_type = "${var.type}"

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_deprecated_interpolation.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_deprecated_interpolation.md

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Warning: [Fixable] Lookup with 2 arguments is deprecated (terraform_deprecated_l
on main.tf line 3:
3: value = lookup(local.map, "a")

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.5.0/docs/rules/terraform_deprecated_lookup.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.5.0/docs/rules/opentofu_deprecated_lookup.md
```

## Why
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ Notice: `no_description` output has no description (terraform_documented_outputs
on template.tf line 1:
1: output "no_description" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_documented_outputs.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_documented_outputs.md

Notice: `empty_description` output has no description (terraform_documented_outputs)

on template.tf line 5:
5: output "empty_description" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_documented_outputs.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_documented_outputs.md

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ Notice: `no_description` variable has no description (terraform_documented_varia
on template.tf line 1:
1: variable "no_description" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_documented_variables.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_documented_variables.md

Notice: `empty_description` variable has no description (terraform_documented_variables)

on template.tf line 5:
5: variable "empty_description" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_documented_variables.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_documented_variables.md

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Warning: Comparing a collection with an empty list is invalid. To detect an empt
on test.tf line 5:
5: count = var.my_list == [] ? 0 : 1

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_empty_list_equality.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_empty_list_equality.md

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Warning: JSON configuration uses array syntax at root, expected object (terrafor
on main.tf.json line 1:
1: [{"resource": {"aws_instance": {"example": {"ami": "ami-12345678"}}}}]

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_json_syntax.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_json_syntax.md
```

## Why
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Warning: Duplicate key: "bar", first defined at main.tf:4,5-8 (terraform_map_dup
on main.tf line 5:
5: bar = 3 // duplicated key

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.9.0/docs/rules/terraform_map_duplicate_keys.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.9.0/docs/rules/opentofu_map_duplicate_keys.md
```

## Why
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ Warning: Module source "git://hashicorp.com/consul.git" is not pinned (terraform
on template.tf line 2:
2: source = "git://hashicorp.com/consul.git"

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_module_pinned_source.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_module_pinned_source.md

Warning: Module source "git://hashicorp.com/consul.git?ref=master" uses a default branch as ref (master) (terraform_module_pinned_source)

on template.tf line 6:
6: source = "git://hashicorp.com/consul.git?ref=master"

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_module_pinned_source.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_module_pinned_source.md

Warning: Module source "hg::http://hashicorp.com/consul.hg?rev=default" uses a default branch as rev (default) (terraform_module_pinned_source)

on template.tf line 10:
10: source = "hg::http://hashicorp.com/consul.hg?rev=default"

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_module_pinned_source.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_module_pinned_source.md

```

Expand Down Expand Up @@ -100,14 +100,14 @@ Warning: Module source "git://hashicorp.com/consul.git" is not pinned (terraform
on template.tf line 2:
2: source = "git://hashicorp.com/consul.git"

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_module_pinned_source.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_module_pinned_source.md

Warning: Module source "git://hashicorp.com/consul.git?ref=feature" uses a ref which is not a semantic version string (terraform_module_pinned_source)

on template.tf line 6:
6: source = "git://hashicorp.com/consul.git?ref=feature"

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_module_pinned_source.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_module_pinned_source.md

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Warning: Module source "git::ssh://git@github.com/hashicorp/consul.git?ref=v1.0.
on main.tf line 2:
3: source = "git::ssh://git@github.com/hashicorp/consul.git?ref=v1.0.0"

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.13.0/docs/rules/terraform_module_shallow_clone.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.13.0/docs/rules/opentofu_module_shallow_clone.md
```

## Why
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Warning: module "latest" should specify a version (terraform_module_version)
on main.tf line 11:
11: module "latest" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_module_version.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_module_version.md
```

### Exact
Expand Down Expand Up @@ -77,7 +77,7 @@ Warning: module "range" should specify an exact version, but a range was found (
on main.tf line 8:
8: version = ">= 1.0.0"

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/v0.1.0/master/docs/rules/terraform_module_version.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/v0.1.0/master/docs/rules/opentofu_module_version.md
```

## Why
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Notice: data name `camelCase` must match the following format: snake_case (terra
on template.tf line 1:
1: data "aws_eip" "camelCase" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_naming_convention.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_naming_convention.md

```

Expand Down Expand Up @@ -113,7 +113,7 @@ Notice: resource name `Invalid_Name_With_Number123` must match the following Reg
on template.tf line 1:
1: resource "aws_eip" "Invalid_Name_With_Number123" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_naming_convention.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_naming_convention.md

```

Expand Down Expand Up @@ -155,7 +155,7 @@ Notice: resource name `Invalid_Name_With_Number123` must match the following for
on template.tf line 1:
1: resource "aws_eip" "Invalid_Name_With_Number123" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_naming_convention.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_naming_convention.md

```

Expand Down Expand Up @@ -199,7 +199,7 @@ Notice: module name `invalid_module_with_number_1a` must match the following Reg
on template.tf line 9:
9: module "invalid_module_with_number_1a" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_naming_convention.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_naming_convention.md

```

Expand Down Expand Up @@ -273,7 +273,7 @@ Notice: local value name `invalid-name` must match the following format: snake_c
on template.tf line 12:
12: invalid-name = "dashes are not allowed with snake_case"

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_naming_convention.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_naming_convention.md

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Warning: Missing version constraint for provider "template" in `required_provide
on main.tf line 1:
1: provider "template" {}

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_required_providers.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_required_providers.md
```

<hr>
Expand All @@ -51,14 +51,14 @@ Warning: provider.template: version constraint should be specified via "required
on main.tf line 1:
1: provider "template" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_required_providers.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_required_providers.md

Warning: Missing version constraint for provider "template" in `required_providers` (terraform_required_providers)

on main.tf line 1:
1: provider "template" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_required_providers.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_required_providers.md
```

<hr>
Expand All @@ -84,7 +84,7 @@ Warning: Legacy version constraint for provider "template" in `required_provider
on main.tf line 5:
5: template = "~> 2"

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_required_providers.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_required_providers.md
```

<hr>
Expand Down Expand Up @@ -112,7 +112,7 @@ Warning: Missing `source` for provider "template" in `required_providers` (terra
6: version = "~> 2"
7: }

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_required_providers.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_required_providers.md
```

## Why
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ $ tflint

Warning: terraform "required_version" attribute is required

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_required_version.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_required_version.md
```

## Why
The `required_version` setting can be used to constrain which versions of the Terraform CLI can be used with your configuration.
If the running version of Terraform doesn't match the constraints specified, Terraform will produce an error and exit without
The `required_version` setting can be used to constrain which versions of the OpenTofu CLI are compatible with your configuration.
If the running version of OpenTofu doesn't match the constraints specified, OpenTofu will produce an error and exit without
taking any further actions.

## How To Fix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Warning: variable "v" should be moved from main.tf to variables.tf (terraform_st
on main.tf line 1:
1: variable "v" {}

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_standard_module_structure.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_standard_module_structure.md
```

## Why
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Warning: `no_type` variable has no type (terraform_typed_variables)
on template.tf line 1:
1: variable "no_type" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_typed_variables.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_typed_variables.md

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Warning: variable "not_used" is declared but not used (terraform_unused_declarat
on config.tf line 1:
1: variable "not_used" {

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_unused_declarations.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_unused_declarations.md

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Warning: provider 'null' is declared in required_providers but not used by the m
4: source = "hashicorp/null"
5: }

Reference: https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.1.0/docs/rules/terraform_unused_required_providers.md
Reference: https://github.com/diofeher/tflint-ruleset-opentofu/blob/v0.1.0/docs/rules/opentofu_unused_required_providers.md
```

## Why
Expand Down
Loading
Loading