Is there a way to subscribe an `aws.lambda.Functio...
# general
m
Is there a way to subscribe an
aws.lambda.Function
instance to an SNS topic that was created external to a pulumi stack? The topic ARN would be passed in as a config parameter; i.e. an instance of
aws.sns.Topic
is not immediately available.
aws.sns.TopicSubscription
is where I started my search, but the problem with it is that
aws.sns.TopicSubscriptionArgs.topic
is required to be of type
pulumi.Input<aws.sns.Topic>
. Right now I am wishing it could be of type
pulumi.Input<aws.sns.Topic | aws.ARN>
.
l
i think you could do this by doing aws.sns.Topic.get
to create a pulumi resource instance for an existing aws topic
you can then subscribe to a lambda off of that topic
m
I'm looking into that as well.
It seems that that first argument,
name
, is arbitrary. The second arg,
id
, would be the ARN. But I'm getting an error:
InvalidParameter: Invalid parameter: TopicArn
. I suspect that I need to provide a custom provider to
aws.sns.Topic.get()
because the topic is in a different region.
l
that sounds reasonable
m
First result: Using
aws.sns.Topic.get()
works when the topic is found in the same region as the stack's default.
Final result: It works across regions, as long as an
aws.Provider
representing the foreign region is supplied to both
aws.sns.Topic.get()
and
new aws.sns.TopicSubscription()
.
👨‍🔧 1
l
nice!