It's spooky season! So in this post, we're going to explore how to avoid being haunted by content you thought you deleted — but actually didn't.
Using the CLI
If you're hosting a static website using AWS S3, one of the easiest ways to update your site is with the sync
CLI command:
aws s3 sync <LocalPath> <S3Uri>
Whether you're running the command manually or as part of a CI/CD pipeline, it's important to note that, by default, it will only add content.
This means that even if you intended to remove a page from your site and removed all links to it, the page could still be accessed by navigating to it directly.
Use the delete flag
In order to delete non-existing content using this command, you'll have to use the --delete
flag.
aws s3 sync <LocalPath> <S3Uri> --delete
Just be careful to only use the --delete
flag when you actually want to delete content that isn't present in the source directory.
Taking precautions
In general, it's a good idea to run S3 CLI commands with the --dryrun
flag to show what actions would be performed without actually performing them.
aws s3 sync <LocalPath> <S3Uri> --delete --dryrun
To read more about this command and other available options, see the documentation.
More Content
If you liked this, you might also like some of my other posts. If you want to be notified of my new posts, follow me on Dev or subscribe to my brief monthly newsletter.
- What was the first program you wrote?
- The weird quirk of JavaScript arrays (that you should never use)
- Does Elixir have for loops?
- Learn Elixir with me!
- Project Tours: Bread Ratio Calculator
- Changing Emoji Skin Tones Programmatically
- I made my first svg animation!
- 5 tips for publishing your first npm package
- 4 Hugo Beginner Mistakes
Top comments (0)