https://pulumi.com logo
#getting-started
Title
# getting-started
r

rhythmic-nail-73192

03/17/2021, 3:56 PM
Is it possible to import component resources in the CLI? You can see I successfully imported 3 resources related to an S3 bucket, but it's at the root of the stack. I want to import them into the S3Bucket component I've created. I assume this is possible with a resource import, but is it possible from the CLI bulk import?
g

gentle-diamond-70147

03/17/2021, 3:58 PM
You can uses
aliases
to change the parent of the resource to your component. https://www.pulumi.com/blog/cumundi-guest-post/
r

rhythmic-nail-73192

03/17/2021, 3:59 PM
Makes sense, but we have over 500 resources to import and I was hoping I could import them directly into the final structure instead of aliasing all of them
g

gentle-diamond-70147

03/17/2021, 4:08 PM
You can set the parent with
pulumi import --parent ...
if that's how you're importing it.
r

rhythmic-nail-73192

03/17/2021, 4:15 PM
Aha! And that works for arbitrarily deep nesting? In the example screenshot above, I would be importing under
panther:s3Bucket
(component) ->
aws:s3:Bucket
->
aws:s3:BucketPublicAccessBlock
g

gentle-diamond-70147

03/17/2021, 4:17 PM
Yep, I believe so.
r

rhythmic-nail-73192

03/17/2021, 4:21 PM
Great, I will try that, thank you! Last question - is there any meaningful difference between importing it from within Pulumi code and using the CLI?
7 Views