Skip to content

13 files changed

+863
-0
lines changed

docs/rules/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,9 +778,12 @@ These rules enforce best practices and naming conventions:
778778
|aws_lambda_alias_invalid_description||
779779
|aws_lambda_alias_invalid_function_name||
780780
|aws_lambda_alias_invalid_function_version||
781+
|aws_lambda_code_signing_config_invalid_description||
781782
|aws_lambda_event_source_mapping_invalid_event_source_arn||
782783
|aws_lambda_event_source_mapping_invalid_function_name||
783784
|aws_lambda_event_source_mapping_invalid_starting_position||
785+
|aws_lambda_function_event_invoke_config_invalid_function_name||
786+
|aws_lambda_function_event_invoke_config_invalid_qualifier||
784787
|aws_lambda_function_invalid_description||
785788
|aws_lambda_function_invalid_function_name||
786789
|aws_lambda_function_invalid_handler||
@@ -794,6 +797,11 @@ These rules enforce best practices and naming conventions:
794797
|aws_lambda_layer_version_invalid_license_info||
795798
|aws_lambda_layer_version_invalid_s3_key||
796799
|aws_lambda_layer_version_invalid_s3_object_version||
800+
|aws_lambda_layer_version_permission_invalid_action||
801+
|aws_lambda_layer_version_permission_invalid_layer_name||
802+
|aws_lambda_layer_version_permission_invalid_organization_id||
803+
|aws_lambda_layer_version_permission_invalid_principal||
804+
|aws_lambda_layer_version_permission_invalid_statement_id||
797805
|aws_lambda_permission_invalid_action||
798806
|aws_lambda_permission_invalid_event_source_token||
799807
|aws_lambda_permission_invalid_function_name||
@@ -802,6 +810,8 @@ These rules enforce best practices and naming conventions:
802810
|aws_lambda_permission_invalid_source_account||
803811
|aws_lambda_permission_invalid_source_arn||
804812
|aws_lambda_permission_invalid_statement_id||
813+
|aws_lambda_provisioned_concurrency_config_invalid_function_name||
814+
|aws_lambda_provisioned_concurrency_config_invalid_qualifier||
805815
|aws_launch_configuration_invalid_spot_price||
806816
|aws_launch_configuration_invalid_type||
807817
|aws_launch_template_invalid_description||
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"log"
7+
8+
hcl "github.com/hashicorp/hcl/v2"
9+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
10+
)
11+
12+
// AwsLambdaCodeSigningConfigInvalidDescriptionRule checks the pattern is valid
13+
type AwsLambdaCodeSigningConfigInvalidDescriptionRule struct {
14+
resourceType string
15+
attributeName string
16+
max int
17+
}
18+
19+
// NewAwsLambdaCodeSigningConfigInvalidDescriptionRule returns new rule with default attributes
20+
func NewAwsLambdaCodeSigningConfigInvalidDescriptionRule() *AwsLambdaCodeSigningConfigInvalidDescriptionRule {
21+
return &AwsLambdaCodeSigningConfigInvalidDescriptionRule{
22+
resourceType: "aws_lambda_code_signing_config",
23+
attributeName: "description",
24+
max: 256,
25+
}
26+
}
27+
28+
// Name returns the rule name
29+
func (r *AwsLambdaCodeSigningConfigInvalidDescriptionRule) Name() string {
30+
return "aws_lambda_code_signing_config_invalid_description"
31+
}
32+
33+
// Enabled returns whether the rule is enabled by default
34+
func (r *AwsLambdaCodeSigningConfigInvalidDescriptionRule) Enabled() bool {
35+
return true
36+
}
37+
38+
// Severity returns the rule severity
39+
func (r *AwsLambdaCodeSigningConfigInvalidDescriptionRule) Severity() string {
40+
return tflint.ERROR
41+
}
42+
43+
// Link returns the rule reference link
44+
func (r *AwsLambdaCodeSigningConfigInvalidDescriptionRule) Link() string {
45+
return ""
46+
}
47+
48+
// Check checks the pattern is valid
49+
func (r *AwsLambdaCodeSigningConfigInvalidDescriptionRule) Check(runner tflint.Runner) error {
50+
log.Printf("[TRACE] Check `%s` rule", r.Name())
51+
52+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
53+
var val string
54+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
55+
56+
return runner.EnsureNoError(err, func() error {
57+
if len(val) > r.max {
58+
runner.EmitIssueOnExpr(
59+
r,
60+
"description must be 256 characters or less",
61+
attribute.Expr,
62+
)
63+
}
64+
return nil
65+
})
66+
})
67+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
"regexp"
9+
10+
hcl "github.com/hashicorp/hcl/v2"
11+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
12+
)
13+
14+
// AwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule checks the pattern is valid
15+
type AwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule returns new rule with default attributes
24+
func NewAwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule() *AwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule {
25+
return &AwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule{
26+
resourceType: "aws_lambda_function_event_invoke_config",
27+
attributeName: "function_name",
28+
max: 140,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^(arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}(-gov)?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule) Name() string {
36+
return "aws_lambda_function_event_invoke_config_invalid_function_name"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsLambdaFunctionEventInvokeConfigInvalidFunctionNameRule) Check(runner tflint.Runner) error {
56+
log.Printf("[TRACE] Check `%s` rule", r.Name())
57+
58+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
59+
var val string
60+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
61+
62+
return runner.EnsureNoError(err, func() error {
63+
if len(val) > r.max {
64+
runner.EmitIssueOnExpr(
65+
r,
66+
"function_name must be 140 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"function_name must be 1 characters or higher",
74+
attribute.Expr,
75+
)
76+
}
77+
if !r.pattern.MatchString(val) {
78+
runner.EmitIssueOnExpr(
79+
r,
80+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}(-gov)?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
"regexp"
9+
10+
hcl "github.com/hashicorp/hcl/v2"
11+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
12+
)
13+
14+
// AwsLambdaFunctionEventInvokeConfigInvalidQualifierRule checks the pattern is valid
15+
type AwsLambdaFunctionEventInvokeConfigInvalidQualifierRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
min int
20+
pattern *regexp.Regexp
21+
}
22+
23+
// NewAwsLambdaFunctionEventInvokeConfigInvalidQualifierRule returns new rule with default attributes
24+
func NewAwsLambdaFunctionEventInvokeConfigInvalidQualifierRule() *AwsLambdaFunctionEventInvokeConfigInvalidQualifierRule {
25+
return &AwsLambdaFunctionEventInvokeConfigInvalidQualifierRule{
26+
resourceType: "aws_lambda_function_event_invoke_config",
27+
attributeName: "qualifier",
28+
max: 128,
29+
min: 1,
30+
pattern: regexp.MustCompile(`^(|[a-zA-Z0-9$_-]+)$`),
31+
}
32+
}
33+
34+
// Name returns the rule name
35+
func (r *AwsLambdaFunctionEventInvokeConfigInvalidQualifierRule) Name() string {
36+
return "aws_lambda_function_event_invoke_config_invalid_qualifier"
37+
}
38+
39+
// Enabled returns whether the rule is enabled by default
40+
func (r *AwsLambdaFunctionEventInvokeConfigInvalidQualifierRule) Enabled() bool {
41+
return true
42+
}
43+
44+
// Severity returns the rule severity
45+
func (r *AwsLambdaFunctionEventInvokeConfigInvalidQualifierRule) Severity() string {
46+
return tflint.ERROR
47+
}
48+
49+
// Link returns the rule reference link
50+
func (r *AwsLambdaFunctionEventInvokeConfigInvalidQualifierRule) Link() string {
51+
return ""
52+
}
53+
54+
// Check checks the pattern is valid
55+
func (r *AwsLambdaFunctionEventInvokeConfigInvalidQualifierRule) Check(runner tflint.Runner) error {
56+
log.Printf("[TRACE] Check `%s` rule", r.Name())
57+
58+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
59+
var val string
60+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
61+
62+
return runner.EnsureNoError(err, func() error {
63+
if len(val) > r.max {
64+
runner.EmitIssueOnExpr(
65+
r,
66+
"qualifier must be 128 characters or less",
67+
attribute.Expr,
68+
)
69+
}
70+
if len(val) < r.min {
71+
runner.EmitIssueOnExpr(
72+
r,
73+
"qualifier must be 1 characters or higher",
74+
attribute.Expr,
75+
)
76+
}
77+
if !r.pattern.MatchString(val) {
78+
runner.EmitIssueOnExpr(
79+
r,
80+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^(|[a-zA-Z0-9$_-]+)$`),
81+
attribute.Expr,
82+
)
83+
}
84+
return nil
85+
})
86+
})
87+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
"regexp"
9+
10+
hcl "github.com/hashicorp/hcl/v2"
11+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
12+
)
13+
14+
// AwsLambdaLayerVersionPermissionInvalidActionRule checks the pattern is valid
15+
type AwsLambdaLayerVersionPermissionInvalidActionRule struct {
16+
resourceType string
17+
attributeName string
18+
max int
19+
pattern *regexp.Regexp
20+
}
21+
22+
// NewAwsLambdaLayerVersionPermissionInvalidActionRule returns new rule with default attributes
23+
func NewAwsLambdaLayerVersionPermissionInvalidActionRule() *AwsLambdaLayerVersionPermissionInvalidActionRule {
24+
return &AwsLambdaLayerVersionPermissionInvalidActionRule{
25+
resourceType: "aws_lambda_layer_version_permission",
26+
attributeName: "action",
27+
max: 22,
28+
pattern: regexp.MustCompile(`^lambda:GetLayerVersion$`),
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsLambdaLayerVersionPermissionInvalidActionRule) Name() string {
34+
return "aws_lambda_layer_version_permission_invalid_action"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsLambdaLayerVersionPermissionInvalidActionRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsLambdaLayerVersionPermissionInvalidActionRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsLambdaLayerVersionPermissionInvalidActionRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsLambdaLayerVersionPermissionInvalidActionRule) Check(runner tflint.Runner) error {
54+
log.Printf("[TRACE] Check `%s` rule", r.Name())
55+
56+
return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error {
57+
var val string
58+
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
59+
60+
return runner.EnsureNoError(err, func() error {
61+
if len(val) > r.max {
62+
runner.EmitIssueOnExpr(
63+
r,
64+
"action must be 22 characters or less",
65+
attribute.Expr,
66+
)
67+
}
68+
if !r.pattern.MatchString(val) {
69+
runner.EmitIssueOnExpr(
70+
r,
71+
fmt.Sprintf(`"%s" does not match valid pattern %s`, truncateLongMessage(val), `^lambda:GetLayerVersion$`),
72+
attribute.Expr,
73+
)
74+
}
75+
return nil
76+
})
77+
})
78+
}

0 commit comments

Comments
 (0)