Skip to content

9 files changed

+560
-0
lines changed

docs/rules/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,19 @@ These rules enforce best practices and naming conventions:
492492
|aws_dynamodb_table_item_invalid_range_key||
493493
|aws_dynamodb_table_item_invalid_table_name||
494494
|aws_ebs_volume_invalid_type||
495+
|aws_ec2_availability_zone_group_invalid_opt_in_status||
495496
|aws_ec2_capacity_reservation_invalid_end_date_type||
496497
|aws_ec2_capacity_reservation_invalid_instance_match_criteria||
497498
|aws_ec2_capacity_reservation_invalid_instance_platform||
498499
|aws_ec2_capacity_reservation_invalid_tenancy||
499500
|aws_ec2_client_vpn_endpoint_invalid_transport_protocol||
500501
|aws_ec2_fleet_invalid_excess_capacity_termination_policy||
501502
|aws_ec2_fleet_invalid_type||
503+
|aws_ec2_host_invalid_auto_placement||
504+
|aws_ec2_host_invalid_host_recovery||
505+
|aws_ec2_subnet_cidr_reservation_invalid_reservation_type||
506+
|aws_ec2_traffic_mirror_filter_rule_invalid_rule_action||
507+
|aws_ec2_traffic_mirror_filter_rule_invalid_traffic_direction||
502508
|aws_ec2_transit_gateway_invalid_auto_accept_shared_attachments||
503509
|aws_ec2_transit_gateway_invalid_default_route_table_association||
504510
|aws_ec2_transit_gateway_invalid_default_route_table_propagation||
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule checks the pattern is valid
14+
type AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsEc2AvailabilityZoneGroupInvalidOptInStatusRule returns new rule with default attributes
21+
func NewAwsEc2AvailabilityZoneGroupInvalidOptInStatusRule() *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule {
22+
return &AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule{
23+
resourceType: "aws_ec2_availability_zone_group",
24+
attributeName: "opt_in_status",
25+
enum: []string{
26+
"opted-in",
27+
"not-opted-in",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule) Name() string {
34+
return "aws_ec2_availability_zone_group_invalid_opt_in_status"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsEc2AvailabilityZoneGroupInvalidOptInStatusRule) 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+
found := false
62+
for _, item := range r.enum {
63+
if item == val {
64+
found = true
65+
}
66+
}
67+
if !found {
68+
runner.EmitIssueOnExpr(
69+
r,
70+
fmt.Sprintf(`"%s" is an invalid value as opt_in_status`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsEc2HostInvalidAutoPlacementRule checks the pattern is valid
14+
type AwsEc2HostInvalidAutoPlacementRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsEc2HostInvalidAutoPlacementRule returns new rule with default attributes
21+
func NewAwsEc2HostInvalidAutoPlacementRule() *AwsEc2HostInvalidAutoPlacementRule {
22+
return &AwsEc2HostInvalidAutoPlacementRule{
23+
resourceType: "aws_ec2_host",
24+
attributeName: "auto_placement",
25+
enum: []string{
26+
"on",
27+
"off",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsEc2HostInvalidAutoPlacementRule) Name() string {
34+
return "aws_ec2_host_invalid_auto_placement"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsEc2HostInvalidAutoPlacementRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsEc2HostInvalidAutoPlacementRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsEc2HostInvalidAutoPlacementRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsEc2HostInvalidAutoPlacementRule) 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+
found := false
62+
for _, item := range r.enum {
63+
if item == val {
64+
found = true
65+
}
66+
}
67+
if !found {
68+
runner.EmitIssueOnExpr(
69+
r,
70+
fmt.Sprintf(`"%s" is an invalid value as auto_placement`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsEc2HostInvalidHostRecoveryRule checks the pattern is valid
14+
type AwsEc2HostInvalidHostRecoveryRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsEc2HostInvalidHostRecoveryRule returns new rule with default attributes
21+
func NewAwsEc2HostInvalidHostRecoveryRule() *AwsEc2HostInvalidHostRecoveryRule {
22+
return &AwsEc2HostInvalidHostRecoveryRule{
23+
resourceType: "aws_ec2_host",
24+
attributeName: "host_recovery",
25+
enum: []string{
26+
"on",
27+
"off",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsEc2HostInvalidHostRecoveryRule) Name() string {
34+
return "aws_ec2_host_invalid_host_recovery"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsEc2HostInvalidHostRecoveryRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsEc2HostInvalidHostRecoveryRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsEc2HostInvalidHostRecoveryRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsEc2HostInvalidHostRecoveryRule) 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+
found := false
62+
for _, item := range r.enum {
63+
if item == val {
64+
found = true
65+
}
66+
}
67+
if !found {
68+
runner.EmitIssueOnExpr(
69+
r,
70+
fmt.Sprintf(`"%s" is an invalid value as host_recovery`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// This file generated by `generator/`. DO NOT EDIT
2+
3+
package models
4+
5+
import (
6+
"fmt"
7+
"log"
8+
9+
hcl "github.com/hashicorp/hcl/v2"
10+
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
11+
)
12+
13+
// AwsEc2SubnetCidrReservationInvalidReservationTypeRule checks the pattern is valid
14+
type AwsEc2SubnetCidrReservationInvalidReservationTypeRule struct {
15+
resourceType string
16+
attributeName string
17+
enum []string
18+
}
19+
20+
// NewAwsEc2SubnetCidrReservationInvalidReservationTypeRule returns new rule with default attributes
21+
func NewAwsEc2SubnetCidrReservationInvalidReservationTypeRule() *AwsEc2SubnetCidrReservationInvalidReservationTypeRule {
22+
return &AwsEc2SubnetCidrReservationInvalidReservationTypeRule{
23+
resourceType: "aws_ec2_subnet_cidr_reservation",
24+
attributeName: "reservation_type",
25+
enum: []string{
26+
"prefix",
27+
"explicit",
28+
},
29+
}
30+
}
31+
32+
// Name returns the rule name
33+
func (r *AwsEc2SubnetCidrReservationInvalidReservationTypeRule) Name() string {
34+
return "aws_ec2_subnet_cidr_reservation_invalid_reservation_type"
35+
}
36+
37+
// Enabled returns whether the rule is enabled by default
38+
func (r *AwsEc2SubnetCidrReservationInvalidReservationTypeRule) Enabled() bool {
39+
return true
40+
}
41+
42+
// Severity returns the rule severity
43+
func (r *AwsEc2SubnetCidrReservationInvalidReservationTypeRule) Severity() string {
44+
return tflint.ERROR
45+
}
46+
47+
// Link returns the rule reference link
48+
func (r *AwsEc2SubnetCidrReservationInvalidReservationTypeRule) Link() string {
49+
return ""
50+
}
51+
52+
// Check checks the pattern is valid
53+
func (r *AwsEc2SubnetCidrReservationInvalidReservationTypeRule) 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+
found := false
62+
for _, item := range r.enum {
63+
if item == val {
64+
found = true
65+
}
66+
}
67+
if !found {
68+
runner.EmitIssueOnExpr(
69+
r,
70+
fmt.Sprintf(`"%s" is an invalid value as reservation_type`, truncateLongMessage(val)),
71+
attribute.Expr,
72+
)
73+
}
74+
return nil
75+
})
76+
})
77+
}

0 commit comments

Comments
 (0)