Skip to content

Commit

Permalink
feat!: Added support for ServerlessV2 and updated AWS provider to v4.…
Browse files Browse the repository at this point in the history
…12+ (#288)
  • Loading branch information
travis-jorge committed May 2, 2022
1 parent b8a3006 commit 6ca7c70
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.64.0
rev: v1.70.1
hooks:
- id: terraform_fmt
- id: terraform_validate
Expand All @@ -23,7 +23,7 @@ repos:
- '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.2.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Terraform module which creates AWS RDS Aurora resources.
- Autoscaling of read-replicas
- Global cluster
- Enhanced monitoring
- Serverless cluster
- Serverless cluster (v1 and v2)
- Import from S3
- Fine grained control of individual cluster instances
- Custom endpoints
Expand Down Expand Up @@ -211,7 +211,7 @@ module "cluster" {
- [MySQL](https://github.com/terraform-aws-modules/terraform-aws-rds-aurora/tree/master/examples/mysql): A simple MySQL cluster
- [PostgreSQL](https://github.com/terraform-aws-modules/terraform-aws-rds-aurora/tree/master/examples/postgresql): A simple PostgreSQL cluster
- [S3 Import](https://github.com/terraform-aws-modules/terraform-aws-rds-aurora/tree/master/examples/s3_import): A MySQL cluster created from a Percona Xtrabackup stored in S3
- [Serverless](https://github.com/terraform-aws-modules/terraform-aws-rds-aurora/tree/master/examples/serverless): Serverless PostgreSQL and MySQL clusters
- [Serverless](https://github.com/terraform-aws-modules/terraform-aws-rds-aurora/tree/master/examples/serverless): Serverless V1 and V2 (PostgreSQL and MySQL)

## Documentation

Expand All @@ -223,14 +223,14 @@ Terraform documentation is generated automatically using [pre-commit hooks](http
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.63 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.12 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.2 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.63 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.12 |
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.2 |

## Modules
Expand Down Expand Up @@ -339,6 +339,7 @@ No modules.
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | The description of the security group. If value is set to empty string it will contain cluster name in the description | `string` | `null` | no |
| <a name="input_security_group_egress_rules"></a> [security\_group\_egress\_rules](#input\_security\_group\_egress\_rules) | A map of security group egress rule defintions to add to the security group created | `map(any)` | `{}` | no |
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | Additional tags for the security group | `map(string)` | `{}` | no |
| <a name="input_serverlessv2_scaling_configuration"></a> [serverlessv2\_scaling\_configuration](#input\_serverlessv2\_scaling\_configuration) | Map of nested attributes with serverless v2 scaling properties. Only valid when `engine_mode` is set to `provisioned` | `map(string)` | `{}` | no |
| <a name="input_skip_final_snapshot"></a> [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Determines whether a final snapshot is created before the cluster is deleted. If true is specified, no snapshot is created | `bool` | `null` | no |
| <a name="input_snapshot_identifier"></a> [snapshot\_identifier](#input\_snapshot\_identifier) | Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot | `string` | `null` | no |
| <a name="input_source_region"></a> [source\_region](#input\_source\_region) | The source region for an encrypted replica DB cluster | `string` | `null` | no |
Expand Down
2 changes: 1 addition & 1 deletion examples/s3_import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Source | Version |
|------|--------|---------|
| <a name="module_aurora"></a> [aurora](#module\_aurora) | ../../ | n/a |
| <a name="module_import_s3_bucket"></a> [import\_s3\_bucket](#module\_import\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 2.0 |
| <a name="module_import_s3_bucket"></a> [import\_s3\_bucket](#module\_import\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 3.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |

## Resources
Expand Down
2 changes: 1 addition & 1 deletion examples/s3_import/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module "vpc" {

module "import_s3_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "~> 2.0"
version = "~> 3.0"

bucket = "${local.name}-${random_pet.this.id}"
acl = "private"
Expand Down
30 changes: 27 additions & 3 deletions examples/serverless/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Serverless Example

Configuration in this directory creates Aurora serverless clusters for both PostgreSQL and MySQL.
Configuration in this directory creates Aurora serverless clusters for both Serverless V1 (PostgreSQL, MySQL), and Serverless V2 (PostgreSQL).

## Usage

Expand All @@ -20,20 +20,21 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.63 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.12.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.63 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.12.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_aurora_mysql"></a> [aurora\_mysql](#module\_aurora\_mysql) | ../../ | n/a |
| <a name="module_aurora_postgresql"></a> [aurora\_postgresql](#module\_aurora\_postgresql) | ../../ | n/a |
| <a name="module_aurora_postgresql_serverlessv2"></a> [aurora\_postgresql\_serverlessv2](#module\_aurora\_postgresql\_serverlessv2) | ../../ | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |

## Resources
Expand All @@ -42,8 +43,11 @@ Note that this example may create resources which cost money. Run `terraform des
|------|------|
| [aws_db_parameter_group.example_mysql](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_parameter_group) | resource |
| [aws_db_parameter_group.example_postgresql](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_parameter_group) | resource |
| [aws_db_parameter_group.example_postgresql13](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_parameter_group) | resource |
| [aws_rds_cluster_parameter_group.example_mysql](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_parameter_group) | resource |
| [aws_rds_cluster_parameter_group.example_postgresql](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_parameter_group) | resource |
| [aws_rds_cluster_parameter_group.example_postgresql13](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/rds_cluster_parameter_group) | resource |
| [aws_rds_engine_version.postgresql](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/rds_engine_version) | data source |

## Inputs

Expand All @@ -53,6 +57,26 @@ No inputs.

| Name | Description |
|------|-------------|
| <a name="output_aurora_postgresql_serverlessv2_additional_cluster_endpoints"></a> [aurora\_postgresql\_serverlessv2\_additional\_cluster\_endpoints](#output\_aurora\_postgresql\_serverlessv2\_additional\_cluster\_endpoints) | A map of additional cluster endpoints and their attributes |
| <a name="output_aurora_postgresql_serverlessv2_cluster_arn"></a> [aurora\_postgresql\_serverlessv2\_cluster\_arn](#output\_aurora\_postgresql\_serverlessv2\_cluster\_arn) | Amazon Resource Name (ARN) of cluster |
| <a name="output_aurora_postgresql_serverlessv2_cluster_database_name"></a> [aurora\_postgresql\_serverlessv2\_cluster\_database\_name](#output\_aurora\_postgresql\_serverlessv2\_cluster\_database\_name) | Name for an automatically created database on cluster creation |
| <a name="output_aurora_postgresql_serverlessv2_cluster_endpoint"></a> [aurora\_postgresql\_serverlessv2\_cluster\_endpoint](#output\_aurora\_postgresql\_serverlessv2\_cluster\_endpoint) | Writer endpoint for the cluster |
| <a name="output_aurora_postgresql_serverlessv2_cluster_engine_version_actual"></a> [aurora\_postgresql\_serverlessv2\_cluster\_engine\_version\_actual](#output\_aurora\_postgresql\_serverlessv2\_cluster\_engine\_version\_actual) | The running version of the cluster database |
| <a name="output_aurora_postgresql_serverlessv2_cluster_hosted_zone_id"></a> [aurora\_postgresql\_serverlessv2\_cluster\_hosted\_zone\_id](#output\_aurora\_postgresql\_serverlessv2\_cluster\_hosted\_zone\_id) | The Route53 Hosted Zone ID of the endpoint |
| <a name="output_aurora_postgresql_serverlessv2_cluster_id"></a> [aurora\_postgresql\_serverlessv2\_cluster\_id](#output\_aurora\_postgresql\_serverlessv2\_cluster\_id) | The RDS Cluster Identifier |
| <a name="output_aurora_postgresql_serverlessv2_cluster_instances"></a> [aurora\_postgresql\_serverlessv2\_cluster\_instances](#output\_aurora\_postgresql\_serverlessv2\_cluster\_instances) | A map of cluster instances and their attributes |
| <a name="output_aurora_postgresql_serverlessv2_cluster_master_password"></a> [aurora\_postgresql\_serverlessv2\_cluster\_master\_password](#output\_aurora\_postgresql\_serverlessv2\_cluster\_master\_password) | The database master password |
| <a name="output_aurora_postgresql_serverlessv2_cluster_master_username"></a> [aurora\_postgresql\_serverlessv2\_cluster\_master\_username](#output\_aurora\_postgresql\_serverlessv2\_cluster\_master\_username) | The database master username |
| <a name="output_aurora_postgresql_serverlessv2_cluster_members"></a> [aurora\_postgresql\_serverlessv2\_cluster\_members](#output\_aurora\_postgresql\_serverlessv2\_cluster\_members) | List of RDS Instances that are a part of this cluster |
| <a name="output_aurora_postgresql_serverlessv2_cluster_port"></a> [aurora\_postgresql\_serverlessv2\_cluster\_port](#output\_aurora\_postgresql\_serverlessv2\_cluster\_port) | The database port |
| <a name="output_aurora_postgresql_serverlessv2_cluster_reader_endpoint"></a> [aurora\_postgresql\_serverlessv2\_cluster\_reader\_endpoint](#output\_aurora\_postgresql\_serverlessv2\_cluster\_reader\_endpoint) | A read-only endpoint for the cluster, automatically load-balanced across replicas |
| <a name="output_aurora_postgresql_serverlessv2_cluster_resource_id"></a> [aurora\_postgresql\_serverlessv2\_cluster\_resource\_id](#output\_aurora\_postgresql\_serverlessv2\_cluster\_resource\_id) | The RDS Cluster Resource ID |
| <a name="output_aurora_postgresql_serverlessv2_cluster_role_associations"></a> [aurora\_postgresql\_serverlessv2\_cluster\_role\_associations](#output\_aurora\_postgresql\_serverlessv2\_cluster\_role\_associations) | A map of IAM roles associated with the cluster and their attributes |
| <a name="output_aurora_postgresql_serverlessv2_db_subnet_group_name"></a> [aurora\_postgresql\_serverlessv2\_db\_subnet\_group\_name](#output\_aurora\_postgresql\_serverlessv2\_db\_subnet\_group\_name) | The db subnet group name |
| <a name="output_aurora_postgresql_serverlessv2_enhanced_monitoring_iam_role_arn"></a> [aurora\_postgresql\_serverlessv2\_enhanced\_monitoring\_iam\_role\_arn](#output\_aurora\_postgresql\_serverlessv2\_enhanced\_monitoring\_iam\_role\_arn) | The Amazon Resource Name (ARN) specifying the enhanced monitoring role |
| <a name="output_aurora_postgresql_serverlessv2_enhanced_monitoring_iam_role_name"></a> [aurora\_postgresql\_serverlessv2\_enhanced\_monitoring\_iam\_role\_name](#output\_aurora\_postgresql\_serverlessv2\_enhanced\_monitoring\_iam\_role\_name) | The name of the enhanced monitoring role |
| <a name="output_aurora_postgresql_serverlessv2_enhanced_monitoring_iam_role_unique_id"></a> [aurora\_postgresql\_serverlessv2\_enhanced\_monitoring\_iam\_role\_unique\_id](#output\_aurora\_postgresql\_serverlessv2\_enhanced\_monitoring\_iam\_role\_unique\_id) | Stable and unique string identifying the enhanced monitoring role |
| <a name="output_aurora_postgresql_serverlessv2_security_group_id"></a> [aurora\_postgresql\_serverlessv2\_security\_group\_id](#output\_aurora\_postgresql\_serverlessv2\_security\_group\_id) | The security group ID of the cluster |
| <a name="output_mysql_additional_cluster_endpoints"></a> [mysql\_additional\_cluster\_endpoints](#output\_mysql\_additional\_cluster\_endpoints) | A map of additional cluster endpoints and their attributes |
| <a name="output_mysql_cluster_arn"></a> [mysql\_cluster\_arn](#output\_mysql\_cluster\_arn) | Amazon Resource Name (ARN) of cluster |
| <a name="output_mysql_cluster_database_name"></a> [mysql\_cluster\_database\_name](#output\_mysql\_cluster\_database\_name) | Name for an automatically created database on cluster creation |
Expand Down
58 changes: 58 additions & 0 deletions examples/serverless/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module "vpc" {
private_subnets = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"]
database_subnets = ["10.99.7.0/24", "10.99.8.0/24", "10.99.9.0/24"]

enable_nat_gateway = false # Disabled NAT to be able to run this example quicker

tags = local.tags
}

Expand Down Expand Up @@ -127,3 +129,59 @@ resource "aws_rds_cluster_parameter_group" "example_mysql" {
description = "${local.name}-aurora-mysql-cluster-parameter-group"
tags = local.tags
}

################################################################################
# RDS Aurora Module - PostgreSQL Serverless V2
################################################################################

data "aws_rds_engine_version" "postgresql" {
engine = "aurora-postgresql"
version = "13.6"
}

module "aurora_postgresql_serverlessv2" {
source = "../../"
name = "${local.name}-postgresqlv2"
engine = data.aws_rds_engine_version.postgresql.engine
engine_mode = "provisioned"
engine_version = data.aws_rds_engine_version.postgresql.version
storage_encrypted = true

vpc_id = module.vpc.vpc_id
subnets = module.vpc.database_subnets
create_security_group = true
allowed_cidr_blocks = module.vpc.private_subnets_cidr_blocks

monitoring_interval = 60

apply_immediately = true
skip_final_snapshot = true

db_parameter_group_name = aws_db_parameter_group.example_postgresql13.id
db_cluster_parameter_group_name = aws_rds_cluster_parameter_group.example_postgresql13.id

serverlessv2_scaling_configuration = {
min_capacity = 2
max_capacity = 10
}

instance_class = "db.serverless"
instances = {
one = {}
two = {}
}
}

resource "aws_db_parameter_group" "example_postgresql13" {
name = "${local.name}-aurora-db-postgres13-parameter-group"
family = "aurora-postgresql13"
description = "${local.name}-aurora-db-postgres13-parameter-group"
tags = local.tags
}

resource "aws_rds_cluster_parameter_group" "example_postgresql13" {
name = "${local.name}-aurora-postgres13-cluster-parameter-group"
family = "aurora-postgresql13"
description = "${local.name}-aurora-postgres13-cluster-parameter-group"
tags = local.tags
}
Loading

0 comments on commit 6ca7c70

Please sign in to comment.