Skip to content

Commit

Permalink
feat(dynamodb): get table connection with read write permissions (#241)
Browse files Browse the repository at this point in the history
Useful when accessing the table using native clients
  • Loading branch information
eladcon authored May 19, 2024
1 parent e0acf87 commit c0cd325
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions dynamodb/dynamodb-types.w
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,5 @@ pub inflight interface IClient {

pub interface ITable extends IClient {
setStreamConsumer(handler: inflight (StreamRecord): void, options: StreamConsumerOptions?): void;
inflight readWriteConnection(): Connection;
}
4 changes: 4 additions & 0 deletions dynamodb/dynamodb.sim.w
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,8 @@ pub class Table_sim impl dynamodb_types.ITable {
pub inflight query(options: dynamodb_types.QueryOptions): dynamodb_types.QueryOutput {
return this.client.query(options);
}

pub inflight readWriteConnection(): dynamodb_types.Connection {
return this.connection;
}
}
9 changes: 9 additions & 0 deletions dynamodb/dynamodb.tf-aws.w
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ pub class Table_tfaws impl dynamodb_types.ITable {
"dynamodb:GetItem",
);
}
if ops.contains("readWriteConnection") {
actions.push(
"dynamodb:*",
);
}
if ops.length > 0 {
lambda.addPolicyStatements({
actions: actions.copy(),
Expand Down Expand Up @@ -190,4 +195,8 @@ pub class Table_tfaws impl dynamodb_types.ITable {
pub inflight query(options: dynamodb_types.QueryOptions): dynamodb_types.QueryOutput {
return this.client.query(options);
}

pub inflight readWriteConnection(): dynamodb_types.Connection {
return this.connection;
}
}
4 changes: 4 additions & 0 deletions dynamodb/dynamodb.w
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,9 @@ pub class Table impl dynamodb_types.ITable {
pub inflight query(options: dynamodb_types.QueryOptions): dynamodb_types.QueryOutput {
return this.implementation.query(options);
}

pub inflight readWriteConnection(): dynamodb_types.Connection {
return this.implementation.readWriteConnection();
}
}

4 changes: 2 additions & 2 deletions dynamodb/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dynamodb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@winglibs/dynamodb",
"version": "0.1.8",
"version": "0.1.9",
"description": "DynamoDB library for Wing",
"author": {
"name": "Cristian Pallarés",
Expand Down

0 comments on commit c0cd325

Please sign in to comment.