Jon Holman
11/21/2021, 3:11 PMattachPermissions
. This does not work, I get an error `Error: The specified grant method is incorrect.`:
scheduled.attachPermissions([
[topic, "grantPublish"],
[table, "grantReadData"],
]);
but this does work, no errors:
scheduled.attachPermissions([topic, "grantPublish"]);
scheduled.attachPermissions([table, "grantReadData"]);
Can someone explain this to me? I thought both would work.Frank
topic
and table
are instances of sst.Topic
and sst.Table
constructs.Frank
scheduled.attachPermissions([
[topic.snsTopic, "grantPublish"],
[table.dynamodbTable, "grantReadData"],
]);
Frank
scheduled.attachPermissions([topic, "grantPublish"]);
grants 2 permissions. sns:*
permission to the topic
, and grantPublish:*
permission to *
. The reason it worked is b/c, sns:*
includes the sns:Publish
permission, and grantPublish:*
is an invalid permission, which is ignored by IAM.Frank
Ömer Toraman
11/21/2021, 8:02 PMÖmer Toraman
11/21/2021, 8:04 PMarray[0](array[1])
This basically means that the second element of the array must be an instance method for the underlying constructÖmer Toraman
11/21/2021, 8:05 PMtopic
does not have a method called grantPublish
to call for.
[topic, "grantPublish"]
Ömer Toraman
11/21/2021, 8:06 PMJon Holman
11/21/2021, 11:49 PMimport * as sns from "@aws-cdk/aws-sns";
import * as snsSubscriptions from "@aws-cdk/aws-sns-subscriptions";
...
const topic = new sns.Topic(this, "NotesEmailReminders", {
displayName: "email reminders",
});
topic.addSubscription(new snsSubscriptions.EmailSubscription("jon..."));
initially I tried SST's topic, but I couldn't get the email subscription created with that.Jon Holman
11/21/2021, 11:53 PMJon Holman
11/22/2021, 12:03 AMscheduled.attachPermissions([
[topic, "grantPublish"],
[table.dynamodbTable, "grantReadData"],
]);
Thanks, @Frank and @Ömer Toraman. It seems like my VS Code is not giving me suggestions on the table being passed from the StorageStack. In that line I linked to the demo app should it be table.dynamodbTable instead of just table?Frank
this.api.attachPermissions([table]);
This is actually right, you can pass in the SST Table or table.dynamodbTable. Both works.
However, [table.dynamodbTable, "grantReadData"]
works, but [table, "grantReadData"]
doesn’t b/c the grantReadData()
doesn’t exist on table.Frank
const topic = new sst.Topic(this, "NotesEmailReminders", ...);
topic.snsTopic.addSubscription(
new snsSubscriptions.EmailSubscription("jon...")
);
topic.snsTopic
gives you the underlying SNS Topic.Jon Holman
11/22/2021, 2:32 AMJon Holman
11/22/2021, 2:33 AM