is it possible to import an existing aws-loggroup ...
# general
p
is it possible to import an existing aws-loggroup into a new stack state so it won't be recreated or error out that it already exists? I want to import only the state not generate any code
a
p
both stacks are using the same code, hence importing the loggroup resource from another stack won't be compatible when I deploy the previous stacks
their resources have different names the only thing they share is the loggroup
by referencing means I have to create a new pulumi projects that creates just the loggroup then reference it
a
then it seems you’re looking for “get functions” https://www.pulumi.com/docs/concepts/resources/get/
p
still won't work as both stacks share the same code, e.g.: stack1 is creating the resource stack2 is also creating the same resource what I need is to import the state of the resource created by stack1 so stack2 will not attempt to recreate it and just use it as it's already created
a
You could create the stack1, then put into stack2's config the AWS resource URN (or whatever is needed for the reference) and in the code you put condition: if there is the reference in the config - use the resource by reference with the Get Function, otherwise create a new resource. Though it doesn't feel like idiomatic approach to me, it could be a workaround if you don't have too many stacks to remember to pass the reference everywhere needed
p
yes, that would work, though I found a different solution
I used
pulumi import
to import the resourse that uses exactly the same code, and now as it finds the resource and there's no change to it, kept it as is
now both stacks share the same code + resource
a
cool, thanks for sharing
p
anytime buddy