Skip to content

Commit 243cf19

Browse files
authored
feat: Added tflint as pre-commit hook (claranet#60)
1 parent 0b710c8 commit 243cf19

39 files changed

+659
-523
lines changed

.pre-commit-config.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
repos:
22
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.39.0
3+
rev: v1.40.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_docs
7+
- id: terraform_tflint
8+
args:
9+
- '--args=--only=terraform_deprecated_interpolation'
10+
- '--args=--only=terraform_deprecated_index'
11+
- '--args=--only=terraform_unused_declarations'
12+
- '--args=--only=terraform_comment_syntax'
13+
- '--args=--only=terraform_documented_outputs'
14+
- '--args=--only=terraform_documented_variables'
15+
- '--args=--only=terraform_typed_variables'
16+
- '--args=--only=terraform_module_pinned_source'
17+
- '--args=--only=terraform_naming_convention'
18+
- '--args=--only=terraform_required_version'
19+
- '--args=--only=terraform_required_providers'
20+
- '--args=--only=terraform_standard_module_structure'
21+
- '--args=--only=terraform_workspace_remote'
722
- repo: git://github.com/pre-commit/pre-commit-hooks
823
rev: v3.2.0
924
hooks:

examples/alias/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ Note that this example may create resources which cost money. Run `terraform des
1717
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1818
## Requirements
1919

20-
No requirements.
20+
| Name | Version |
21+
|------|---------|
22+
| terraform | >= 0.12.6, < 0.14 |
23+
| aws | >= 2.67, < 4.0 |
24+
| random | ~> 2 |
2125

2226
## Providers
2327

2428
| Name | Version |
2529
|------|---------|
26-
| random | n/a |
30+
| random | ~> 2 |
2731

2832
## Inputs
2933

examples/alias/main.tf

Lines changed: 88 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -12,62 +12,95 @@ provider "aws" {
1212
resource "random_pet" "this" {
1313
length = 2
1414
}
15+
#
16+
#module "lambda_function" {
17+
# source = "../../"
18+
#
19+
# function_name = "${random_pet.this.id}-lambda"
20+
# handler = "index.lambda_handler"
21+
# runtime = "python3.8"
22+
# publish = true
23+
#
24+
# source_path = "${path.module}/../fixtures/python3.8-app1"
25+
# hash_extra = "yo"
26+
#
27+
# create_async_event_config = true
28+
# maximum_event_age_in_seconds = 100
29+
#
30+
# provisioned_concurrent_executions = 1
31+
#
32+
# allowed_triggers = {
33+
# APIGatewayAny = {
34+
# service = "apigateway"
35+
# arn = "arn:aws:execute-api:eu-west-1:135367859851:aqnku8akd0"
36+
# }
37+
# }
38+
#
39+
# # current version
40+
# # create_current_version_async_event_config = false
41+
# # create_current_version_triggers = false
42+
#
43+
# # unqualified alias
44+
# # create_unqualified_alias_async_event_config = false
45+
# # create_unqualified_alias_triggers = false
46+
#}
47+
#
48+
#module "alias_no_refresh" {
49+
# source = "../../modules/alias"
50+
#
51+
# create = true
52+
# refresh_alias = false
53+
#
54+
# name = "current-no-refresh"
55+
#
56+
# function_name = module.lambda_function.this_lambda_function_name
57+
# function_version = module.lambda_function.this_lambda_function_version
58+
#
59+
# # create_version_async_event_config = false
60+
# # create_async_event_config = true
61+
# # maximum_event_age_in_seconds = 130
62+
#
63+
# allowed_triggers = {
64+
# AnotherAPIGatewayAny = { # keys should be unique
65+
# service = "apigateway"
66+
# arn = "arn:aws:execute-api:eu-west-1:135367859851:abcdedfgse"
67+
# }
68+
# }
69+
#
70+
#}
71+
#
72+
#module "alias_refresh" {
73+
# source = "../../modules/alias"
74+
#
75+
# create = true
76+
# refresh_alias = true
77+
#
78+
# name = "current-with-refresh"
79+
#
80+
# function_name = module.lambda_function.this_lambda_function_name
81+
#}
82+
#
83+
#module "alias_existing" {
84+
# source = "../../modules/alias"
85+
#
86+
# create = true
87+
# use_existing_alias = true
88+
#
89+
# name = module.alias_refresh.this_lambda_alias_name
90+
# function_name = module.lambda_function.this_lambda_function_name
91+
#
92+
# create_async_event_config = true
93+
# maximum_event_age_in_seconds = 100
94+
#
95+
# allowed_triggers = {
96+
# ThirdAPIGatewayAny = {
97+
# service = "apigateway"
98+
# arn = "arn:aws:execute-api:eu-west-1:135367859851:aqnku8akd0"
99+
# }
100+
# }
101+
#
102+
#}
15103

16-
module "lambda_function" {
17-
source = "../../"
18-
19-
function_name = "${random_pet.this.id}-lambda"
20-
handler = "index.lambda_handler"
21-
runtime = "python3.8"
22-
publish = true
23-
24-
source_path = "${path.module}/../fixtures/python3.8-app1"
25-
hash_extra = "yo"
26-
27-
create_async_event_config = true
28-
maximum_event_age_in_seconds = 100
29-
30-
provisioned_concurrent_executions = 1
31-
32-
allowed_triggers = {
33-
APIGatewayAny = {
34-
service = "apigateway"
35-
arn = "arn:aws:execute-api:eu-west-1:135367859851:aqnku8akd0"
36-
}
37-
}
38-
39-
// current version
40-
// create_current_version_async_event_config = false
41-
// create_current_version_triggers = false
42-
43-
// unqualified alias
44-
// create_unqualified_alias_async_event_config = false
45-
// create_unqualified_alias_triggers = false
46-
}
47-
48-
module "alias_no_refresh" {
49-
source = "../../modules/alias"
50-
51-
create = true
52-
refresh_alias = false
53-
54-
name = "current-no-refresh"
55-
56-
function_name = module.lambda_function.this_lambda_function_name
57-
function_version = module.lambda_function.this_lambda_function_version
58-
59-
// create_version_async_event_config = false
60-
// create_async_event_config = true
61-
// maximum_event_age_in_seconds = 130
62-
63-
allowed_triggers = {
64-
AnotherAPIGatewayAny = { // keys should be unique
65-
service = "apigateway"
66-
arn = "arn:aws:execute-api:eu-west-1:135367859851:abcdedfgse"
67-
}
68-
}
69-
70-
}
71104

72105
module "alias_refresh" {
73106
source = "../../modules/alias"
@@ -79,24 +112,3 @@ module "alias_refresh" {
79112

80113
function_name = module.lambda_function.this_lambda_function_name
81114
}
82-
83-
module "alias_existing" {
84-
source = "../../modules/alias"
85-
86-
create = true
87-
use_existing_alias = true
88-
89-
name = module.alias_refresh.this_lambda_alias_name
90-
function_name = module.lambda_function.this_lambda_function_name
91-
92-
create_async_event_config = true
93-
maximum_event_age_in_seconds = 100
94-
95-
allowed_triggers = {
96-
ThirdAPIGatewayAny = {
97-
service = "apigateway"
98-
arn = "arn:aws:execute-api:eu-west-1:135367859851:aqnku8akd0"
99-
}
100-
}
101-
102-
}

examples/alias/variables.tf

Whitespace-only changes.

examples/alias/versions.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
required_version = ">= 0.12.6, < 0.14"
3+
4+
required_providers {
5+
aws = ">= 2.67, < 4.0"
6+
random = "~> 2"
7+
}
8+
}

examples/async/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ Note that this example may create resources which cost money. Run `terraform des
1717
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1818
## Requirements
1919

20-
No requirements.
20+
| Name | Version |
21+
|------|---------|
22+
| terraform | >= 0.12.6, < 0.14 |
23+
| aws | >= 2.67, < 4.0 |
24+
| random | ~> 2 |
2125

2226
## Providers
2327

2428
| Name | Version |
2529
|------|---------|
26-
| aws | n/a |
27-
| random | n/a |
30+
| aws | >= 2.67, < 4.0 |
31+
| random | ~> 2 |
2832

2933
## Inputs
3034

examples/async/variables.tf

Whitespace-only changes.

examples/async/versions.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
required_version = ">= 0.12.6, < 0.14"
3+
4+
required_providers {
5+
aws = ">= 2.67, < 4.0"
6+
random = "~> 2"
7+
}
8+
}

examples/build-package/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ Note that this example may create resources which cost money. Run `terraform des
1717
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1818
## Requirements
1919

20-
No requirements.
20+
| Name | Version |
21+
|------|---------|
22+
| terraform | >= 0.12.6, < 0.14 |
23+
| aws | >= 2.67, < 4.0 |
24+
| random | ~> 2 |
2125

2226
## Providers
2327

2428
| Name | Version |
2529
|------|---------|
26-
| random | n/a |
30+
| random | ~> 2 |
2731

2832
## Inputs
2933

examples/build-package/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ module "package_with_docker" {
204204
build_in_docker = true
205205
docker_pip_cache = true
206206
docker_with_ssh_agent = true
207-
// docker_file = "${path.module}/../fixtures/python3.8-app1/docker/Dockerfile"
207+
# docker_file = "${path.module}/../fixtures/python3.8-app1/docker/Dockerfile"
208208
docker_build_root = "${path.module}/../../docker"
209209
docker_image = "lambci/lambda:build-python3.8"
210210
}

0 commit comments

Comments
 (0)