-
Notifications
You must be signed in to change notification settings - Fork 108
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
Update deployment templates for Aurora Serverless v2 #3623
Changes from all commits
f3c05e9
64639c7
6bea497
3be0a8a
e669cdd
fddeec5
2b0ef7c
16254be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
prefix = "prefix" | ||
db_admin_username = "changethisuser" | ||
db_admin_password = "changethispassword" | ||
region = "us-east-1" | ||
vpc_id = "vpc_id" | ||
subnets = ["subnet-some-subnet-1", "subnet-some-subnet-in-another-az-2"] | ||
deletion_protection = false | ||
cluster_identifier = "some_cluster" | ||
tags = { "Deployment" = "some_deployment_identifier" } | ||
prefix = "prefix" | ||
db_admin_username = "changethisuser" | ||
db_admin_password = "changethispassword" | ||
region = "us-east-1" | ||
vpc_id = "vpc_id" | ||
subnets = ["subnet-some-subnet-1", "subnet-some-subnet-in-another-az-2"] | ||
deletion_protection = false | ||
cluster_identifier = "some_cluster" | ||
cluster_instance_count = 1 | ||
tags = { "Deployment" = "some_deployment_identifier" } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ resource "aws_secretsmanager_secret_version" "rds_login" { | |
database = "postgres" | ||
engine = "postgres" | ||
host = aws_rds_cluster.cumulus.endpoint | ||
hostReader = aws_rds_cluster.cumulus.reader_endpoint | ||
port = 5432 | ||
dbClusterIdentifier = aws_rds_cluster.cumulus.id | ||
}) | ||
|
@@ -52,21 +53,6 @@ resource "aws_security_group_rule" "rds_security_group_allow_postgres" { | |
self = true | ||
} | ||
|
||
resource "aws_rds_cluster_parameter_group" "rds_cluster_group" { | ||
count = var.enable_upgrade ? 0 : 1 | ||
name = "${var.prefix}-cluster-parameter-group" | ||
family = var.parameter_group_family | ||
|
||
dynamic "parameter" { | ||
for_each = var.db_parameters | ||
content { | ||
apply_method = parameter.value["apply_method"] | ||
name = parameter.value["name"] | ||
value = parameter.value["value"] | ||
} | ||
} | ||
} | ||
|
||
resource "aws_rds_cluster_parameter_group" "rds_cluster_group_v13" { | ||
name = "${var.prefix}-cluster-parameter-group-v13" | ||
family = var.parameter_group_family_v13 | ||
|
@@ -82,9 +68,9 @@ resource "aws_rds_cluster_parameter_group" "rds_cluster_group_v13" { | |
} | ||
|
||
resource "aws_rds_cluster" "cumulus" { | ||
depends_on = [aws_db_subnet_group.default, aws_rds_cluster_parameter_group.rds_cluster_group] | ||
depends_on = [aws_db_subnet_group.default, aws_rds_cluster_parameter_group.rds_cluster_group_v13] | ||
cluster_identifier = var.cluster_identifier | ||
engine_mode = "serverless" | ||
engine_mode = "provisioned" | ||
npauzenga marked this conversation as resolved.
Show resolved
Hide resolved
|
||
engine = "aurora-postgresql" | ||
engine_version = var.engine_version | ||
database_name = "postgres" | ||
|
@@ -94,21 +80,35 @@ resource "aws_rds_cluster" "cumulus" { | |
preferred_backup_window = var.backup_window | ||
db_subnet_group_name = aws_db_subnet_group.default.id | ||
apply_immediately = var.apply_immediately | ||
storage_encrypted = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's worth noting - this is required as the default changed from v1 to v2. 👍🏻 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, v2 default is storage_encrypted = false, so we need to add it. |
||
|
||
scaling_configuration { | ||
serverlessv2_scaling_configuration { | ||
npauzenga marked this conversation as resolved.
Show resolved
Hide resolved
|
||
max_capacity = var.max_capacity | ||
min_capacity = var.min_capacity | ||
timeout_action = var.rds_scaling_timeout_action | ||
} | ||
vpc_security_group_ids = [aws_security_group.rds_cluster_access.id] | ||
deletion_protection = var.deletion_protection | ||
enable_http_endpoint = true | ||
tags = var.tags | ||
final_snapshot_identifier = "${var.cluster_identifier}-final-snapshot" | ||
snapshot_identifier = var.snapshot_identifier | ||
db_cluster_parameter_group_name = var.enable_upgrade ? aws_rds_cluster_parameter_group.rds_cluster_group_v13.id : aws_rds_cluster_parameter_group.rds_cluster_group[0].id | ||
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.rds_cluster_group_v13.id | ||
|
||
lifecycle { | ||
ignore_changes = [engine_version] | ||
prevent_destroy = true | ||
} | ||
} | ||
|
||
resource "aws_rds_cluster_instance" "cumulus" { | ||
cluster_identifier = aws_rds_cluster.cumulus.id | ||
identifier = "${aws_rds_cluster.cumulus.id}-instance-${count.index+1}" | ||
count = var.cluster_instance_count | ||
instance_class = "db.serverless" | ||
engine = aws_rds_cluster.cumulus.engine | ||
engine_version = aws_rds_cluster.cumulus.engine_version | ||
|
||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well add this output now, we know we'll need it soon.