Skip to content

Commit

Permalink
feat: Ability to set custom security_group_name (#379)
Browse files Browse the repository at this point in the history
feat: ability to customise security_group_name
  • Loading branch information
estahn authored May 12, 2023
1 parent 4380f14 commit 67edcaa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ No modules.
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | Additional tags for the security group | `map(string)` | `{}` | no |
| <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 |
Expand Down
6 changes: 4 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ locals {
internal_db_subnet_group_name = try(coalesce(var.db_subnet_group_name, var.name), "")
db_subnet_group_name = var.create_db_subnet_group ? try(aws_db_subnet_group.this[0].name, null) : local.internal_db_subnet_group_name

security_group_name = try(coalesce(var.security_group_name, var.name), "")

cluster_parameter_group_name = try(coalesce(var.db_cluster_parameter_group_name, var.name), null)
db_parameter_group_name = try(coalesce(var.db_parameter_group_name, var.name), null)

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

name = var.security_group_use_name_prefix ? null : var.name
name_prefix = var.security_group_use_name_prefix ? "${var.name}-" : null
name = var.security_group_use_name_prefix ? null : local.security_group_name
name_prefix = var.security_group_use_name_prefix ? "${local.security_group_name}-" : null
vpc_id = var.vpc_id
description = coalesce(var.security_group_description, "Control traffic to/from RDS Aurora ${var.name}")

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ variable "create_security_group" {
default = true
}

variable "security_group_name" {
description = "The security group name. Default value is (`var.name`)"
type = string
default = ""
}

variable "security_group_use_name_prefix" {
description = "Determines whether the security group name (`var.name`) is used as a prefix"
type = bool
Expand Down

0 comments on commit 67edcaa

Please sign in to comment.