Skip to content

Commit cd3769c

Browse files
feat: Add serverless functionality (#10)
* fix: update dependencies * feat: Add ServerlessV2 * terraform-docs: automated action --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 2c23fe0 commit cd3769c

File tree

6 files changed

+48
-6
lines changed

6 files changed

+48
-6
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ such as extended backups, user management, and autoscaling.
8181
| <a name="input_enable_enhanced_backups"></a> [enable\_enhanced\_backups](#input\_enable\_enhanced\_backups) | Enable enhanced backups. | `bool` | `true` | no |
8282
| <a name="input_enabled_cloudwatch_logs_exports"></a> [enabled\_cloudwatch\_logs\_exports](#input\_enabled\_cloudwatch\_logs\_exports) | Set of log types to enable for exporting to CloudWatch logs. | `list(string)` | <pre>[<br> "audit",<br> "error",<br> "general",<br> "slowquery"<br>]</pre> | no |
8383
| <a name="input_engine"></a> [engine](#input\_engine) | The engine to use. | `string` | `"aurora-mysql"` | no |
84+
| <a name="input_engine_mode"></a> [engine\_mode](#input\_engine\_mode) | The engine mode to use. | `string` | `"provisioned"` | no |
8485
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | The engine version to use. | `string` | `null` | no |
8586
| <a name="input_instance_class"></a> [instance\_class](#input\_instance\_class) | The instance type of the RDS instance. | `string` | n/a | yes |
8687
| <a name="input_monitoring_interval"></a> [monitoring\_interval](#input\_monitoring\_interval) | The interval, in seconds, between points when Enhanced Monitoring metrics are collected for the DB instance. | `number` | `60` | no |
@@ -89,6 +90,7 @@ such as extended backups, user management, and autoscaling.
8990
| <a name="input_port"></a> [port](#input\_port) | The port on which the DB accepts connections. | `number` | `3306` | no |
9091
| <a name="input_preferred_backup_window"></a> [preferred\_backup\_window](#input\_preferred\_backup\_window) | The daily time range (in UTC) during which automated backups are created if they are enabled. | `string` | `"00:00-02:30"` | no |
9192
| <a name="input_preferred_maintenance_window"></a> [preferred\_maintenance\_window](#input\_preferred\_maintenance\_window) | The weekly time range during which system maintenance can occur, in (UTC). | `string` | `"Mon:03:00-Mon:04:30"` | no |
93+
| <a name="input_serverlessv2_scaling_configuration"></a> [serverlessv2\_scaling\_configuration](#input\_serverlessv2\_scaling\_configuration) | The scaling configuration of the Aurora Serverless DB cluster. | <pre>object({<br> max_capacity = number<br> min_capacity = number<br> })</pre> | <pre>{<br> "max_capacity": null,<br> "min_capacity": null<br>}</pre> | no |
9294
| <a name="input_storage_type"></a> [storage\_type](#input\_storage\_type) | Storage type. | `string` | `"aurora"` | no |
9395
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to add to the AWS RDS Cluster Instance. | `map(any)` | `{}` | no |
9496
| <a name="input_vpc_security_group_ids_rds_cluster"></a> [vpc\_security\_group\_ids\_rds\_cluster](#input\_vpc\_security\_group\_ids\_rds\_cluster) | List of VPC security groups to associate with the RDS Proxy. | `list(string)` | `null` | no |

main.tf

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ module "rds_cluster" {
3131
# How many read replicas to create
3232
additional_reader_capacity = var.additional_reader_capacity
3333

34-
# The engine version to use
34+
# The engine
3535
engine = var.engine
3636
engine_version = var.engine_version
37+
engine_mode = var.engine_mode
3738
database_name = var.database_name
3839

40+
# Serverless
41+
serverlessv2_scaling_configuration = var.serverlessv2_scaling_configuration
42+
3943
# Network
4044
db_subnet_group_name = var.database_subnet_group_name
4145
vpc_security_group_ids = var.vpc_security_group_ids_rds_cluster

modules/rds_cluster/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
| <a name="input_deletion_protection"></a> [deletion\_protection](#input\_deletion\_protection) | If the DB instance should have deletion protection enabled. | `bool` | `false` | no |
2222
| <a name="input_enabled_cloudwatch_logs_exports"></a> [enabled\_cloudwatch\_logs\_exports](#input\_enabled\_cloudwatch\_logs\_exports) | Set of log types to enable for exporting to CloudWatch logs. | `list(string)` | n/a | yes |
2323
| <a name="input_engine"></a> [engine](#input\_engine) | The engine to use. | `string` | `"aurora-mysql"` | no |
24-
| <a name="input_engine_mode"></a> [engine\_mode](#input\_engine\_mode) | The database engine mode. Valid values: global, parallelquery, provisioned, serverless | `string` | `"provisioned"` | no |
24+
| <a name="input_engine_mode"></a> [engine\_mode](#input\_engine\_mode) | The database engine mode. | `string` | n/a | yes |
2525
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | The engine version to use. | `string` | n/a | yes |
2626
| <a name="input_final_snapshot_identifier"></a> [final\_snapshot\_identifier](#input\_final\_snapshot\_identifier) | The name of your final DB snapshot when this DB cluster is deleted. | `string` | `"final-snapshot"` | no |
2727
| <a name="input_iam_database_authentication_enabled"></a> [iam\_database\_authentication\_enabled](#input\_iam\_database\_authentication\_enabled) | Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. | `bool` | `false` | no |
@@ -31,6 +31,7 @@
3131
| <a name="input_preferred_backup_window"></a> [preferred\_backup\_window](#input\_preferred\_backup\_window) | The daily time range (in UTC) during which automated backups are created if they are enabled. | `string` | `"00:00-02:30"` | no |
3232
| <a name="input_preferred_maintenance_window"></a> [preferred\_maintenance\_window](#input\_preferred\_maintenance\_window) | The weekly time range during which system maintenance can occur, in (UTC). | `string` | `"Mon:03:00-Mon:04:30"` | no |
3333
| <a name="input_replication_source_identifier"></a> [replication\_source\_identifier](#input\_replication\_source\_identifier) | ARN of the source DB cluster or DB instance if this DB cluster is created as a Read Replica. | `string` | `null` | no |
34+
| <a name="input_serverlessv2_scaling_configuration"></a> [serverlessv2\_scaling\_configuration](#input\_serverlessv2\_scaling\_configuration) | The scaling configuration of the Aurora Serverless DB cluster. | <pre>object({<br> max_capacity = optional(number)<br> min_capacity = optional(number)<br> })</pre> | n/a | yes |
3435
| <a name="input_skip_final_snapshot"></a> [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB cluster is deleted. | `bool` | `false` | no |
3536
| <a name="input_source_region"></a> [source\_region](#input\_source\_region) | The source region for an encrypted replica DB cluster. | `string` | `null` | no |
3637
| <a name="input_storage_encrypted"></a> [storage\_encrypted](#input\_storage\_encrypted) | Specifies whether the DB cluster is encrypted. | `bool` | `true` | no |
@@ -56,7 +57,7 @@
5657
## Resources
5758

5859
- resource.aws_rds_cluster.main (modules/rds_cluster/main.tf#1)
59-
- resource.random_password.master_password (modules/rds_cluster/main.tf#95)
60-
- resource.random_string.master_username (modules/rds_cluster/main.tf#89)
60+
- resource.random_password.master_password (modules/rds_cluster/main.tf#105)
61+
- resource.random_string.master_username (modules/rds_cluster/main.tf#99)
6162
- data source.aws_availability_zones.available (modules/rds_cluster/data.tf#1)
6263
<!-- END_TF_DOCS -->

modules/rds_cluster/main.tf

+10
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ resource "aws_rds_cluster" "main" {
6363
# Security
6464
deletion_protection = var.deletion_protection
6565

66+
# Serverless
67+
dynamic "serverlessv2_scaling_configuration" {
68+
for_each = var.serverlessv2_scaling_configuration == null ? [] : [1]
69+
content {
70+
max_capacity = var.serverlessv2_scaling_configuration.max_capacity
71+
min_capacity = var.serverlessv2_scaling_configuration.min_capacity
72+
}
73+
}
74+
75+
# Tags
6676
tags = merge(
6777
var.tags,
6878
{

modules/rds_cluster/variables.tf

+9-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ variable "engine" {
100100
}
101101

102102
variable "engine_mode" {
103-
default = "provisioned"
104-
description = "The database engine mode. Valid values: global, parallelquery, provisioned, serverless"
103+
description = "The database engine mode."
105104
type = string
106105
}
107106

@@ -158,6 +157,14 @@ variable "replication_source_identifier" {
158157
type = string
159158
}
160159

160+
variable "serverlessv2_scaling_configuration" {
161+
description = "The scaling configuration of the Aurora Serverless DB cluster."
162+
type = object({
163+
max_capacity = optional(number)
164+
min_capacity = optional(number)
165+
})
166+
}
167+
161168
variable "source_region" {
162169
default = null
163170
description = "The source region for an encrypted replica DB cluster."

variables.tf

+18
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ variable "engine_version" {
108108
type = string
109109
}
110110

111+
variable "engine_mode" {
112+
default = "provisioned"
113+
description = "The engine mode to use."
114+
type = string
115+
}
116+
111117
variable "instance_class" {
112118
description = "The instance type of the RDS instance."
113119
type = string
@@ -193,6 +199,18 @@ variable "port" {
193199
type = number
194200
}
195201

202+
variable "serverlessv2_scaling_configuration" {
203+
default = {
204+
max_capacity = null
205+
min_capacity = null
206+
}
207+
description = "The scaling configuration of the Aurora Serverless DB cluster."
208+
type = object({
209+
max_capacity = number
210+
min_capacity = number
211+
})
212+
}
213+
196214
variable "storage_type" {
197215
default = "aurora"
198216
description = "Storage type."

0 commit comments

Comments
 (0)