Closed schwjustin closed 2 months ago
@schwjustin Hi, what is Resource variable in this line tableName: Resource.RateLimiterTable.name,
?
What is Resource.RateLimiterTable.name
value?
@animir sorry for the delay, I'm using sst ion and I can reference my aws (or other) resources through import { Resource } from "sst"
. This is my dynamo table:
const rateLimiterTable = new sst.aws.Dynamo("RateLimiterTable", {
fields: {
key: "string",
},
primaryIndex: { hashKey: "key" },
transform: {
table: (args) => {
args.billingMode = "PAY_PER_REQUEST";
},
},
});
@animir Resource.RateLimiterTable.name prints: sst-justinschwartz-RateLimiterTableTable
This is what I see in the aws console
@schwjustin If you have that table created already, could you try setting tableCreated
option to true
when you create a limiter? This is the option description https://github.com/animir/node-rate-limiter-flexible/wiki/Options#tablecreated
That limiter options would be:
{
tableName: Resource.RateLimiterTable.name,
tableCreated: true,
points: options.endpointLimits.perSecond || DEFAULT_RATE_LIMITS.IP_PER_SECOND,
duration: 1,
storeClient: dynamoClient,
}
That worked!
In my SST Ion project (SST Ion uses Pulumi) I am building an API with API Gateway v2, Lambda functions, and DynamoDB. I implemented the following code for rate-limiter-flexible but I keep getting
Error: Table is not created yet
when the table is for sure already created and accessible in the AWS console:At some point I got a different error
Error Cannot describe time to live while table is in CREATING state: Current table state is CREATING