Hello everyone, just discovered SST. absolutely in...
# help
m
Hello everyone, just discovered SST. absolutely in love with it. Just 3 questions • How do I set billing mode for GSI in dynamodb (need to set it as PAY_PER_REQUEST) • Is there a way I can check what will be deployed like CDK diff • how do I export the GSI name as CfnOutput (the operation
addGlobalSecondaryIndex()
returns void and the table doesn't have it either.)
f
Hey @Mr.9715
How do I set billing mode for GSI in dynamodb (need to set it as PAY_PER_REQUEST)
I think GSI inherits the billing model of the table? And by default
sst.Table
has billing mode set to
PAY_PER_REQUEST
Is there a way I can check what will be deployed like CDK diff
Currently no. But if you run
sst build
, you can get the generated CF template inside
.build/cdk.out
. We will probably add a command ie.
sst diff
to simply this.
how do I export the GSI name as CfnOutput
The key for the
secondaryIndexes
field is the index name. You can add it to the stack output like this:
Copy code
new Table(this, "Notes", {
  fields: {
    userId: TableFieldType.STRING,
    noteId: TableFieldType.STRING,
    time: TableFieldType.NUMBER,
  },
  primaryIndex: { partitionKey: "noteId", sortKey: "userId" },
  secondaryIndexes: {
    userTimeIndex: { partitionKey: "userId", sortKey: "time" },
  },
});

this.addOutputs({
  INDEX_NAME: "userTimeIndex",
});
m
Amazing, thank you so much. I am willing to contribute if needed, I can work with Javascript and Python. sst diff will help a lot, thanks.
the logical prefix is extremely useful.
f
Thanks @Mr.9715, I opened an issue for
sst diff
, and drew down some notes on how we could implement the command. SST is written in JS, super welcome to take a crack at it👍