Skip to content

Commit 67edcaa

Browse files
authored
feat: Ability to set custom security_group_name (#379)
feat: ability to customise security_group_name
1 parent 4380f14 commit 67edcaa

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ No modules.
354354
| <a name="input_s3_import"></a> [s3\_import](#input\_s3\_import) | Configuration map used to restore from a Percona Xtrabackup in S3 (only MySQL is supported) | `map(string)` | `{}` | no |
355355
| <a name="input_scaling_configuration"></a> [scaling\_configuration](#input\_scaling\_configuration) | Map of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` | `map(string)` | `{}` | no |
356356
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | The description of the security group. If value is set to empty string it will contain cluster name in the description | `string` | `null` | no |
357+
| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | The security group name. Default value is (`var.name`) | `string` | `""` | no |
357358
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | Map of security group rules to add to the cluster security group created | `any` | `{}` | no |
358359
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | Additional tags for the security group | `map(string)` | `{}` | no |
359360
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether the security group name (`var.name`) is used as a prefix | `bool` | `true` | no |

main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ locals {
88
internal_db_subnet_group_name = try(coalesce(var.db_subnet_group_name, var.name), "")
99
db_subnet_group_name = var.create_db_subnet_group ? try(aws_db_subnet_group.this[0].name, null) : local.internal_db_subnet_group_name
1010

11+
security_group_name = try(coalesce(var.security_group_name, var.name), "")
12+
1113
cluster_parameter_group_name = try(coalesce(var.db_cluster_parameter_group_name, var.name), null)
1214
db_parameter_group_name = try(coalesce(var.db_parameter_group_name, var.name), null)
1315

@@ -306,8 +308,8 @@ resource "aws_appautoscaling_policy" "this" {
306308
resource "aws_security_group" "this" {
307309
count = local.create && var.create_security_group ? 1 : 0
308310

309-
name = var.security_group_use_name_prefix ? null : var.name
310-
name_prefix = var.security_group_use_name_prefix ? "${var.name}-" : null
311+
name = var.security_group_use_name_prefix ? null : local.security_group_name
312+
name_prefix = var.security_group_use_name_prefix ? "${local.security_group_name}-" : null
311313
vpc_id = var.vpc_id
312314
description = coalesce(var.security_group_description, "Control traffic to/from RDS Aurora ${var.name}")
313315

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,12 @@ variable "create_security_group" {
546546
default = true
547547
}
548548

549+
variable "security_group_name" {
550+
description = "The security group name. Default value is (`var.name`)"
551+
type = string
552+
default = ""
553+
}
554+
549555
variable "security_group_use_name_prefix" {
550556
description = "Determines whether the security group name (`var.name`) is used as a prefix"
551557
type = bool

0 commit comments

Comments
 (0)