Open Source your AWS Amplify Project in 3 Steps

If you're interested in building a full stack app that is open sourced and secure, then AWS Amplify is the way to go! This article will cover how you can upload your existing project to GitHub and start sharing it with the world without needing to worry about your resources being abused.

Prerequisites


curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL
  • Configure the Amplify CLI by running:

amplify configure

1. Setup Git

First, start by setting up Git for your project (you should be in the root directory of your project):


git init

Now all the files in your project should be tracked by Git, excluding all the files listed in the .gitignore file:


cat .gitignore

Next, commit all the files for your project:


git add . && git commit -m "initial commit"

This is two command in one: adding all the changes from the current directory to Git and commiting those changes to Git with a comment specifying this is the initial commit.

2. Uploading to GitHub using the GitHub CLI

The easiest way to get your project up to GitHub is to use the CLI.

Create a new repository in your GitHub account by running the following command:


gh repo create

You can press Enter to select all the default answers for each prompt:


? Repository name my-project
? Repository description
? Visibility Public
? This will add an "origin" git remote to your local repository. Continue? Yes

Now push the commit to GitHub:


git push origin main

Depending on the branch you're currently on, you may need to use a different branch name. In the snippet above, the branch name is main.

Your codebase should now be available to the world with one exception, others can't access your AWS resources.

3. Cloning the project

As long as your repo is public, other developers only need to enter in a single command to clone both the project source code AND the structure of your AWS resources to their own account.

Run the following command:


amplify init --app https://github.com/your-profile/your-project

Done! 🎉

Your open source project is now successfully cloned and the resource structure has been copied to the other developers AWS account.