Hi, i define two tables like that, ```const doma...
# help
f
Hi, i define two tables like that,
Copy code
const domainLogsTable = new sst.Table(this, process.env.TABLE_DOMAINLOGS, {
    fields: {
        id: sst.TableFieldType.STRING,
        domainName: sst.TableFieldType.STRING,
        time: sst.TableFieldType.NUMBER
    },
    primaryIndex: {partitionKey: "id"},
    globalIndexes: {
        domainNameIndex: {partitionKey: "domainName", projection: "all", sortKey: "time"}
    },
    dynamodbTable: {
        removalPolicy: RemovalPolicy.DESTROY,
    },
});

const domainTable = new sst.Table(this,process.env.TABLE_DOMAIN, {
   fields: {
       domainName: sst.TableFieldType.STRING
   },
   primaryIndex: {partitionKey: "domainName"}
});

const api = new sst.Api(this, "Api", {
    routes: {
        "GET /": "src/lambda.handler",
    },
    defaultFunctionProps: {
        permissions: [domainTable,domainLogsTable]
    }
});
but i get accessdeniedexception when put item to dynamodb
i
Try this?
Copy code
const api = new sst.Api(this, "Api", {
    routes: {
        "GET /": "src/lambda.handler",
    },
    defaults: {
        function: {
            permissions: [domainTable.table, domainLogsTable.table]                
        }
    }
});
f
not working
I fixed like that, // index.js
Copy code
const storageStack = new StorageStack(app, "storage")

const apiStack = new ApiStack(app, "api-stack", {
    tableDomain: storageStack.tableDomain,
    tableDomainLogs: storageStack.tableDomainLogs
});
//ApiStack.js
Copy code
const {tableDomain, tableDomainLogs} = props;

const api = new sst.Api(this, "Api", {
    routes: {
        "GET /": "get.main"
    },
    defaultFunctionProps: {
        environment: {
            tableDomain: tableDomain.tableName,
            tableDomainLogs: tableDomainLogs.tableName
        }
    }
});