Skip to content

Commit ee655e5

Browse files
ckappenIc3w0lf
andauthored
feat: Add Prefix List Ids (#16)
* feat: Add Prefix List Ids --------- Co-authored-by: Jerome Wolff <[email protected]>
1 parent e45f1ba commit ee655e5

16 files changed

+284
-1297
lines changed

.github/workflows/test.yaml

+3-12
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ permissions:
2929
# Run the job #
3030
###############
3131
jobs:
32-
terratest:
33-
name: Terratest
32+
terraform-test:
33+
name: Terraform Test
3434
runs-on: ubuntu-latest
3535
steps:
3636
############################
@@ -49,18 +49,9 @@ jobs:
4949
aws-region: ${{ vars.AWS_TESTING_REGION }}
5050
mask-aws-account-id: false
5151

52-
################
53-
# Setup Golang #
54-
################
55-
- name: Set up Go
56-
uses: actions/setup-go@v4
57-
with:
58-
go-version-file: 'go.mod'
59-
6052
#############
6153
# Run tests #
6254
#############
6355
- name: Run Tests
6456
timeout-minutes: 30
65-
working-directory: test
66-
run: go test -v
57+
run: terraform init && terraform test

.pre-commit-config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ repos:
44
hooks:
55
- id: terraform_docs
66
- id: terraform_fmt
7+
args:
8+
- --args=-recursive
79
- id: terraform_validate
810
args:
911
- --hook-config=--retry-once-with-cleanup=true

.tflint.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ plugin "terraform" {
55

66
plugin "aws" {
77
enabled = true
8-
version = "0.18.0"
8+
version = "0.27.0"
99
source = "github.com/terraform-linters/tflint-ruleset-aws"
1010
}

README.md

+21-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ Terraform module to create a Security Group with ingress and egress rules in one
4343
| Name | Description | Type | Default | Required |
4444
|------|-------------|------|---------|:--------:|
4545
| <a name="input_description"></a> [description](#input\_description) | Description of the Security Group. | `string` | `null` | no |
46-
| <a name="input_egress_rules"></a> [egress\_rules](#input\_egress\_rules) | Egress rules to add to the Security Group. See examples for usage. | <pre>list(object({<br> protocol = string<br> description = optional(string)<br><br> port = optional(number)<br> to_port = optional(number)<br> from_port = optional(number)<br><br> cidr_blocks = optional(list(string))<br> source_security_group_id = optional(string)<br><br> self = optional(bool)<br> }))</pre> | `[]` | no |
47-
| <a name="input_ingress_rules"></a> [ingress\_rules](#input\_ingress\_rules) | Ingress rules to add to the Security Group. See examples for usage. | <pre>list(object({<br> protocol = string<br> description = optional(string)<br><br> port = optional(number)<br> to_port = optional(number)<br> from_port = optional(number)<br><br> cidr_blocks = optional(list(string))<br> source_security_group_id = optional(string)<br><br> self = optional(bool)<br> }))</pre> | `[]` | no |
46+
| <a name="input_egress_rules"></a> [egress\_rules](#input\_egress\_rules) | Egress rules to add to the Security Group. See examples for usage. | <pre>list(object({<br> protocol = string<br> description = optional(string)<br><br> port = optional(number)<br> to_port = optional(number)<br> from_port = optional(number)<br><br> cidr_blocks = optional(list(string))<br> prefix_list_ids = optional(list(string))<br> source_security_group_id = optional(string)<br> self = optional(bool)<br> }))</pre> | `[]` | no |
47+
| <a name="input_ingress_rules"></a> [ingress\_rules](#input\_ingress\_rules) | Ingress rules to add to the Security Group. See examples for usage. | <pre>list(object({<br> protocol = string<br> description = optional(string)<br><br> port = optional(number)<br> to_port = optional(number)<br> from_port = optional(number)<br><br> cidr_blocks = optional(list(string))<br> prefix_list_ids = optional(list(string))<br> source_security_group_id = optional(string)<br> self = optional(bool)<br> }))</pre> | `[]` | no |
4848
| <a name="input_name"></a> [name](#input\_name) | Name of the Security Group and Prefix. | `string` | n/a | yes |
4949
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Whether to use the name as prefix or regular name. | `bool` | `true` | no |
5050
| <a name="input_revoke_rules_on_delete"></a> [revoke\_rules\_on\_delete](#input\_revoke\_rules\_on\_delete) | Instruct Terraform to revoke all of the Security Groups attached ingress and egress rules before deleting the rule itself. This is normally not needed. | `bool` | `false` | no |
@@ -66,7 +66,7 @@ Terraform module to create a Security Group with ingress and egress rules in one
6666
## Resources
6767

6868
- resource.aws_security_group.main (main.tf#6)
69-
- resource.aws_security_group_rule.main_egress (main.tf#34)
69+
- resource.aws_security_group_rule.main_egress (main.tf#35)
7070
- resource.aws_security_group_rule.main_ingress (main.tf#18)
7171

7272
# Examples
@@ -87,6 +87,17 @@ module "source_security_group" {
8787
vpc_id = module.vpc.vpc_id
8888
}
8989
90+
resource "aws_ec2_managed_prefix_list" "test" {
91+
name = "All VPC CIDR-s"
92+
address_family = "IPv4"
93+
max_entries = 5
94+
95+
entry {
96+
cidr = "10.100.0.0/16"
97+
description = "Primary"
98+
}
99+
}
100+
90101
module "full" {
91102
source = "../../"
92103
@@ -153,6 +164,13 @@ module "full" {
153164
port = 3306
154165
protocol = "udp"
155166
self = true
167+
},
168+
169+
# Using prefix list
170+
{
171+
port = 443
172+
protocol = "tcp"
173+
prefix_list_ids = [aws_ec2_managed_prefix_list.test.id]
156174
}
157175
]
158176
}

examples/full/main.tf

+18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ module "source_security_group" {
1313
vpc_id = module.vpc.vpc_id
1414
}
1515

16+
resource "aws_ec2_managed_prefix_list" "test" {
17+
name = "All VPC CIDR-s"
18+
address_family = "IPv4"
19+
max_entries = 5
20+
21+
entry {
22+
cidr = "10.100.0.0/16"
23+
description = "Primary"
24+
}
25+
}
26+
1627
module "full" {
1728
source = "../../"
1829

@@ -79,6 +90,13 @@ module "full" {
7990
port = 3306
8091
protocol = "udp"
8192
self = true
93+
},
94+
95+
# Using prefix list
96+
{
97+
port = 443
98+
protocol = "tcp"
99+
prefix_list_ids = [aws_ec2_managed_prefix_list.test.id]
82100
}
83101
]
84102
}

go.mod

-67
This file was deleted.

0 commit comments

Comments
 (0)