Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fake #563

Closed
wants to merge 6 commits into from
Closed

Fake #563

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ No provider.
| timeouts | (Optional) Updated Terraform resource management timeouts. Applies to `aws_db_instance` in particular to permit resource management times | `map(string)` | <pre>{<br> "create": "40m",<br> "delete": "40m",<br> "update": "80m"<br>}</pre> | no |
| timezone | (Optional) Time zone of the DB instance. timezone is currently only supported by Microsoft SQL Server. The timezone can only be set on creation. See MSSQL User Guide for more information. | `string` | `""` | no |
| use\_parameter\_group\_name\_prefix | Whether to use the parameter group name prefix or not | `bool` | `true` | no |
| use\_option\_group\_name\_prefix | Whether to use the option group name prefix or not | `bool` | `true` | no |
| use\_subnet\_group\_name\_prefix | Whether to use the subnet group name prefix or not | `bool` | `true` | no |
| username | Username for the master DB user | `string` | n/a | yes |
| vpc\_security\_group\_ids | List of VPC security groups to associate | `list(string)` | `[]` | no |

Expand Down
1 change: 1 addition & 0 deletions file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
asdfjasdñfljasdj
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module "db_subnet_group" {
create = local.enable_create_db_subnet_group
identifier = var.identifier
name_prefix = "${var.identifier}-"
use_name_prefix = var.use_subnet_group_name_prefix
subnet_ids = var.subnet_ids

tags = var.tags
}

Expand All @@ -42,6 +42,7 @@ module "db_option_group" {
create = local.enable_create_db_option_group
identifier = var.identifier
name_prefix = "${var.identifier}-"
use_name_prefix = var.use_option_group_name_prefix
option_group_description = var.option_group_description
engine_name = var.engine
major_engine_version = var.major_engine_version
Expand Down
45 changes: 43 additions & 2 deletions modules/db_option_group/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
resource "aws_db_option_group" "this_no_prefix" {
count = var.create && false == var.use_name_prefix ? 1 : 0

option_group_description = var.option_group_description == "" ? format("Option group for %s", var.identifier) : var.option_group_description
engine_name = var.engine_name
major_engine_version = var.major_engine_version

dynamic "option" {
for_each = var.options
content {
option_name = option.value.option_name
port = lookup(option.value, "port", null)
version = lookup(option.value, "version", null)
db_security_group_memberships = lookup(option.value, "db_security_group_memberships", null)
vpc_security_group_memberships = lookup(option.value, "vpc_security_group_memberships", null)

dynamic "option_settings" {
for_each = lookup(option.value, "option_settings", [])
content {
name = lookup(option_settings.value, "name", null)
value = lookup(option_settings.value, "value", null)
}
}
}
}

tags = merge(
var.tags,
{
"Name" = format("%s", var.identifier)
},
)

timeouts {
delete = lookup(var.timeouts, "delete", null)
}

lifecycle {
create_before_destroy = true
}
}

resource "aws_db_option_group" "this" {
count = var.create ? 1 : 0
count = var.create && var.use_name_prefix ? 1 : 0

name_prefix = var.name_prefix
option_group_description = var.option_group_description == "" ? format("Option group for %s", var.identifier) : var.option_group_description
Expand Down Expand Up @@ -40,4 +82,3 @@ resource "aws_db_option_group" "this" {
create_before_destroy = true
}
}

4 changes: 2 additions & 2 deletions modules/db_option_group/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
output "this_db_option_group_id" {
description = "The db option group id"
value = element(concat(aws_db_option_group.this.*.id, [""]), 0)
value = element(concat(aws_db_option_group.this.*.id, aws_db_option_group.this_no_prefix.*.id, [""]), 0)
}

output "this_db_option_group_arn" {
description = "The ARN of the db option group"
value = element(concat(aws_db_option_group.this.*.arn, [""]), 0)
value = element(concat(aws_db_option_group.this.*.arn, aws_db_option_group.this_no_prefix.*.arn, [""]), 0)
}

6 changes: 6 additions & 0 deletions modules/db_option_group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ variable "name_prefix" {
type = string
}

variable "use_name_prefix" {
description = "Whether to use name_prefix or not"
type = bool
default = true
}

variable "identifier" {
description = "The identifier of the resource"
type = string
Expand Down
20 changes: 11 additions & 9 deletions modules/db_subnet_group/main.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
resource "aws_db_subnet_group" "this" {
count = var.create ? 1 : 0
resource "aws_db_subnet_group" "this_no_prefix" {
count = var.create && false == var.use_name_prefix ? 1 : 0
name = var.identifier
description = "Database subnet group for ${var.identifier}"
subnet_ids = var.subnet_ids
tags = var.tags
}

resource "aws_db_subnet_group" "this" {
count = var.create && var.use_name_prefix ? 1 : 0
name = var.identifier
name_prefix = var.name_prefix
description = "Database subnet group for ${var.identifier}"
subnet_ids = var.subnet_ids

tags = merge(
var.tags,
{
"Name" = format("%s", var.identifier)
},
)
tags = var.tags
}

4 changes: 2 additions & 2 deletions modules/db_subnet_group/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
output "this_db_subnet_group_id" {
description = "The db subnet group name"
value = element(concat(aws_db_subnet_group.this.*.id, [""]), 0)
value = element(concat(aws_db_subnet_group.this.*.id, aws_db_subnet_group.this_no_prefix.*.id, [""]), 0)
}

output "this_db_subnet_group_arn" {
description = "The ARN of the db subnet group"
value = element(concat(aws_db_subnet_group.this.*.arn, [""]), 0)
value = element(concat(aws_db_subnet_group.this.*.arn, aws_db_subnet_group.this_no_prefix.*.arn, [""]), 0)
}

6 changes: 6 additions & 0 deletions modules/db_subnet_group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ variable "name_prefix" {
type = string
}

variable "use_name_prefix" {
description = "Whether to use name_prefix or not"
type = bool
default = true
}

variable "identifier" {
description = "The identifier of the resource"
type = string
Expand Down
11 changes: 10 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,16 @@ variable "use_parameter_group_name_prefix" {
type = bool
default = true
}

variable "use_option_group_name_prefix" {
description = "Whether to use the option group name prefix or not"
type = bool
default = true
}
variable "use_subnet_group_name_prefix" {
description = "Whether to use the subnet group name prefix or not"
type = bool
default = true
}
variable "performance_insights_enabled" {
description = "Specifies whether Performance Insights are enabled"
type = bool
Expand Down
Loading