Skip to content

Commit a8501c4

Browse files
committed
feat: add security_group_name_prefix_enabled
Signed-off-by: nitrocode <[email protected]>
1 parent 5eb31d0 commit a8501c4

File tree

7 files changed

+20
-1
lines changed

7 files changed

+20
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ Available targets:
462462
| <a name="input_retention_period"></a> [retention\_period](#input\_retention\_period) | Number of days to retain backups for | `number` | `5` | no |
463463
| <a name="input_s3_import"></a> [s3\_import](#input\_s3\_import) | Restore from a Percona Xtrabackup in S3. The `bucket_name` is required to be in the same region as the resource. | <pre>object({<br/> bucket_name = string<br/> bucket_prefix = string<br/> ingestion_role = string<br/> source_engine = string<br/> source_engine_version = string<br/> })</pre> | `null` | no |
464464
| <a name="input_scaling_configuration"></a> [scaling\_configuration](#input\_scaling\_configuration) | List of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` | <pre>list(object({<br/> auto_pause = bool<br/> max_capacity = number<br/> min_capacity = number<br/> seconds_until_auto_pause = number<br/> timeout_action = string<br/> }))</pre> | `[]` | no |
465+
| <a name="input_security_group_name_prefix_enabled"></a> [security\_group\_name\_prefix\_enabled](#input\_security\_group\_name\_prefix\_enabled) | Set to `true` to use `name_prefix` to name of the security group. Set to `false` to use `name` instead | `bool` | `false` | no |
465466
| <a name="input_security_groups"></a> [security\_groups](#input\_security\_groups) | List of security groups to be allowed to connect to the DB instance | `list(string)` | `[]` | no |
466467
| <a name="input_serverlessv2_scaling_configuration"></a> [serverlessv2\_scaling\_configuration](#input\_serverlessv2\_scaling\_configuration) | serverlessv2 scaling properties | <pre>object({<br/> min_capacity = number<br/> max_capacity = number<br/> })</pre> | `null` | no |
467468
| <a name="input_skip_final_snapshot"></a> [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB cluster is deleted | `bool` | `true` | no |

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
| <a name="input_retention_period"></a> [retention\_period](#input\_retention\_period) | Number of days to retain backups for | `number` | `5` | no |
149149
| <a name="input_s3_import"></a> [s3\_import](#input\_s3\_import) | Restore from a Percona Xtrabackup in S3. The `bucket_name` is required to be in the same region as the resource. | <pre>object({<br/> bucket_name = string<br/> bucket_prefix = string<br/> ingestion_role = string<br/> source_engine = string<br/> source_engine_version = string<br/> })</pre> | `null` | no |
150150
| <a name="input_scaling_configuration"></a> [scaling\_configuration](#input\_scaling\_configuration) | List of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` | <pre>list(object({<br/> auto_pause = bool<br/> max_capacity = number<br/> min_capacity = number<br/> seconds_until_auto_pause = number<br/> timeout_action = string<br/> }))</pre> | `[]` | no |
151+
| <a name="input_security_group_name_prefix_enabled"></a> [security\_group\_name\_prefix\_enabled](#input\_security\_group\_name\_prefix\_enabled) | Set to `true` to use `name_prefix` to name of the security group. Set to `false` to use `name` instead | `bool` | `false` | no |
151152
| <a name="input_security_groups"></a> [security\_groups](#input\_security\_groups) | List of security groups to be allowed to connect to the DB instance | `list(string)` | `[]` | no |
152153
| <a name="input_serverlessv2_scaling_configuration"></a> [serverlessv2\_scaling\_configuration](#input\_serverlessv2\_scaling\_configuration) | serverlessv2 scaling properties | <pre>object({<br/> min_capacity = number<br/> max_capacity = number<br/> })</pre> | `null` | no |
153154
| <a name="input_skip_final_snapshot"></a> [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB cluster is deleted | `bool` | `true` | no |

examples/complete/fixtures.us-east-2.tfvars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ intra_security_group_traffic_enabled = true
3838
parameter_group_name_prefix_enabled = true
3939

4040
rds_cluster_identifier_prefix_enabled = true
41+
42+
security_group_name_prefix_enabled = true

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module "rds_cluster" {
4848

4949
parameter_group_name_prefix_enabled = var.parameter_group_name_prefix_enabled
5050
rds_cluster_identifier_prefix_enabled = var.rds_cluster_identifier_prefix_enabled
51+
security_group_name_prefix_enabled = var.security_group_name_prefix_enabled
5152

5253
cluster_parameters = [
5354
{

examples/complete/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,10 @@ variable "rds_cluster_identifier_prefix_enabled" {
103103
default = false
104104
description = "Set to `true` to use `identifier_prefix` to name the cluster. Set to `false` to use `identifier` instead"
105105
}
106+
107+
variable "security_group_name_prefix_enabled" {
108+
type = bool
109+
default = false
110+
description = "Set to `true` to use `name_prefix` to name of the security group. Set to `false` to use `name` instead"
111+
}
112+

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ data "aws_partition" "current" {
2424
# TODO: Use cloudposse/security-group module
2525
resource "aws_security_group" "default" {
2626
count = local.enabled ? 1 : 0
27-
name = module.this.id
27+
name_prefix = var.security_group_name_prefix_enabled ? "${module.this.id}${module.this.delimiter}" : null
28+
name = !var.security_group_name_prefix_enabled ? module.this.id : null
2829
description = "Allow inbound traffic from Security Groups and CIDRs"
2930
vpc_id = var.vpc_id
3031
tags = module.this.tags

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,12 @@ variable "rds_cluster_identifier_prefix_enabled" {
565565
description = "Set to `true` to use `identifier_prefix` to name the cluster. Set to `false` to use `identifier` instead"
566566
}
567567

568+
variable "security_group_name_prefix_enabled" {
569+
type = bool
570+
default = false
571+
description = "Set to `true` to use `name_prefix` to name of the security group. Set to `false` to use `name` instead"
572+
}
573+
568574
variable "enable_global_write_forwarding" {
569575
type = bool
570576
default = null

0 commit comments

Comments
 (0)