Skip to content

Commit 0fe9a56

Browse files
babinskiyVeetaha
andauthored
ci: add tflint (#95)
This pull request introduces a new Terraform linting job to the CI workflow and adds a configuration file for TFLint. The most important changes include adding a new `tflint` job in the CI workflow and configuring TFLint with specific plugins and settings. ### CI Workflow Enhancements: * [`.github/workflows/ci.yml`](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR88-R102): Added a new `tflint` job that runs on `ubuntu-latest`, sets up TFLint, and runs it with specific options. ### TFLint Configuration: * [`.tflint.hcl`](diffhunk://#diff-c82c2fd3fe5d1315facdf6794e11d51e0bf10783e6ef34a270996a62bccf605dR1-R25): Added a new configuration file for TFLint specifying required version, plugin directory, and enabling plugins for Terraform, AWS, and AzureRM with specific versions and sources. --------- Co-authored-by: Veetaha <gersoh3@gmail.com>
1 parent 81c7022 commit 0fe9a56

File tree

12 files changed

+67
-4
lines changed

12 files changed

+67
-4
lines changed

.githooks/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ if command_exists ./node_modules/.bin/prettier; then
4646
echo "$files" | xargs ./node_modules/.bin/prettier --ignore-unknown --write
4747
fi
4848

49+
if command_exists tflint; then
50+
tflint --init
51+
tflint --config "$(pwd)/.tflint.hcl" --color --recursive
52+
fi
53+
4954
# Add the modified/prettified files to staging
5055
echo "$files" | xargs git add
5156

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,21 @@ jobs:
8585
git diff --exit-code --color=always || ( echo "Terraform docs are
8686
out-of-date. See the diff above." && exit 1 )
8787
88+
tflint:
89+
runs-on: ubuntu-latest
90+
91+
env:
92+
TFLINT_CONFIG_FILE: "${{ github.workspace }}/.tflint.hcl"
93+
94+
steps:
95+
- uses: actions/checkout@v4
96+
- uses: terraform-linters/setup-tflint@v4
97+
with:
98+
tflint_version: "latest"
99+
100+
- run: tflint --init
101+
- run: tflint --color --recursive
102+
88103
prettier:
89104
runs-on: ubuntu-latest
90105
steps:

.tflint.hcl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
tflint {
2+
required_version = ">= 0.53.0"
3+
}
4+
5+
config {
6+
plugin_dir = "~/.tflint.d/plugins"
7+
call_module_type = "local"
8+
}
9+
10+
plugin "terraform" {
11+
enabled = true
12+
preset = "all"
13+
}
14+
15+
plugin "aws" {
16+
enabled = true
17+
version = "0.38.0"
18+
source = "github.com/terraform-linters/tflint-ruleset-aws"
19+
}
20+
21+
plugin "azurerm" {
22+
enabled = true
23+
version = "0.27.0"
24+
source = "github.com/terraform-linters/tflint-ruleset-azurerm"
25+
}

asset-account/terraform/stack-set/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ No modules.
6565
| <a name="input_managed_execution"></a> [managed_execution](#input_managed_execution) | [See docs here](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_set#managed_execution-1) | <pre>object({<br/> active = optional(bool)<br/> })</pre> | `null` | no |
6666
| <a name="input_operation_preferences"></a> [operation_preferences](#input_operation_preferences) | [See docs here](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_instances#operation_preferences) | <pre>object({<br/> concurrency_mode = optional(string)<br/> failure_tolerance_count = optional(number)<br/> failure_tolerance_percentage = optional(number)<br/> max_concurrent_count = optional(number)<br/> max_concurrent_percentage = optional(number)<br/><br/> # Region settings are not supported, because<br/> # there must be at most one stack per account<br/> # in a single region.<br/> })</pre> | `null` | no |
6767
| <a name="input_permission_model"></a> [permission_model](#input_permission_model) | [See docs here](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_set#permission_model-1) | `string` | `null` | no |
68-
| <a name="input_region"></a> [region](#input_region) | The AWS region where the Elastio Asset Account stack instances will be deployed.<br/>It is just a single region because this stack is deployed only once per AWS account. | `string` | `"us-east-1"` | no |
6968
| <a name="input_retain_stacks"></a> [retain_stacks](#input_retain_stacks) | [See docs here](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack_instances#retain_stacks-1) | `bool` | `null` | no |
70-
| <a name="input_stack_set_description"></a> [stack_set_description](#input_stack_set_description) | n/a | `string` | `"Elastio Asset Account StackSet creates IAM roles to link the AWS accounts with\nthe Elastio Connector. This allows the Elastio Connector to scan the assets\navailable in the account where the Elastio Asset Account stack instances are\ndeployed.\n"` | no |
71-
| <a name="input_stack_set_name"></a> [stack_set_name](#input_stack_set_name) | n/a | `string` | `"ElastioAssetAccount"` | no |
69+
| <a name="input_stack_instances_region"></a> [stack_instances_region](#input_stack_instances_region) | The AWS region where the Elastio Asset Account stack instances will be deployed.<br/>It is just a single region because this stack is deployed only once per AWS account. | `string` | `"us-east-1"` | no |
70+
| <a name="input_stack_set_description"></a> [stack_set_description](#input_stack_set_description) | The description of the CloudFormation StackSet. | `string` | `"Elastio Asset Account StackSet creates IAM roles to link the AWS accounts with\nthe Elastio Connector. This allows the Elastio Connector to scan the assets\navailable in the account where the Elastio Asset Account stack instances are\ndeployed.\n"` | no |
71+
| <a name="input_stack_set_name"></a> [stack_set_name](#input_stack_set_name) | The name of the CloudFormation StackSet. | `string` | `"ElastioAssetAccount"` | no |
7272
| <a name="input_tags"></a> [tags](#input_tags) | Additional tags to apply to all resources created by this stack. | `map(string)` | `{}` | no |
7373
| <a name="input_template_url"></a> [template_url](#input_template_url) | The URL of the Elastio Asset Account CloudFormation template obtained from<br/>the Elastio Portal.<br/><br/>This parameter is sensitive, because anyone who knows this URL can deploy<br/>Elastio Account stack and linking it to your Elastio tenant. | `string` | n/a | yes |
7474

asset-account/terraform/stack-set/examples/self-managed/main.tf

Whitespace-only changes.

asset-account/terraform/stack-set/examples/self-managed/outputs.tf

Whitespace-only changes.

asset-account/terraform/stack-set/examples/self-managed/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ variable "template_url" {
1313
}
1414

1515
variable "admin_account_aws_profile" {
16+
description = "The AWS CLI profile name for the admin account."
1617
type = string
1718
default = null
1819
}
1920

2021
variable "asset_account_aws_profile" {
22+
description = "The AWS CLI profile name for the asset account."
2123
type = string
2224
default = null
2325
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.0"
8+
}
9+
}
10+
}

asset-account/terraform/stack-set/examples/service-managed/outputs.tf

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
}

0 commit comments

Comments
 (0)