Maybe not Python specific, but I've got a question...
# python
s
Maybe not Python specific, but I've got a question about importing a resource into the state. My particular problem is, I have two AWS accounts and my code uses a provider to configure resources in the second account. I cannot delete and recreate them easily, thus I have to import these, but how do I import resources located in a second account?
p
you can specify the provider while importing the resources
s
Do you have an example for this?
p
do you already have a provider defined in the state for the second account?
s
I thought yes, but my pulumi run said it will create it
But I can create a resource and remove it so the provider will be persisted in the state
p
Create it then. You will need an existing provider instance if you want to easily import the resource.
you can create the provider itself, you don’t have to create any resources linked to it
Once you have a configured provider in the state, get its URN (you can find it using e.g.
pulumi stack --show-urns
). Once you have it, use
--provider
flag available in
pulumi import
command.
Example:
Copy code
pulumi import --provider my_provider_name='<PROVIDER>' github:index/repository:Repository just-a-test just-a-test
my_provider_name
can be anything AFAIK - it will just be used in generate code template (you can reuse the variable name you used for provider so the snippet will be adjusted to it out of the box)
make sure you provide
PROVIDER
within single quotes (URNs usually contain dollar signs and it breaks the shell substitution)
s
Ok, thanks
Will give it a try
Will report later, got pulled into a meeting
@prehistoric-activity-61023 And of course I forgot to report back .. it did work 😁
🙌 1