1- name : Terraform Module Security-Group
1+ ---
2+ #
3+ # This is the canonical configuration for the `README.md`
4+ # Run `make readme` to rebuild the `README.md`
5+ #
6+
7+ # Name of this project
8+ name : Terraform AWS Subnet
29
310# License of this project
411license : " APACHE"
@@ -18,6 +25,9 @@ badges:
1825 image : " https://img.shields.io/badge/License-APACHE-blue.svg"
1926 url : " LICENSE.md"
2027
28+ prerequesties :
29+ - name : Terraform 1.5.4
30+ url : https://learn.hashicorp.com/terraform/getting-started/install.html
2131# description of this project
2232description : |-
2333 This terraform module creates set of Security Group and Security Group Rules resources in various combinations.
@@ -26,78 +36,202 @@ description: |-
2636include :
2737 - " terraform.md"
2838
29- # How to use this project
3039# How to use this project
3140usage : |-
3241 Here are some examples of how you can use this module in your inventory structure:
33- ### NEW_SECURITY_GROUP
42+ ### Basic
3443 Here is an example of how you can use this module in your inventory structure:
3544 ```hcl
3645 # use this
3746 module "security_group" {
38- source = "clouddrove/security-group/aws"
39- version = "1.3 .0"
40- name = "security-group "
47+ source = "clouddrove/security-group/aws"
48+ version = "2.0 .0"
49+ name = "app "
4150 environment = "test"
42- label_order = ["name", "environment"]
43-
44- vpc_id = module.vpc.vpc_id
45- new_enable_security_group = true
46- allowed_ip = ["172.16.0.0/16", "10.0.0.0/16"]
47- allowed_ports = [22, 27017]
48- security_groups = []
49- max_entries = 5
50- prefix_list_enabled = true
51- prefix_list_id = []
52- entry = [
53- {
54- cidr = "10.0.0.0/16"
55- description = "VPC CIDR"
51+ vpc_id = module.vpc.vpc_id
52+
53+ ## INGRESS Rules
54+ new_sg_ingress_rules_with_cidr_blocks = [{
55+ rule_count = 1
56+ from_port = 22
57+ protocol = "tcp"
58+ to_port = 22
59+ cidr_blocks = [module.vpc.vpc_cidr_block, "172.16.0.0/16"]
60+ description = "Allow ssh traffic."
5661 },
5762 {
58- cidr = "10.10.0.0/24"
59- description = "VPC CIDR"
63+ rule_count = 2
64+ from_port = 27017
65+ protocol = "tcp"
66+ to_port = 27017
67+ cidr_blocks = ["172.16.0.0/16"]
68+ description = "Allow Mongodb traffic."
6069 }
6170 ]
71+
72+ ## EGRESS Rules
73+ new_sg_egress_rules_with_cidr_blocks = [{
74+ rule_count = 1
75+ from_port = 22
76+ protocol = "tcp"
77+ to_port = 22
78+ cidr_blocks = [module.vpc.vpc_cidr_block, "172.16.0.0/16"]
79+ description = "Allow ssh outbound traffic."
80+ },
81+ {
82+ rule_count = 2
83+ from_port = 27017
84+ protocol = "tcp"
85+ to_port = 27017
86+ cidr_blocks = ["172.16.0.0/16"]
87+ description = "Allow Mongodb outbound traffic."
88+ }]
6289 }
6390 ```
64- ### NEW_SECURITY_GROUP_WITH_EGRESS
65- module "security_group" {
91+
92+ ### ONLY RULES
93+ module "security_group_rules" {
6694 source = "clouddrove/security-group/aws"
67- version = "1.3.0"
68- name = "security-group"
69- environment = "test"
70- label_order = ["name", "environment"]
71-
72- vpc_id = module.vpc.vpc_id
73- prefix_list_enabled = false
74- allowed_ip = ["172.16.0.0/16", "10.0.0.0/16"]
75- allowed_ipv6 = ["2405:201:5e00:3684:cd17:9397:5734:a167/128"]
76- allowed_ports = [22, 27017]
77- security_groups = ["sg-xxxxxxxxx"]
78- prefix_list_id = ["pl-6da54004"]
79- egress_rule = true
80- egress_allowed_ip = ["172.16.0.0/16", "10.0.0.0/16"]
81- egress_allowed_ports = [22, 27017]
82- egress_protocol = "tcp"
83- egress_prefix_list_ids = ["pl-xxxxxxxxx"]
84- egress_security_groups = ["sg-xxxxxxxxx"]
95+ version = "2.0.0"
96+ name = "app"
97+ environment = "test"
98+ vpc_id = "vpc-xxxxxxxxx"
99+ new_sg = false
100+ existing_sg_id = "sg-xxxxxxxxx"
101+
102+ ## INGRESS Rules
103+ existing_sg_ingress_rules_with_cidr_blocks = [{
104+ rule_count = 1
105+ from_port = 22
106+ protocol = "tcp"
107+ to_port = 22
108+ cidr_blocks = ["10.9.0.0/16"]
109+ description = "Allow ssh traffic."
110+ },
111+ {
112+ rule_count = 2
113+ from_port = 27017
114+ protocol = "tcp"
115+ to_port = 27017
116+ cidr_blocks = ["10.9.0.0/16"]
117+ description = "Allow Mongodb traffic."
118+ }
119+ ]
120+
121+ existing_sg_ingress_rules_with_self = [{
122+ rule_count = 1
123+ from_port = 22
124+ protocol = "tcp"
125+ to_port = 22
126+ description = "Allow ssh traffic."
127+ },
128+ {
129+ rule_count = 2
130+ from_port = 27017
131+ protocol = "tcp"
132+ to_port = 27017
133+ description = "Allow Mongodb traffic."
134+ }
135+ ]
85136
137+ existing_sg_ingress_rules_with_source_sg_id = [{
138+ rule_count = 1
139+ from_port = 22
140+ protocol = "tcp"
141+ to_port = 22
142+ source_security_group_id = "sg-xxxxxxxxx"
143+ description = "Allow ssh traffic."
144+ },
145+ {
146+ rule_count = 2
147+ from_port = 27017
148+ protocol = "tcp"
149+ to_port = 27017
150+ source_security_group_id = "sg-xxxxxxxxx"
151+ description = "Allow Mongodb traffic."
152+ }]
153+
154+ ## EGRESS Rules
155+ existing_sg_egress_rules_with_cidr_blocks = [{
156+ rule_count = 1
157+ from_port = 22
158+ protocol = "tcp"
159+ to_port = 22
160+ cidr_blocks = ["10.9.0.0/16"]
161+ description = "Allow ssh outbound traffic."
162+ },
163+ {
164+ rule_count = 2
165+ from_port = 27017
166+ protocol = "tcp"
167+ to_port = 27017
168+ cidr_blocks = ["10.9.0.0/16"]
169+ description = "Allow Mongodb outbound traffic."
170+ }]
171+
172+ existing_sg_egress_rules_with_self = [{
173+ rule_count = 1
174+ from_port = 22
175+ protocol = "tcp"
176+ to_port = 22
177+ description = "Allow ssh outbound traffic."
178+ },
179+ {
180+ rule_count = 2
181+ from_port = 27017
182+ protocol = "tcp"
183+ to_port = 27017
184+ description = "Allow Mongodb outbound traffic."
185+ }]
186+
187+ existing_sg_egress_rules_with_source_sg_id = [{
188+ rule_count = 1
189+ from_port = 22
190+ protocol = "tcp"
191+ to_port = 22
192+ source_security_group_id = "sg-xxxxxxxxx"
193+ description = "Allow ssh outbound traffic."
194+ },
195+ {
196+ rule_count = 2
197+ from_port = 27017
198+ protocol = "tcp"
199+ to_port = 27017
200+ source_security_group_id = "sg-xxxxxxxxx"
201+ description = "Allow Mongodb outbound traffic."
202+ }]
86203 }
87204 ```
88- ### UPDATED_EXISTING
89- module "security_group" {
90- source = "clouddrove/security-group/aws"
91- version = "1.3.0"
92- name = "security-group"
93- environment = "test"
94- label_order = ["name", "environment"]
95-
96- is_external = true
97- existing_sg_id = "sg-xxxxxxxxxxxx"
98- vpc_id = module.vpc.vpc_id
99- allowed_ip = ["172.16.0.0/16", "10.0.0.0/16"]
100- allowed_ports = [22, 27017]
101- security_groups = ["sg-xxxxxxxxxxxxx"]
205+
206+ ### PREFIX LIST
207+ module "security_group" {
208+ source = "clouddrove/security-group/aws"
209+ version = "2.0.0"
210+ name = "app"
211+ environment = "test"
212+ vpc_id = module.vpc.vpc_id
213+ prefix_list_enabled = true
214+ entry = [{
215+ cidr = "10.19.0.0/16"
216+ }]
217+
218+ ## INGRESS Rules
219+ new_sg_ingress_rules_with_prefix_list = [{
220+ rule_count = 1
221+ from_port = 22
222+ protocol = "tcp"
223+ to_port = 22
224+ description = "Allow ssh traffic."
225+ }
226+ ]
227+ ## EGRESS Rules
228+ new_sg_egress_rules_with_prefix_list = [{
229+ rule_count = 1
230+ from_port = 3306
231+ protocol = "tcp"
232+ to_port = 3306
233+ description = "Allow mysql/aurora outbound traffic."
234+ }
235+ ]
102236 }
103- ```
237+ ```
0 commit comments