-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Aurora Serverless V2 clusters (#23)
* Add support for Aurora Serverless V2 clusters * remove duplicated terraform docs section * Update variables.tf Co-authored-by: Max Williams <8859277+max-rocket-internet@users.noreply.github.com> * Update variables.tf Co-authored-by: Max Williams <8859277+max-rocket-internet@users.noreply.github.com> * remove duplicated terraform docs section --------- Co-authored-by: Max Williams <8859277+max-rocket-internet@users.noreply.github.com>
- Loading branch information
1 parent
47a1b21
commit 8825f3b
Showing
6 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# A simple example | ||
|
||
This example will show the bare minimum parameters to create a Serverless V2 PostgreSQL Aurora cluster. | ||
|
||
In general setup of the PostgreSQL serverless v2 cluster is very similar to creation of a regular PostgreSQL cluster. | ||
The only crucial differences are the following: | ||
* `engine_mode` needs to be specified and set to `provisioned` | ||
* `instance_type` is to be set to `db.serverless` | ||
* Scaling params are to be set in `serverlessv2_min_capacity` and `serverlessv2_max_capacity` params. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
provider "aws" { | ||
region = "eu-west-1" | ||
} | ||
|
||
data "aws_availability_zones" "available" {} | ||
|
||
module "aurora" { | ||
source = "../../" | ||
name = "aurora-example-postgresql" | ||
engine = "aurora-postgresql" | ||
engine_mode = "provisioned" | ||
engine_version = "16.4" | ||
subnet_ids = ["${module.vpc.database_subnets}"] | ||
vpc_id = "${module.vpc.vpc_id}" | ||
replica_count = 1 | ||
instance_type = "db.serverless" | ||
apply_immediately = true | ||
skip_final_snapshot = true | ||
db_parameter_group_name = "${aws_db_parameter_group.aurora_db_postgres164_parameter_group.id}" | ||
db_cluster_parameter_group_name = "${aws_rds_cluster_parameter_group.aurora_cluster_postgres164_parameter_group.id}" | ||
serverlessv2_min_capacity = 0.5 | ||
serverlessv2_max_capacity = 2 | ||
} | ||
|
||
resource "aws_db_parameter_group" "aurora_db_postgres164_parameter_group" { | ||
name = "test-aurora-db-postgres164-parameter-group" | ||
family = "aurora-postgresql16.4" | ||
description = "test-aurora-db-postgres164-parameter-group" | ||
} | ||
|
||
resource "aws_rds_cluster_parameter_group" "aurora_cluster_postgres164_parameter_group" { | ||
name = "test-aurora-postgres164-cluster-parameter-group" | ||
family = "aurora-postgresql16.4" | ||
description = "test-aurora-postgres164-cluster-parameter-group" | ||
} | ||
|
||
resource "aws_security_group" "app_servers" { | ||
name = "app-servers" | ||
description = "For application servers" | ||
vpc_id = "${module.vpc.vpc_id}" | ||
} | ||
|
||
resource "aws_security_group_rule" "allow_access" { | ||
type = "ingress" | ||
from_port = "${module.aurora.cluster_port}" | ||
to_port = "${module.aurora.cluster_port}" | ||
protocol = "tcp" | ||
source_security_group_id = "${aws_security_group.app_servers.id}" | ||
security_group_id = "${module.aurora.security_group_id}" | ||
} | ||
|
||
module "vpc" { | ||
source = "terraform-aws-modules/vpc/aws" | ||
version = "1.46.0" | ||
name = "example-postgres" | ||
cidr = "10.0.0.0/16" | ||
azs = ["${data.aws_availability_zones.available.names}"] | ||
|
||
private_subnets = [ | ||
"10.0.1.0/24", | ||
"10.0.2.0/24", | ||
"10.0.3.0/25", | ||
] | ||
|
||
public_subnets = [ | ||
"10.0.4.0/24", | ||
"10.0.5.0/24", | ||
"10.0.6.0/25", | ||
] | ||
|
||
database_subnets = [ | ||
"10.0.7.0/24", | ||
"10.0.8.0/24", | ||
"10.0.9.0/25", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters