Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new construct AmplifyDatabaseCluster #2969

Open
wants to merge 32 commits into
base: feature/aurora-serverless
Choose a base branch
from

Conversation

dpilch
Copy link
Member

@dpilch dpilch commented Oct 21, 2024

Description of changes

Add new package @aws-amplify/database-construct with new construct AmplifyDatabaseCluster for creating an Aurora database cluster. The final naming and API has not been decided.

AmplifyDatabaseClusterProps
export type AmplifyDatabaseClusterProps = {
  dbType: 'POSTGRES' // `MYSQL` will come later
};
Resources

The resources property will contain the resources created by the L3 construct.

import { ISecret } from 'aws-cdk-lib/secrets-manager';
import { IDatabaseCluster } from 'aws-cdk-lib/rds';

export interface AmplifyDatabaseResources {
    readonly consoleSecret: ISecret;
    readonly dataApiSecret: ISecret;
    readonly databaseCluster: IDatabaseCluster;
}
  • resources.consoleSecret - Secrets manager secret.
  • resources.dataApiSecret - Secrets manager secret.
  • resources.databaseCluster - Aurora cluster.
Datasource Strategy

The datasourceStrategy property will contain the datasource strategy to be passed to the Amplify GraphQL API construct. The datasource strategy is currently using SQLLambdaModelDataSourceStrategy for the PoC, but will change in the future.

Usage
import { AmplifyDatabaseCluster } from '@aws-amplify/database-construct';
import { AmplifyGraphQLAPI } from '@aws-amplify/graphql-api-construct';

const databaseCluster = new AmplifyDatabaseCluster({
  dbType: 'POSTGRES',
});

const dbManager = AmplifyDatabaseManager({
  // will get information needed from databaseCluster.resources
  databaseCluster,
});

// out of scope. but will looks something like this
dbManager.sqlStatment('create Todo table sql statement');

const schema = `
  type Todo @model {
    content: String
  }
`;

new AmplifyGraphQLAPI({
  definition: AmplifyGraphqlDefinition.fromString(
    // graphql schema needs to match databaseCluster sql schema
    // gen 2 will provide compile time type checking
    schema,
    databaseCluster.dataSourceStrategy
  ),
});
CDK / CloudFormation Parameters Changed

See description above. No change to GraphQL API construct yet.

Issue #, if available

N/A

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • E2E test run linked
  • Tests are changed or added

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dpilch dpilch force-pushed the database-construct branch from e170748 to 1d2768e Compare October 22, 2024 16:53
@dpilch dpilch closed this Oct 22, 2024
@dpilch dpilch deleted the database-construct branch October 22, 2024 22:02
@dpilch dpilch restored the database-construct branch October 24, 2024 15:10
@dpilch dpilch reopened this Oct 24, 2024
@dpilch dpilch force-pushed the database-construct branch from 1d2768e to 6b8ddff Compare October 24, 2024 15:34
@dpilch dpilch changed the title Database construct Add new construct AmplifyDatabaseCluster Oct 24, 2024
@dpilch dpilch force-pushed the database-construct branch from d0c0fa9 to 9cc69e3 Compare October 25, 2024 14:44
@dpilch dpilch changed the base branch from main to feature/aurora-serverless October 25, 2024 14:44
@dpilch dpilch marked this pull request as ready for review October 25, 2024 17:36
@dpilch dpilch requested review from a team as code owners October 25, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant