This message was deleted.
# general
s
This message was deleted.
n
I’m using a
protocol
of
lambda
and trying to set the
endpoint
to the arn of my lambda, but i get
Copy code
error: Error creating SNS topic: InvalidParameter: Invalid parameter: Lambda endpoint ARN
    	status code: 400, request id: bb8ed901-7c38-5ff9-af43-8e5a64cecebf
oh i guess that error means im trying to re-create the topic, i just need to get the topic… interesting.
so i changed it to use
Copy code
const topic = pulumi.output(aws.sns.getTopic({
	name: 'topic-name'
}, { async: true }))
but now I’m getting the following error on
Copy code
new aws.sns.TopicSubscription
of
Copy code
Type 'Output<string>' is not assignable to type 'Input<Topic>'.
even though it says to use an
arn
Copy code
/**
     * The ARN of the SNS topic to subscribe to
     */
    readonly topic: pulumi.Input<Topic>;
w
your
topic
variable isn’t not a string. It will be some object with a property on it that is a string.
Could you share a full code snippet?
n
yeah i was able to finally get it with
Copy code
const topic = new aws.sns.Topic('someTopic')

export const lambdaWithSns = new aws.lambda.Permission('lambdaWithSns', {
	action: 'lambda:InvokeFunction',
	function: someLambda.name,
	principal: '<http://sns.amazonaws.com|sns.amazonaws.com>',
	sourceArn: topic.arn
})

export const subscriptionChange = new aws.sns.TopicSubscription(resourceName(pulumi, 'subscription'), {
	protocol: 'lambda',
	topic: topic,
	endpoint: someLambda.arn
})
hey @white-balloon-205 looks like this ☝️ actually wasn’t what i needed… dev/staging didn’t have the topic, so new created those just fine, but there was an existing
topic
in production env, and now it created a duplicate
topic-2468
&
topic-1357
, but i’d want the one that was already created, and NOT create a new one. That’s why i was trying use
getTopic
, but that doesn’t have the same return type, so back to the drawing board. thx though.
w
You can use
Topic.get
to get a full instance of
Topic
based on an existing ID. https://www.pulumi.com/docs/reference/pkg/aws/sns/topic/#look-up
n
oh yeah, just realized
Copy code
/**
     * Get an existing Topic resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state Any extra arguments used during the lookup.
     */
    static get(name: string, id: pulumi.Input<pulumi.ID>, state?: TopicState, opts?: pulumi.CustomResourceOptions): Topic;
I feel like i’ve tried that ☝️ but i was failing with it also. ill look again, thx @white-balloon-205 appreciate it.
👍 1
@white-balloon-205 still having issues with this, sorry man, but i have:
Copy code
const existingTopic = pulumi.output(aws.sns.Topic.get('someTopic', '3ce3de0'))
const arn = existingTopic.apply(o => o.arn)
and that results with:
Copy code
arn OutputImpl {
      __pulumiOutput: true,
      isKnown: Promise { <pending> },
      isSecret: Promise { <pending> },
      resources: [Function],
      allResources: [Function],
      promise: [Function],
      toString: [Function],
      toJSON: [Function] }
and i still can’t seem to get the
Topic.arn
, am i missing something?
also noticed this error message at some point as well, but I can’t figure this out 😞
Copy code
To get the value of an Output<T> as an Output<string> consider either:
    1: o.apply(v => `prefix${v}suffix`)
    2: pulumi.interpolate `prefix${v}suffix`
    See <https://pulumi.io/help/outputs> for more details.
    This function may throw in a future version of @pulumi/pulumi.
w
I'm not quite sure what you are ultimately trying to do with the
arn
- but the code above should just be:
Copy code
const arn = aws.sns.Topic.get('someTopic', '3ce3de0').arn
n
I’m trying to use the arn for `sourceArn`:
Copy code
export const pxTopicSubLambdaWithSns = new aws.lambda.Permission('pxTopicSubLambdaWithSns', {
	action: 'lambda:InvokeFunction',
	function: pxTopicSubLambda.name,
	principal: '<http://sns.amazonaws.com|sns.amazonaws.com>',
	sourceArn: topicArn
})
but im getting different errors when trying different things, and getting more errors the more i fix the other things.. idk, just getting beat up by this.
recent error:
Copy code
error: Preview failed: refreshing urn:pulumi:::aws:sns/topic:Topic::deviceConfigUpdates: InvalidParameter: Invalid parameter: TopicArn Reason: An ARN must have at least 6 elements, not 1
    	status code: 400, request id: 6fc026ce-bed4-5b7a-8538-71adf830afb3