https://pulumi.com logo
#google-cloud
Title
# google-cloud
s

sparse-carpet-63783

02/04/2022, 5:47 PM
Hi all. Is there a way to create sub-buckets using storage.Bucket()? I cannot find any examples of how it’s done. Thx!
p

prehistoric-activity-61023

02/05/2022, 9:54 AM
That might sound stupid… is there anything like sub-buckets in GCS? I’ve never heard of it.
Unless… you meant “how to a create empty folder within GCS bucket”. If so, you can achieve that e.g. by explicitly creating an object with trailing slash in name:
Copy code
gcp.storage.BucketObject(
    "empty-folder",
    bucket=my_bucket_name,
    name='example_folder/',
    content='IT-DOES-NOT-MATTER',
)
content
field is required but it will be ignored in case object has trailing slash in name. Just a reminder, GCS (and basically most of object storage solutions) uses a flat filesystem. That means, you don’t have to actually create empty folders in order to store things within them. You can directly upload file
parent_folder/subfolder/myfile.txt
and it will “create” parent directories automatically (cause in fact, it’s just a long name with slashes and not a real tree-like structure).
🙌 1
g

green-school-95910

02/07/2022, 11:12 AM
I believe when you create a folder from the web console it sets a specific mime type to identify it as a folder marker. You need that if you want to
gsutil rsync
somewhere including the empty folder if I'm not mistaken
s

sparse-carpet-63783

02/07/2022, 7:06 PM
makes sense. Thanks a lot for the pointers
4 Views