Skip to content

Commit

Permalink
fix permissions?
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriscbr committed Aug 16, 2023
1 parent f39e5c2 commit 0be5983
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions dynamodb.w
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,38 @@ class DynamoDBTable {
}
}

bind(host: std.IInflightHost, ops: Array<str>) {
// currently simulator does not require permissions
// may change with https://github.com/winglang/wing/issues/3082
if let tableAws = this.tableAws {
if let host = aws.Function.from(host) {
if ops.contains("putItem") {
host.addPolicyStatements([aws.PolicyStatement {
actions: ["dynamodb:PutItem"],
resources: [tableAws.table.arn],
effect: aws.Effect.ALLOW,
}]);
}

if ops.contains("getItem") {
host.addPolicyStatements([aws.PolicyStatement {
actions: ["dynamodb:GetItem"],
resources: [tableAws.table.arn],
effect: aws.Effect.ALLOW,
}]);
}

if ops.contains("scan") {
host.addPolicyStatements([aws.PolicyStatement {
actions: ["dynamodb:Scan"],
resources: [tableAws.table.arn],
effect: aws.Effect.ALLOW,
}]);
}
}
}
}

inflight getItem(key: Map<Attribute>): Map<Attribute>? {
assert(key.size() == 1);
if let tableSim = this.tableSim {
Expand Down

0 comments on commit 0be5983

Please sign in to comment.