Skip to content

Commit 6a73ce8

Browse files
Updated security groups to fix trivy low issue
1 parent ba5f481 commit 6a73ce8

File tree

8 files changed

+16
-1
lines changed

8 files changed

+16
-1
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ repos:
1111
hooks:
1212
- id: terraform_fmt
1313
name: Terraform Formatter
14+
- id: terraform_trivy
15+
name: Terraform Trivy Security Scan
16+
files: ^red-instance/.*\.tf$
1417
- repo: https://github.com/terraform-docs/terraform-docs
1518
rev: v0.20.0
1619
hooks:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ No modules.
8383
| <a name="input_dns_name"></a> [dns\_name](#input\_dns\_name) | The DNS name to use for the public DNS record | `string` | `""` | no |
8484
| <a name="input_enable_public_dns"></a> [enable\_public\_dns](#input\_enable\_public\_dns) | Controls whether a public DNS record should be created | `bool` | `false` | no |
8585
| <a name="input_enable_s3_bucket_policy"></a> [enable\_s3\_bucket\_policy](#input\_enable\_s3\_bucket\_policy) | Controls whether an S3 bucket policy should be attached to the instance role | `bool` | `false` | no |
86-
| <a name="input_ingress_rules"></a> [ingress\_rules](#input\_ingress\_rules) | List of ingress rules | <pre>list(object({<br/> from_port = number<br/> to_port = number<br/> protocol = string<br/> cidr_blocks = list(string)<br/> }))</pre> | <pre>[<br/> {<br/> "cidr_blocks": [<br/> "0.0.0.0/0"<br/> ],<br/> "from_port": 22,<br/> "protocol": "tcp",<br/> "to_port": 22<br/> }<br/>]</pre> | no |
86+
| <a name="input_ingress_rules"></a> [ingress\_rules](#input\_ingress\_rules) | List of ingress rules | <pre>list(object({<br/> description = string<br/> from_port = number<br/> to_port = number<br/> protocol = string<br/> cidr_blocks = list(string)<br/> }))</pre> | <pre>[<br/> {<br/> "cidr_blocks": [<br/> "0.0.0.0/0"<br/> ],<br/> "description": "Allow SSH access",<br/> "from_port": 22,<br/> "protocol": "tcp",<br/> "to_port": 22<br/> }<br/>]</pre> | no |
8787
| <a name="input_instance_name"></a> [instance\_name](#input\_instance\_name) | The name of the instance | `string` | n/a | yes |
8888
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The instance type to use for the instance | `string` | `"t4g.small"` | no |
8989
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Set the project name. | `string` | n/a | yes |

red-instance/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ resource "aws_security_group" "allow_ssh" {
3939
dynamic "ingress" {
4040
for_each = var.ingress_rules
4141
content {
42+
description = ingress.value.description
4243
from_port = ingress.value.from_port
4344
to_port = ingress.value.to_port
4445
protocol = ingress.value.protocol

red-instance/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ variable "volume_size" {
6868
variable "ingress_rules" {
6969
description = "List of ingress rules"
7070
type = list(object({
71+
description = string
7172
from_port = number
7273
to_port = number
7374
protocol = string
7475
cidr_blocks = list(string)
7576
}))
7677
default = [
7778
{
79+
description = "Allow SSH access"
7880
from_port = 22
7981
to_port = 22
8082
protocol = "tcp"

tests/dns-only/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module "red-instance" {
4242
# Only allow SSH access
4343
ingress_rules = [
4444
{
45+
description = "Allow SSH access from anywhere"
4546
from_port = 22
4647
to_port = 22
4748
protocol = "tcp"

tests/full-force/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,28 @@ module "red-instance" {
4242
# Comprehensive security group rules
4343
ingress_rules = [
4444
{
45+
description = "Allow SSH access from the VPC"
4546
from_port = 22
4647
to_port = 22
4748
protocol = "tcp"
4849
cidr_blocks = ["10.0.0.0/16"]
4950
},
5051
{
52+
description = "Allow HTTP access from anywhere"
5153
from_port = 80
5254
to_port = 80
5355
protocol = "tcp"
5456
cidr_blocks = ["0.0.0.0/0"]
5557
},
5658
{
59+
description = "Allow HTTPS access from anywhere"
5760
from_port = 443
5861
to_port = 443
5962
protocol = "tcp"
6063
cidr_blocks = ["0.0.0.0/0"]
6164
},
6265
{
66+
description = "Allow custom application traffic"
6367
from_port = 8000
6468
to_port = 9000
6569
protocol = "tcp"

tests/manual/disabled/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ module "red-instance" {
77
region = "us-east-1"
88
ingress_rules = [
99
{
10+
description = "Allow SSH access from anywhere"
1011
from_port = 22
1112
to_port = 22
1213
protocol = "tcp"
1314
cidr_blocks = ["0.0.0.0/0"]
1415
},
1516
{
17+
description = "Allow HTTP access from anywhere"
1618
from_port = 80
1719
to_port = 80
1820
protocol = "tcp"

tests/manual/enabled/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ module "red-instance" {
55
region = "us-east-1"
66
ingress_rules = [
77
{
8+
description = "Allow SSH access from anywhere"
89
from_port = 22
910
to_port = 22
1011
protocol = "tcp"
1112
cidr_blocks = ["0.0.0.0/0"]
1213
},
1314
{
15+
description = "Allow HTTP access from anywhere"
1416
from_port = 80
1517
to_port = 80
1618
protocol = "tcp"

0 commit comments

Comments
 (0)