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

Chore/revert engine info data #41

Merged
merged 3 commits into from
Dec 13, 2023
Merged
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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Terraform module for AWS RDS instances
|------|------|
| [null_resource.validate_instance_type_proxy](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [random_id.snapshot_identifier](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |
| [aws_rds_engine_version.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/rds_engine_version) | data source |
| [aws_rds_engine_version.engine_info](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/rds_engine_version) | data source |

## Inputs

Expand Down
4 changes: 2 additions & 2 deletions data.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data "aws_rds_engine_version" "default" {
data "aws_rds_engine_version" "engine_info" { # preferred vesion.
engine = local.engine
version = var.engine_version
default_only = var.engine_version != null ? false : true
default_only = !local.is_major_engine_version || var.engine_version == null
}
8 changes: 5 additions & 3 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ locals {
# Parameter group
########################################################################
create_db_parameter_group = true
parameter_group_family = data.aws_rds_engine_version.default.parameter_group_family
parameter_group_family = data.aws_rds_engine_version.engine_info.parameter_group_family

instance_parameters = concat([
{
Expand Down Expand Up @@ -84,10 +84,12 @@ locals {
performance_insights_enabled = false,
performance_insights_retention_period = null,
delete_automated_backups = true
}
}
}

engine_version = var.engine_version != null ? var.engine_version : floor(data.aws_rds_engine_version.default.version)
# engine_version = var.engine_version != null ? var.engine_version : floor(data.aws_rds_engine_version.default.version)
engine_version = data.aws_rds_engine_version.engine_info.version
is_major_engine_version = try(length(regexall("\\.[0-9]+$", var.engine_version)) > 0, true) # For example, 15 is a major version, but 15.5 is not
environment = var.environment == "prod" ? var.environment : "non-prod"
default_config = local.config[local.environment]
instance_class = var.instance_class != "" ? var.instance_class : local.default_config.instance_class
Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ output "iam_instance_profile_for_ec2" {

output "instance_engine_info" {
description = "The engine info for the selected engine of the RDS instance"
value = jsonencode(data.aws_rds_engine_version.default)
value = jsonencode(data.aws_rds_engine_version.engine_info)
}
7 changes: 4 additions & 3 deletions tests/instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ module "rds_instance_test" {
subnet_ids = concat(module.vpc.public_subnets)
enabled_cloudwatch_logs_exports = ["upgrade", "postgresql"]
cloudwatch_log_group_retention_in_days = 1
include_proxy = true
include_proxy = false
proxy_debug_logging = true
enhanced_monitoring_interval = 0
allow_major_version_upgrade = true
engine_version = "15.4"
performance_insights_enabled = true
# engine_version = "15.4"
performance_insights_enabled = true

# Group variables into maps
vpc_id = module.vpc.vpc_id
Expand All @@ -60,6 +60,7 @@ module "rds_instance_test" {
},
]
}
environment = "dev"
}

################################################################################
Expand Down