aws / aws/aws-cdk

(aws-rds): Improve Aurora Serverless Version Support With DatabaseClusterEngine (For ParameterGroup)

Open
#14,031 6 comments 9 reactions 0 assignees View on GitHub
@aws-cdk/aws-rds effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

See #13936 for additional context.

The [CDK docs](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-rds.DatabaseClusterEngine.html) strongly recommend that you use a versioned engine when using non-serverless clusters, but are not as specific if you are using serverless clusters. So, I can create a ServerlessCluster using something like the following without issue:

```python
cluster = rds.ServerlessCluster(
self,
"Database",
engine=rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
vpc=database_stack_props["vpc"],
backup_retention=cdk.Duration.days(7),
default_database_name="postgres",
deletion_protection=False,
enable_data_api=True,
parameter_group=rds.ParameterGroup.from_parameter_group_name(
self, "ParameterGroup", "default.aurora-postgresql10"
),
removal_policy=cdk.RemovalPolicy.SNAPSHOT,
storage_encryption_key=kms_key,
vpc_subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType.ISOLATED),
)
```

However, if you wish to create a parameter group for your serverless cluster and modify some of the default settings, you cannot use `from_parameter_group_name` since the imported resource is not able to be mutated (and therefore rds.force_ssl wont show up in your cdk synth output). So the following won't work:

```python
parameter_group = rds.ParameterGroup.from_parameter_group_name(
self, "ParameterGroup", "default.aurora-postgresql10"
)
parameter_group.add_parameter("rds.force_ssl", "1")
```

Additionally, you cannot use an unversioned engine as you will get an error: `jsii.errors.JSIIError: ParameterGroup cannot be used with an engine that doesn't specify a version`. So the following also won't work:
```python
parameter_group = rds.ParameterGroup(
self,
f"{construct_id}-ParameterGroup",
engine=rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
parameters={
"rds.force_ssl": "1"
}
)
```

The **only** way I was able to create a parameter group for a serverless cluster is by using a specific named version:
```python
parameter_group = rds.ParameterGroup(
self,
"ParameterGroup",
engine=rds.DatabaseClusterEngine.aurora_postgres(
version=rds.AuroraPostgresEngineVersion.VER_10_14
),
parameters={
"rds.force_ssl": "1"
}
)
````

So, I am in a weird situation where my parameter group **MUST** be a named version, but my cluster doesn't. To keep things consistent, I should be using the same version for my ParameterGroup as my ServerlessCluster.

With Aurora Serverless v1, generally there is only a single version or two that is supported (per [AWS docs](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.relnotes.html)). For example, Aurora PostgreSQL Serverless v1 currently (as of the time of creating this issue) supports `10.12` only. Additionally, if AWS rolls out new version support, it upgrades any existing serverless clusters to that new version.

So, at the core of my problem:

1. If I don't set a specific ServerlessCluster version, I can't make a custom parameter group
2. If I set a specific ServerlessCluster version and Amazon bumps the supported version, my next cdk deploy could fail without any code changes

### Proposed Solution(s)

1. Create new default serverless parametergroups for Serverless (so instead of `default.aurora-postgresql10`, I can use `default.aurora-postgresql-serverless`. Note this may be something beyond CDK, or there may need to be some 🧙 magic 🧙 that maps `aurora-postgresql-serverless` to the latest supported parameter group version of Serverless (`default.aurora-postgresql10`)
2. Allow `rds.ParameterGroup.from_parameter_group_name` to be mutated, or create a new convenience method, such as `create_from_parameter_group_name`

Or...

1. Add more enums to [DatabaseClusterEngine](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-rds.DatabaseClusterEngine.html) or the underlying props classes like [AuroraPostgresEngineVersion](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-rds.AuroraPostgresEngineVersion.html) that tracks/follows the version that AWS has for serverless (so if I create my database and the enum resolved to`10.12`, and they upgrade me from `10.12` to `10.14`, the enum then resolves to `10.14`).

Or...

Other ideas?

### Other

* [ ] :wave: I may be able to implement this feature request
* [ ] :warning: This feature might incur a breaking change

---

This is a :rocket: Feature Request

Contributor guide

Open the contributing guide

Research direction

Start with DatabaseClusterEngine, AuroraPostgresEngineVersion, ServerlessCluster, and ParameterGroup.from_parameter_group_name in the CDK RDS implementation and API docs. Reproduce the serverless parameter-group examples, then determine which proposed behavior is compatible with AWS version support. Done means a documented, tested way to customize a serverless parameter group without pinning an unstable engine version.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, postgresql, typescript
Domain
cloud, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.