is it possible to alias a resource to another reso...
# typescript
b
is it possible to alias a resource to another resource that used to be part of a
ComponentResource
? basically I have an S3 bucket inside a
ComponentResource
however I now want to refactor this template and move the bucket out of the component resource, but i don't want to replace the actual resource in AWS. is this possible? I basically removed the entire component resource from my code, copy-pasted just the bucket resource into the template. I've then set a few variations of
aliases
on the resource but each time i run
pulumi up
it's seeing them as two different resources. I feel like maybe i'm just not providing the right alias but just wanted to check if this was actually possible
l
Sure. You can use
pulumi stack rename
or
pulumi stack rm
followed by an import.
You're looking to rename it "up" a few levels. Have a look at its original URN (
pulumi stack export
) and URNs near where you want it to end up. The changes should be fairly straightforward.
Not really a #typescript question.. kind of #general I think?
(The advantage of the
rm
then import is that it's easy to add the alias at the same time.)
b
do you mean
pulumi state rm
? i dont want to rename or remove the stack, just rename some resources
l
Yes 🙂 Sorry.
(Bit late here..)
b
haha, all good
l
So it would be
pulumi state delete
b
i want to try and avoid having to delete/reimport but if I can't figure out the alias stuff i guess I can fall back to that
l
I can't find the command for renaming a resource.. maybe it has to be delete / import.. I thought there was a rename... 😕
The problem with the alias in this situation is that the dependency isn't broken.. you need that if you want to move it out of the component resource.
You can have an alias to the old name, but I don't think you can "just" alias it, you have to rename (= delete/import) it too.
c
This blog post on alias could help you.
👍 1
b
i ended up aliasing using the entire URN (rather than parent or type) and that worked exactly how I needed it to. thanks for the help both
👍 1