You do not need to flatten the tree first. In buildspec.yml, declare artifacts with a recursive glob: files: '**/*' . That matches every file in every subfolder of the build working directory. Two refinements from the thread's approach: if you only want the nested folder's contents, set base-directory to that folder so the uploaded tree starts there instead of including the parent path; and quote '**/*' in YAML so the asterisks are not misparsed. Verify with a post_build ls or find before the upload step runs.

Context: Stack Overflow #54484028 (accepted answer, 30 votes): the asker needs buildspec.yml to pick up every file under a nested public folder, including subfolders, for an S3 deploy via CodePipeline. They worked around it by copying everything into a flat staging dir first. The accepted answer's own buildspec shows the simpler mechanism: the artifacts files glob '**/*' already matches recursively.