https://pulumi.com logo
#typescript
Title
# typescript
b

breezy-butcher-78604

03/16/2021, 6:09 AM
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

little-cartoon-10569

03/16/2021, 6:14 AM
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

breezy-butcher-78604

03/16/2021, 6:17 AM
do you mean
pulumi state rm
? i dont want to rename or remove the stack, just rename some resources
l

little-cartoon-10569

03/16/2021, 6:17 AM
Yes 🙂 Sorry.
(Bit late here..)
b

breezy-butcher-78604

03/16/2021, 6:18 AM
haha, all good
l

little-cartoon-10569

03/16/2021, 6:19 AM
So it would be
pulumi state delete
b

breezy-butcher-78604

03/16/2021, 6:19 AM
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

little-cartoon-10569

03/16/2021, 6:19 AM
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

cool-fireman-90027

03/16/2021, 12:46 PM
This blog post on alias could help you.
👍 1
b

breezy-butcher-78604

03/16/2021, 1:05 PM
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