Skip to content

Commit 64a1b35

Browse files
committed
finish docs
1 parent 6c1f13e commit 64a1b35

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

docs/rules/aws_security_group_rule_deprecated.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,26 @@
55
## Example
66

77
```hcl
8-
resource "null_resource" "foo" {
9-
// TODO: Write the example Terraform code which violates the rule
8+
resource "aws_security_group_rule" "foo" {
9+
security_group_id = "sg-12345678"
1010
}
1111
```
1212

13-
```
14-
$ tflint
13+
```sh
14+
❯ tflint
15+
1 issue(s) found:
1516

16-
// TODO: Write the output when inspects the above code
17+
Warning: Consider using aws_vpc_security_group_egress_rule or aws_vpc_security_group_ingress_rule instead.
1718

19+
on test.tf line 5:
20+
4: resource "aws_security_group_rule" "foo" {
21+
5: security_group_id = "sg-12345678"
22+
6: }
1823
```
19-
2024
## Why
2125
22-
// TODO: Write why you should follow the rule. This section is also a place to explain the value of the rule
26+
Avoid using the `aws_security_group_rule` resource, as it struggles with managing multiple CIDR blocks, and, due to the historical lack of unique IDs, tags and descriptions.
2327
2428
## How To Fix
2529
26-
// TODO: Write how to fix it to avoid the problem
30+
Depending on `foo.type`, you can fix the issue by using either `aws_vpc_security_group_egress_rule` or `aws_vpc_security_group_ingress_rule`:

rules/aws_security_group_rule_deprecated.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,10 @@ func (r *AwsSecurityGroupRuleDeprecatedRule) Check(runner tflint.Runner) error {
5454
}
5555

5656
for _, resource := range resources.Blocks {
57-
attribute, exists := resource.Body.Attributes[r.attributeName]
58-
if !exists {
59-
continue
60-
}
61-
6257
runner.EmitIssue(
6358
r,
6459
"Consider using aws_vpc_security_group_egress_rule or aws_vpc_security_group_ingress_rule instead.",
65-
attribute.Expr.Range(),
60+
resource.DefRange,
6661
)
6762
}
6863

rules/aws_security_group_rule_deprecated_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ resource "aws_security_group_rule" "test" {
2626
Message: "Consider using aws_vpc_security_group_egress_rule or aws_vpc_security_group_ingress_rule instead.",
2727
Range: hcl.Range{
2828
Filename: "resource.tf",
29-
Start: hcl.Pos{Line: 3, Column: 22},
30-
End: hcl.Pos{Line: 3, Column: 35},
29+
Start: hcl.Pos{Line: 2, Column: 1},
30+
End: hcl.Pos{Line: 2, Column: 42},
3131
},
3232
},
3333
},

0 commit comments

Comments
 (0)