https://pulumi.com logo
#general
Title
# general
m

modern-diamond-82589

02/21/2019, 9:38 PM
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

lemon-spoon-91807

02/21/2019, 10:01 PM
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

modern-diamond-82589

02/21/2019, 10:02 PM
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

lemon-spoon-91807

02/21/2019, 10:11 PM
that sounds reasonable
m

modern-diamond-82589

02/21/2019, 10:45 PM
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

lemon-spoon-91807

02/22/2019, 2:26 AM
nice!
3 Views