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

Fix connections to PostgreSQL 15 and later #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ locals {
module.metaflow-common.default_ui_static_container_image :
var.ui_static_container_image
)

# RDS PostgreSQL >= 15 requires SSL by default
# https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Concepts.General.SSL.html#PostgreSQL.Concepts.General.SSL.Requiring
database_ssl_mode = tonumber(split(".", var.db_engine_version)[0]) >= 15 ? "require" : "disable"
}
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module "metaflow-metadata-service" {
database_name = module.metaflow-datastore.database_name
database_password = module.metaflow-datastore.database_password
database_username = module.metaflow-datastore.database_username
database_ssl_mode = local.database_ssl_mode
db_migrate_lambda_zip_file = var.db_migrate_lambda_zip_file
datastore_s3_bucket_kms_key_arn = module.metaflow-datastore.datastore_s3_bucket_kms_key_arn
enable_api_basic_auth = var.metadata_service_enable_api_basic_auth
Expand Down
3 changes: 2 additions & 1 deletion modules/metadata-service/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ resource "aws_ecs_task_definition" "this" {
{"name": "MF_METADATA_DB_NAME", "value": "${var.database_name}"},
{"name": "MF_METADATA_DB_PORT", "value": "5432"},
{"name": "MF_METADATA_DB_PSWD", "value": "${var.database_password}"},
{"name": "MF_METADATA_DB_USER", "value": "${var.database_username}"}
{"name": "MF_METADATA_DB_USER", "value": "${var.database_username}"},
{"name": "MF_METADATA_DB_SSL_MODE", "value": "${var.database_ssl_mode}"}
],
"logConfiguration": {
"logDriver": "awslogs",
Expand Down
12 changes: 12 additions & 0 deletions modules/metadata-service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ variable "database_username" {
description = "The database username"
}

variable "database_ssl_mode" {
type = string
description = "The metadata service database connection ssl mode"
default = "disable"

# https://github.com/Netflix/metaflow-service/blob/master/run_goose.py#L63
validation {
condition = contains(["disable", "allow", "prefer", "require", "verify-ca", "verify-full"], var.database_ssl_mode)
error_message = "The database_ssl_mode variable is invalid."
}
}

variable "datastore_s3_bucket_kms_key_arn" {
type = string
description = "The ARN of the KMS key used to encrypt the Metaflow datastore S3 bucket"
Expand Down