question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[aws-s3-deployment] support for empty folder deployement

See original GitHub issue

Description

With the following assets folder:

assets/ |----> FolderA/

Instantiate BucketDeployement has no effect.

new BucketDeployment(this, "DeployWebsite", {
      sources: [Source.asset("./assets")],
      destinationBucket: myBucket
    }); // no effect

What would be expected?

A bucket with the following structure:

Mybucket: |----> FolderA/

Use Case

required to generate folder-level access bucket policies

Proposed Solution

As a workaround, i use empty file to force BucketDeployement to render the folder structures And delete the empty file afterwards

assets/ |----> FolderA/ ---->emptyFiles.txt

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
tstibbscommented, Jun 29, 2022

I personally think this is still a valid feature request. If someone wants to close it as “won’t ever get around to implementing this” then fair enough, but I don’t think the fact that it hasn’t seen any attention in the last year invalidates the requirement.

0reactions
moltarcommented, Sep 14, 2022

S3 has no concept of folders though. S3 is an object store. Each object is a blob, which is identified by a key. A folder is not an object or a blob. It’s a filesystem concept.

The folders are an illusion made by AWS Console. If you use / in the object key name, then the console will pretend the key paths are folders. But as far as the underlying protocol and APIs are concerned - there are no folders, just keys.

The workaround is super simple though. Create a dummy object: your-desired-dir/.keep.

You can do it directly from the Source class, without ever needing this file to exist on disk prior:

Source.data('your-desired-dir/.keep', '')
Read more comments on GitHub >

github_iconTop Results From Across the Web

aws-cdk/aws-s3-deployment module - AWS Documentation
IMPORTANT The aws-s3-deployment module is only intended to be used with zip files from trusted sources. Directories bundled by the CDK CLI (by...
Read more >
Emptying a bucket - Amazon Simple Storage Service
You can empty a bucket's contents using the Amazon S3 console, AWS SDKs, or AWS Command Line Interface (AWS CLI). When you empty...
Read more >
Organizing objects in the Amazon S3 console using folders
Use the Amazon S3 console to create folders that you can use to group your objects.
Read more >
Create a pipeline that uses Amazon S3 as a deployment ...
Even if you delete files from the source repository, the S3 deploy action does not delete S3 objects corresponding to deleted files. This...
Read more >
Use custom resources with Amazon S3 buckets in ...
The template allows you to create folders in S3 buckets. Amazon S3 has a flat structure, but supports the folder concept as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found