-
Notifications
You must be signed in to change notification settings - Fork 89
chore: update CDK postgres E2Es to use Data API #2735
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
Conversation
f162a71 to
73e09f1
Compare
packages/amplify-graphql-api-construct-tests/rds-test-config.json
Outdated
Show resolved
Hide resolved
...uct-tests/src/__tests__/relationships/postgres-uuid-pk/uuid-pk-ddbprimary-sqlrelated.test.ts
Outdated
Show resolved
Hide resolved
| const createDBInput: ExecuteStatementCommandInput = { | ||
| resourceArn: dbCluster.clusterArn, | ||
| secretArn, | ||
| sql: `create database ${config.dbname};`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rework this to include dbname as a parameter, to avoid potential SQL injection if dbname is ever compromised. (Plus, it's a good habit to get into to not interpolate into SQL if you can avoid it). In this case, the risk is minimal since we generate the dbname, but if in future we decided "hey, let's let dbname be specified by an environment variable", then we'd be open to executing SQL with untrusted input.
| }, | ||
| }; | ||
|
|
||
| const command = new CreateDBClusterCommand(params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: command is pretty generic, especially since you're issuing multiple commands in the body of this function
| const command = new CreateDBClusterCommand(params); | |
| const createClusterCommand = new CreateDBClusterCommand(params); |
| const instanceCommand = new CreateDBInstanceCommand(instanceParams); | ||
|
|
||
| try { | ||
| const rdsResponse = await rdsClient.send(command); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, rdsResponse is pretty generic. Consider something that more explicitly defines the purpose of the variable
| const rdsResponse = await rdsClient.send(command); | |
| const createClusterResponse = await rdsClient.send(createClusterCommand); |
| database: dbCluster.dbName, | ||
| }; | ||
|
|
||
| const command = new ExecuteStatementCommand(createDBInput); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: as elsewhere, the name is pretty generic
| const command = new ExecuteStatementCommand(createDBInput); | |
| const createDbCommand = new ExecuteStatementCommand(createDBInput); |
| // create the test tables in the test database | ||
| queries?.map(async (query) => { | ||
| try { | ||
| const createTableInput: ExecuteStatementCommandInput = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nit: you don't actually know that the incoming queries are for creating tables -- some may be altering tables, creating indexes, or even updating tables with new records. :) In this case, a more generic name is appropriate.
| const createTableInput: ExecuteStatementCommandInput = { | |
| const executeStatementInput: ExecuteStatementCommandInput = { |
| const createTableResponse = await client.send(new ExecuteStatementCommand(createTableInput)); | ||
| console.log('Create table response: ' + JSON.stringify(createTableResponse)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const createTableResponse = await client.send(new ExecuteStatementCommand(createTableInput)); | |
| console.log('Create table response: ' + JSON.stringify(createTableResponse)); | |
| const executeStatementResponse = await client.send(new ExecuteStatementCommand(createTableInput)); | |
| console.log('executeStatementResponse: ' + JSON.stringify(executeStatementResponse)); |
| MinCapacity: 4, | ||
| MaxCapacity: 10, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is only a test resource, can we lower these values?
Description of changes
CDK / CloudFormation Parameters Changed
Issue #, if available
Description of how you validated changes
Update
sql-models-2test to use postgres and verified it passes.Checklist
yarn testpassesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.