Skip to content

Commit b6bbe43

Browse files
committed
feat(security-group): create security group before destroy
1 parent ec2e82d commit b6bbe43

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

modules/security-group/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This module creates following resources.
1818

1919
| Name | Version |
2020
|------|---------|
21-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.24.0 |
21+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.3.0 |
2222

2323
## Modules
2424

@@ -41,8 +41,8 @@ This module creates following resources.
4141
| <a name="input_name"></a> [name](#input\_name) | (Required) The name of the security group. | `string` | n/a | yes |
4242
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | (Required) The ID of the associated VPC. | `string` | n/a | yes |
4343
| <a name="input_description"></a> [description](#input\_description) | (Optional) The security group description. This field maps to the AWS `GroupDescription` attribute, for which there is no Update API. | `string` | `"Managed by Terraform."` | no |
44-
| <a name="input_egress_rules"></a> [egress\_rules](#input\_egress\_rules) | (Optional) The configuration for egress rules of the security group. Each block of `egress_rules` as defined below.<br> (Required) `id` - The ID of the egress rule. This value is only used internally within Terraform code.<br> (Optional) `description` - The description of the rule.<br> (Required) `protocol` - The protocol to match. Note that if `protocol` is set to `-1`, it translates to all protocols, all port ranges, and `from_port` and `to_port` values should not be defined.<br> (Required) `from_port` - The start of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 type.<br> (Required) `to_port` - The end of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 code.<br> (Optional) `ipv4_cidrs` - The IPv4 network ranges to allow, in CIDR notation.<br> (Optional) `ipv6_cidrs` - The IPv6 network ranges to allow, in CIDR notation.<br> (Optional) `prefix_lists` - The prefix list IDs to allow.<br> (Optional) `security_groups` - The source security group IDs to allow.<br> (Optional) `self` - Whether the security group itself will be added as a source to this ingress rule. | <pre>list(object({<br> id = string<br> description = optional(string, "Managed by Terraform.")<br> protocol = string<br> from_port = number<br> to_port = number<br> ipv4_cidrs = optional(list(string), [])<br> ipv6_cidrs = optional(list(string), [])<br> prefix_lists = optional(list(string), [])<br> security_groups = optional(list(string), [])<br> self = optional(bool, false)<br> }))</pre> | `[]` | no |
45-
| <a name="input_ingress_rules"></a> [ingress\_rules](#input\_ingress\_rules) | (Optional) The configuration for ingress rules of the security group. Each block of `ingress_rules` as defined below.<br> (Required) `id` - The ID of the ingress rule. This value is only used internally within Terraform code.<br> (Optional) `description` - The description of the rule.<br> (Required) `protocol` - The protocol to match. Note that if `protocol` is set to `-1`, it translates to all protocols, all port ranges, and `from_port` and `to_port` values should not be defined.<br> (Required) `from_port` - The start of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 type.<br> (Required) `to_port` - The end of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 code.<br> (Optional) `ipv4_cidrs` - The IPv4 network ranges to allow, in CIDR notation.<br> (Optional) `ipv6_cidrs` - The IPv6 network ranges to allow, in CIDR notation.<br> (Optional) `prefix_lists` - The prefix list IDs to allow.<br> (Optional) `security_groups` - The source security group IDs to allow.<br> (Optional) `self` - Whether the security group itself will be added as a source to this ingress rule. | <pre>list(object({<br> id = string<br> description = optional(string, "Managed by Terraform.")<br> protocol = string<br> from_port = number<br> to_port = number<br> ipv4_cidrs = optional(list(string), [])<br> ipv6_cidrs = optional(list(string), [])<br> prefix_lists = optional(list(string), [])<br> security_groups = optional(list(string), [])<br> self = optional(bool, false)<br> }))</pre> | `[]` | no |
44+
| <a name="input_egress_rules"></a> [egress\_rules](#input\_egress\_rules) | (Optional) The configuration for egress rules of the security group. Each block of `egress_rules` as defined below.<br/> (Required) `id` - The ID of the egress rule. This value is only used internally within Terraform code.<br/> (Optional) `description` - The description of the rule.<br/> (Required) `protocol` - The protocol to match. Note that if `protocol` is set to `-1`, it translates to all protocols, all port ranges, and `from_port` and `to_port` values should not be defined.<br/> (Required) `from_port` - The start of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 type.<br/> (Required) `to_port` - The end of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 code.<br/> (Optional) `ipv4_cidrs` - The IPv4 network ranges to allow, in CIDR notation.<br/> (Optional) `ipv6_cidrs` - The IPv6 network ranges to allow, in CIDR notation.<br/> (Optional) `prefix_lists` - The prefix list IDs to allow.<br/> (Optional) `security_groups` - The source security group IDs to allow.<br/> (Optional) `self` - Whether the security group itself will be added as a source to this ingress rule. | <pre>list(object({<br/> id = string<br/> description = optional(string, "Managed by Terraform.")<br/> protocol = string<br/> from_port = number<br/> to_port = number<br/> ipv4_cidrs = optional(list(string), [])<br/> ipv6_cidrs = optional(list(string), [])<br/> prefix_lists = optional(list(string), [])<br/> security_groups = optional(list(string), [])<br/> self = optional(bool, false)<br/> }))</pre> | `[]` | no |
45+
| <a name="input_ingress_rules"></a> [ingress\_rules](#input\_ingress\_rules) | (Optional) The configuration for ingress rules of the security group. Each block of `ingress_rules` as defined below.<br/> (Required) `id` - The ID of the ingress rule. This value is only used internally within Terraform code.<br/> (Optional) `description` - The description of the rule.<br/> (Required) `protocol` - The protocol to match. Note that if `protocol` is set to `-1`, it translates to all protocols, all port ranges, and `from_port` and `to_port` values should not be defined.<br/> (Required) `from_port` - The start of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 type.<br/> (Required) `to_port` - The end of port range for the TCP and UDP protocols, or an ICMP/ICMPv6 code.<br/> (Optional) `ipv4_cidrs` - The IPv4 network ranges to allow, in CIDR notation.<br/> (Optional) `ipv6_cidrs` - The IPv6 network ranges to allow, in CIDR notation.<br/> (Optional) `prefix_lists` - The prefix list IDs to allow.<br/> (Optional) `security_groups` - The source security group IDs to allow.<br/> (Optional) `self` - Whether the security group itself will be added as a source to this ingress rule. | <pre>list(object({<br/> id = string<br/> description = optional(string, "Managed by Terraform.")<br/> protocol = string<br/> from_port = number<br/> to_port = number<br/> ipv4_cidrs = optional(list(string), [])<br/> ipv6_cidrs = optional(list(string), [])<br/> prefix_lists = optional(list(string), [])<br/> security_groups = optional(list(string), [])<br/> self = optional(bool, false)<br/> }))</pre> | `[]` | no |
4646
| <a name="input_module_tags_enabled"></a> [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no |
4747
| <a name="input_resource_group_description"></a> [resource\_group\_description](#input\_resource\_group\_description) | (Optional) The description of Resource Group. | `string` | `"Managed by Terraform."` | no |
4848
| <a name="input_resource_group_enabled"></a> [resource\_group\_enabled](#input\_resource\_group\_enabled) | (Optional) Whether to create Resource Group to find and group AWS resources which are created by this module. | `bool` | `true` | no |

modules/security-group/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,8 @@ resource "aws_security_group" "this" {
4040
local.module_tags,
4141
var.tags,
4242
)
43+
44+
lifecycle {
45+
create_before_destroy = true
46+
}
4347
}

0 commit comments

Comments
 (0)