Ross Coundon
04/19/2021, 9:55 PMnew PolicyStatement({
actions: ['dynamodb:*'],
effect: Effect.ALLOW,
resources: [
'arn:aws:dynamodb:eu-west-2:12345667889:table/mytable/*',
'arn:aws:dynamodb:eu-west-2:12345667889:table/mytable',
],
});
I’m still getting an error about not having the permission to PutItem so I wanted to try adding consumers to a table construct instead but I don’t quite understand the sample.
From the doc here it shows:
import { Table } from "@aws-cdk/aws-dynamodb";
new Table(this, "Table", {
dynamodbTable: Table.fromTableArn(stack, "MyDynamoDBTable", tableArn),
});
Is this something i need to do from within my SST stack? If so, what is stack
referencing?Frank
Ross Coundon
04/19/2021, 10:06 PMRoss Coundon
04/19/2021, 10:08 PMFrank
import dynamodb from "@aws-cdk/aws-dynamodb";
const existingTable = dynamodb.Table.fromTableArn(this, "ImportedTable", tableArn);
const table = new sst.Table(this, "MyTable", {
dynamodbTable: existingTable,
});
You can grant the permission like this:
const fn = new sst.Function(this, "MyFunction", ...);
fn.attachPermissions([table]);
And similarly u can grant the permission to all function in an api like this:
const api = new sst.ApiGatewayV1Api(this, "MyApi", ...);
api.attachPermissions([table]);
Ross Coundon
04/19/2021, 10:18 PMFrank
stack
comes from..Frank
Ross Coundon
04/19/2021, 10:21 PMFrank