Hello folks, Quick doubt, is it possible to update an Topic Subscription using Pulumi SDK? I’ve alr...
b
Hello folks, Quick doubt, is it possible to update an Topic Subscription using Pulumi SDK? I’ve already created an
SNS Topic
but now I want it to have filter policies and may add more in the near future, the thing is that I cannot directly update it because Pulumi says that the resource already exists and won’t update it. Even changing the name of the subscription to try provoking a delete and re-creation won’t work because the Subscription remains and you cannot add a new subscription using the same Topic/Endpoint. Is there any way to achieve this? could not find anything on the docs Thanks in advance!
m
To resolve the conflict, first import the subscription into your stack: https://www.pulumi.com/docs/concepts/options/import/ Then it's under Pulumi's management and you can modify and update it just like any other resource.
b
Great, will try that, thx!
Even when I’ve created the subscription using Pulumi, I do have to import it in order to be able to modify it?
m
You can modify it by modifying the stack to which the resource belongs. But you cannot manage the same resource in more than one Pulumi stack at the same time.
Either your first Pulumi deployment of resources is a one-off activity (i.e., you'll never go back and update the stack), then you can safely import it in another stack. Or you need to structure your stacks in a way that has each resource under control of one stack. You can look up an existing subscription (if you just need to know some property) but you cannot modify it
b
The situation is the following (always using the same stack and code): • Have successfully create an SNS Subscription to a Topic as src and SQS as endpoint • Tried to add a new filter policy to that subscription and this fails. Pulumi won’t modify the already existing subscription to add the filter policy because says that the subscription already exists and won’t update it
m
You'll have to do this modification through the original stack. The following works: First version that you deployed with `pulumi up`:
Copy code
subscription = aws.sns.TopicSubscription("my-sub", topic=..., protocol="sqs")
And then, later, you modify this code to now read:
Copy code
subscription = aws.sns.TopicSubscription("my-sub", topic=..., protocol="sqs", filter_policy="...")
And run
pulumi up
again. This will modify the subscription. What you cannot do is have a second stack that just modifies this property of the resource.
b
I think I’ve found the error
and you’re absolutely right
Should work, the issue raises from a bifurcation I wasn’t aware of so it is trying to create a new subscription instead of updating the previous one
Thanks, already trying that
👍 1
It worked like a charm, it was an error on the code, thx
🎉 1