AWS s3 subfolders creation

Skip to first unread message

sushant kode

Jun 5, 2021, 2:48:17 AM6/5/21
to Terraform
Hi All,
We have a requirement to create  a particular set of folders and subfolders in a s3 bucket. Bucket will be having a folder with env name (eg. level 1-> dev). Now dev will have 3 subfolders (eg. level 2-> incoming, outgoing, error). Now each of the subfolder will be 2 more subfolders(eg. level 3-> orange, black). 
the folder structure:
dev/ outgoing /orange
dev/ outgoing /black
dev/ error /orange
dev/ error /black
There is possibility of having level 4 subfolder structure. Is there a way in terraform to create these folders and subfolders keeping the code generic, so that it can be used for other buckets across environments. 

Thanks in Advance. 

Fernando 🐼

Jun 5, 2021, 4:42:47 AM6/5/21
Object storage, like aws s3, does not have a concept of folders. 
Every object has a key, and that key is the path to it. 
Folders, directories, etc, do not represent keys and as such don't really exist. 

Object storage is not a file system! 

Fernando 🐼

In the coming weeks, inbound messages to this group will be disabled, and it will be used for outbound announcements only. To prepare for this switch, please direct questions and conversations to our primary medium to communicate with practitioners: We look forward to collaborating with you there!
This mailing list is governed under the HashiCorp Community Guidelines - Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues:
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Sam Flint

Jun 8, 2021, 10:22:34 AM6/8/21
You can specify any bucket path when writing to it.   No need to create them ahead of time with terraform.

Alexandra Freeman

Jun 21, 2021, 10:31:08 AM6/21/21
to Terraform
Hello and thank you for your question!
On June 3, 2019 HashiCorp launched Discuss, a forum to facilitate dialogue within the HashiCorp community. This format allows answers to be more readily searched and indexed, making it easier to find answers to existing questions and to share knowledge with each other. Please direct all questions and conversations to the discussion forum. We look forward to collaborating with you there!


Reply all
Reply to author
0 new messages