Turns out I needed to create a `aws.lambda.Permiss...
# general
f
Turns out I needed to create a
aws.lambda.Permission
first. Is there a nice API to do both of these things?
b
I'm surprised
TopicSubscription
doesn't create the requisite permissions. @lemon-spoon-91807 what do you think?
l
TopicSubscription is a raw aws resource. So it would be a bit interesting to make it automatically make a permission
note: we do have Pulumi's
TopicEventSubscription
which also make's this permission for you automatically:
Copy code
this.permission = new lambda.Permission(name, {
            action: "lambda:invokeFunction",
            function: this.func,
            principal: "<http://sns.amazonaws.com|sns.amazonaws.com>",
            sourceArn: topic.id,
}, parentOpts);
we also have added the extension method "Topic.onEvent(...)" which will do this for you
f
Where is
TopicEventSubscription
located?
Ah https://pulumi.io/reference/pkg/nodejs/@pulumi/aws-serverless/#TopicEventSubscription. Seems weird to have to bring in another package to do this.
l
you don't have to
it's in aws now:
and:
f
Oh cool that sounds like what I was after. Will take a look tomorrow.
l
FYI:
@pulumi/aws-serverless
has been deprecated
Sounds good 🙂
b
Cyrus, instead of programming against TopicEventSubscription directly, is it better to use events like
onEvent
? E.g., for Kenny's example
Copy code
alertsSnsTopic.onEvent(..)
rather than
Copy code
new aws.sns.TopicSubscription(..., {
    topic: alertsSnsTopic,
    ...
);
l
they're functionally identical. So it depends in you prefer of thinking as events you connect by attaching to an instance. or if you think of an event as a first-class object in your system.
b
Ah ok, I thought you were saying one would create the IAM resources and the other wouldn't. Good to know they are the same.
l
Some people prefer the former (it's very .net'y for example). Whereas it's very idiomatically AWS to think of them as nouns
gotcha! sorry if that was unclear!