aws-amplify / aws-amplify/amplify-data
Support RDS IAM authentication metadata in configure({ database })
- Dominant language
- TypeScript
- Stars
- 18
- Forks
- 23
- Avg merge
- 26m
- Merged PRs (30d)
- 1
Description
**Is your feature request related to a problem? Please describe.**
Generated SQL schemas currently use `configure({ database })` to store database connection metadata:
```ts
export const schema = configure({
database: {
identifier: "IDYufuVoPi8Po1obyjhhITYQ",
engine: "postgresql",
connectionUri: secret("SQL_CONNECTION_STRING")
}
}).schema({
// models...
});
```
This works for password-based connection URIs such as:
```txt
postgres://user:password@hostname:port/database
```
However, there is currently no explicit way to represent a database connection that uses **RDS IAM database authentication** instead of a static password.
This is needed for use cases such as Aurora PostgreSQL Express configuration, where the connection may rely on IAM auth tokens rather than a password in the connection URI.
**Describe the solution you'd like**
I would like `configure({ database })` to support an optional authentication strategy field.
For example:
```ts
export const schema = configure({
database: {
identifier: "IDYufuVoPi8Po1obyjhhITYQ",
engine: "postgresql",
connectionUri: secret("SQL_CONNECTION_STRING"),
authentication: {
strategy: "rdsIam"
}
}
}).schema({
// models...
});
```
When `authentication` is omitted, the current behavior should remain unchanged and default to password-based authentication.
When `authentication.strategy === "rdsIam"`, downstream packages should be able to understand that:
- the database uses RDS IAM authentication;
- `connectionUri` may omit the password;
- `connectionUri` still provides host, port, database name, and username.
This issue is only about allowing `@aws-amplify/data-schema` to express this metadata. Runtime support, such as generating IAM auth tokens and configuring IAM permissions, would be handled in downstream packages.
**Describe alternatives you've considered**
One alternative is to encode the auth mode in the URI, for example:
```txt
postgres+iam://postgres@hostname:5432/database
```
However, an explicit typed field is clearer and easier for downstream packages (https://github.com/aws-amplify/amplify-category-api) to consume.
Another alternative is to manually edit generated `schema.sql.ts` files, but those files are autogenerated and would be overwritten.
**Additional context**
This is motivated by supporting Aurora PostgreSQL Express configuration and other RDS PostgreSQL setups that use IAM database authentication.
The goal is to extend the existing database metadata shape in a backward-compatible way:
```ts
configure({
database: {
identifier,
engine,
connectionUri,
vpcConfig,
authentication // optional
}
})
```
A companion issue may be needed in `amplify-category-api` or other backend/runtime packages to consume this metadata and implement the actual RDS IAM authentication behavior.
Contributor guide
Research direction
Start at the configure({ database }) type and metadata path in @aws-amplify/data-schema; generated schema.sql.ts files should not be edited. Confirm how database metadata is represented and consumed, then add the optional authentication.strategy value while preserving password-based behavior when it is omitted. Done means downstream packages can distinguish rdsIam and receive the host, port, database name, and username without requiring a password.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, postgresql, typescript
- Domain
- backend-api-design, cloud, databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100