-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored the SG Module and Clean trash files
- Loading branch information
Weyder Ferreira
committed
Jan 6, 2023
1 parent
834e24b
commit cf5aae6
Showing
10 changed files
with
196 additions
and
85 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
No requirements. | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_security_group.sg](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_description"></a> [description](#input\_description) | Fo what you be use this SG? | `string` | n/a | yes | | ||
| <a name="input_egress"></a> [egress](#input\_egress) | Egress 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> | `[]` | no | | ||
| <a name="input_ingress"></a> [ingress](#input\_ingress) | 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> | `[]` | no | | ||
| <a name="input_ingress_sg"></a> [ingress\_sg](#input\_ingress\_sg) | Ingress Rules | <pre>list(object({<br> description = string,<br> from_port = number,<br> to_port = number,<br> protocol = string,<br> security_groups = list(string)<br> }))</pre> | `[]` | no | | ||
| <a name="input_name"></a> [name](#input\_name) | The name of SG | `string` | n/a | yes | | ||
| <a name="input_revoke_rules_on_delete"></a> [revoke\_rules\_on\_delete](#input\_revoke\_rules\_on\_delete) | (Optional) Instruct Terraform to revoke all of the Security Groups attached ingress and egress rules before deleting the rule itself. This is normally not needed, however certain AWS services such as Elastic Map Reduce may automatically add required rules to security groups used with the service, and those rules may contain a cyclic dependency that prevent the security groups from being destroyed without removing the dependency first. | `bool` | `true` | no | | ||
| <a name="input_tags"></a> [tags](#input\_tags) | The tags of resource | `map(string)` | `null` | no | | ||
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC ID | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_id"></a> [id](#output\_id) | The name SG ID | | ||
| <a name="output_name"></a> [name](#output\_name) | The name SG name | | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
vpc/security-group/outputs.tf → vpc/security-group/custom/outputs.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
No requirements. | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_default_security_group.dsg](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_security_group) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_egress"></a> [egress](#input\_egress) | Egress 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> | `[]` | no | | ||
| <a name="input_ingress"></a> [ingress](#input\_ingress) | 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> | `[]` | no | | ||
| <a name="input_ingress_sg"></a> [ingress\_sg](#input\_ingress\_sg) | Ingress Rules | <pre>list(object({<br> description = string,<br> from_port = number,<br> to_port = number,<br> protocol = string,<br> security_groups = list(string)<br> }))</pre> | `[]` | no | | ||
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no | | ||
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | (Optional, Forces new resource) VPC ID. Note that changing the vpc\_id will not restore any default security group rules that were modified, added, or removed. It will be left in its current state. | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_id"></a> [id](#output\_id) | The name SG ID | | ||
| <a name="output_name"></a> [name](#output\_name) | The name SG ID | | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
resource "aws_default_security_group" "dsg" { | ||
vpc_id = var.vpc_id | ||
|
||
dynamic "ingress" { | ||
for_each = var.ingress | ||
content { | ||
description = ingress.value.description | ||
from_port = ingress.value.from_port | ||
to_port = ingress.value.to_port | ||
protocol = ingress.value.protocol | ||
cidr_blocks = ingress.value.cidr_blocks | ||
} | ||
} | ||
|
||
dynamic "ingress" { | ||
for_each = var.ingress_sg | ||
content { | ||
description = ingress.value.description | ||
from_port = ingress.value.from_port | ||
to_port = ingress.value.to_port | ||
protocol = ingress.value.protocol | ||
security_groups = ingress.value.security_groups | ||
} | ||
} | ||
|
||
dynamic "egress" { | ||
for_each = var.egress | ||
content { | ||
description = egress.value.description | ||
from_port = egress.value.from_port | ||
to_port = egress.value.to_port | ||
protocol = egress.value.protocol | ||
cidr_blocks = egress.value.cidr_blocks | ||
} | ||
} | ||
|
||
tags = var.tags | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "id" { | ||
value = aws_default_security_group.dsg.id | ||
description = "The name SG ID" | ||
} | ||
|
||
output "name" { | ||
value = aws_default_security_group.dsg.name | ||
description = "The name SG ID" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
variable "vpc_id" { | ||
type = string | ||
description = "(Optional, Forces new resource) VPC ID. Note that changing the vpc_id will not restore any default security group rules that were modified, added, or removed. It will be left in its current state." | ||
} | ||
variable "ingress" { | ||
type = list(object({ | ||
description = string, | ||
from_port = number, | ||
to_port = number, | ||
protocol = string, | ||
cidr_blocks = list(string) | ||
})) | ||
default = [] | ||
description = "Ingress Rules" | ||
} | ||
|
||
variable "ingress_sg" { | ||
type = list(object({ | ||
description = string, | ||
from_port = number, | ||
to_port = number, | ||
protocol = string, | ||
security_groups = list(string) | ||
})) | ||
default = [] | ||
description = "Ingress Rules" | ||
} | ||
|
||
variable "egress" { | ||
type = list(object({ | ||
description = string, | ||
from_port = number, | ||
to_port = number, | ||
protocol = string | ||
cidr_blocks = list(string) | ||
})) | ||
default = [] | ||
description = "Egress Rules" | ||
} | ||
|
||
variable "tags" { | ||
description = "A map of tags to add to all resources" | ||
type = map(string) | ||
default = {} | ||
} |
This file was deleted.
Oops, something went wrong.