AWS Amplify Removed Video Source

AWS Amplify removed video sources from HTML

A good amount the websites I’ve pushed to production in the past couple of years have all been hosted on-prem within my client’s data centers. However, not all of my clients have test environments. Up until recently I’ve been hosting my test sites with Server4You, a fantastic non AWS/Azure/GCP hosting company/provider. But with the rise of AWS and Azure I want to start venturing over that way to gain experience and play around with those providers some more.

I’m starting with a front end only React app that I’ve developed for a client which will ultimately live in their data center when the site goes live, but to test while we’re building the site I decided to give AWS Amplify a try. This service is awesome and hooks right into Gitlab for automated CI/CD with a couple button clicks. Awesome as it is, I did run into one problem: My video src references were stripped out during the CI/CD process.

The site has three HTML5 video references to mp4s that are hosted within the build folder at the root of the web project. When the AWS Amplify CI/CD process migrated my code over to the hosting web server all of my src references were blank – <video src="" />.. I tried referencing the videos in a couple different ways from the React app but nothing seemed to work.

To get the video links to work in AWS Amplify, I ended up creating a S3 storage account, uploading my videos to a S3 bucket , assigned the appropriate permissions then referencing the videos in code to pull from the S3 bucket which ended up fixing the problem.

I haven’t been able to find any documentation that explicitly says that video sources are removed but hosting the videos in S3 fixed the issue for me.

Add A New Git Remote Repository

Working with different clients I often end up with multiple Git remote repositories. When I start a new project with a client I create the initial repository in my Gitlab called origin and if the time comes I will add another remote repository in the client environment with the name of the client clientABC. This is how to add a new Git remote repository in addition to your default Git repository.

Add the new remote repository using the git remote add command.
git remote add clientABC

Then when pushing or pulling from the different remote repositories make sure to include the appropriate remote name when running the commands. For example, when pulling from origin dev branch use git pull origin dev. And if you want to push your changes up to the new client remote use git push clientABC dev.

Remove Passwords From Git History

Every once in a while you’ll check in a key or password into a git repository by mistake. Not to worry, there’s a great utility that can erase the values from history for you. You can delete the file or update the text from the current HEAD but the value still exists in your branch history so you need to go further to remove the value.

Luckily there’s the BFG Repo-Cleaner utility tool that goes through your git history and updates all references of the private value and replaces it with **Removed**.

Here’s how to use the BFG Repo-Cleaner to remove passwords from your git history. The BFG Repo-Cleaner is a Java file that can be saved to your local machine and run against your cloned git repo.

  1. Start by downloading the BFG Repo-Cleaner .jar file to your local machine. I saved mine to a folder called bfg on my D: drive – D:\code\bfg.
  2. Create a passwords.txt file that lists the passwords/keys you want to remove from your git repository and save to the same folder as the BFG Cleaner. The passwords.txt file is just a list of different passwords/keys that you want to remove from the repository.
  3. Clone your repository using the –mirror flag and make a full backup of the repo just in case something breaks.
    $ git clone --mirror
  4. Open command prompt and run the following command
    $ java -jar d:\code\bfg\bfg-1.13.0.jar --replace-text d:\code\bfg\passwords.txt d:\code\delete-passwords.git
  5. Move into the cloned git folder and run the following command
    $ cd delete-passwords.git
    $ git reflog expire --expire=now --all && git gc --prune=now --aggressive
  6. And finally push your changes back to the remote repository
    $ git push

That’s it. If you go into your repository now you will see that all references to your values from the passwords.txt file will now be replaced with **Removed**. This is just the tip of the utilities ability, there are more examples and other documentation on at the BFG Repo-Cleaner project Github page.