eLinkin
Host your media in the cloud in minutes!
The AWS Serverless boilerplate with all you need to quickly host your media in the cloud practically for free using AWS S3 Buckets and Cloudfront.
Key Features
-
S3 Media Hosting: Easily upload your media and deploy. Then it is available to you in the cloud!
-
Do it again and again: Host your media, then do it again and again. Built with AWS CDK (Cloud Deployment Kit), creating different media deployments is as easy as copy and paste.
-
Automatic GitHub repository invitation upon payment
Step-by-step setup
When deploying this template, the sequence of steps is important. Follow the steps below in order to get up and running.
Quick Start
To successfully deploy the project, you will need to create an AWS account.
IMPORTANT: When creating AWS users/accounts, NEVER give out your access keys to anyone or upload them to any public repository. Bad actors can abuse your keys and spin up AWS resources without your immediate knowledge!
Setting Multi-Factor Authentication (MFA) on your AWS account is highly recommended!
Creating An IAM User
Creating an IAM User for AWS Access
When setting up a new AWS account, you'll encounter a variety of features. While it might seem complex, we'll take care of most of it for you! We do need to first configure access keys, which allow external applications (like ours) to interact with your AWS resources. These keys are managed through IAM (Identity and Access Management) users.
Setup an IAM User Guide for eLinkin
-
Create API Access Keys:
- Open the IAM Console.
- Make sure you are logged into your AWS account.
- Navigate to
Users
underAccess management
- Click on
Create user
. They do not need access to AWS Management Console. - Select
Attach policies directly
- *Under
Permissions policies
selectAdministratorAccess
and check it. Alternatively, you can provide scoped permissions by looking under the requirements in/deployment/lib
. - Press
Next
thenCreate User
- Now that your user is created, select the user.
- Go to "Security Credentials".
- Scroll down to "Access Keys".
- Click "Create access key".
- Select "Local Code", check the checkbox, and continue.
- You don't need a description. Select
Create access key
. - Continue to get your Access Key ID and Secret Access Key and follow the next stpe.
-
Update the
variables.env
File:- Place your Access Key ID and Secret Access Key in the
variables.env
file. - Your project should now have the necessary access to AWS resources.
- Place your Access Key ID and Secret Access Key in the
Important Security Note (I know we already had one up there but this is extremely important!)
- DO NOT UPLOAD YOUR KEYS TO ANY PUBLIC REPOSITORY!
- As an extra precaution, after deploying your project and confirming it works, consider deleting these keys both in your local project as well as inside of the [IAM Console](https://us-east-1.console.aws.amazon.com/.
- If you are uploading this anywhere that is not your local directories, be sure to add it to your .gitignore file.
Setting Up AWS CDK (Cloud Deployment Kit)
-
Install Node.js and npm AWS CDK is a Node.js application, so you need Node.js and npm (Node.js package manager) installed. You can download and install Node.js and npm.
-
Install AWS CDK With Node.js and npm installed, you can now install AWS CDK. Run the following command in your terminal:
npm install -g aws-cdk
This installs the AWS CDK globally on your machine, allowing you to use it in any project.
- Verify CDK Installation After installation, verify that the CDK has been installed correctly by running:
cdk --version
This command will display the installed version of the CDK, confirming that it is ready to use.
Pre-Deployment
Installing Node Modules
Now that your environment is configured, the next step is to install the required Node.js modules. These modules are necessary for the AWS CDK and other project dependencies to function correctly.
-
Navigate to the 'Deployment' Folder: Open your terminal and navigate to the project folder. Use the cd command to change directories:
cd path/to/your/project
Replace path/to/your/project with the actual path to your project's root directory.
-
Run npm Install: In the your project directory, run the following command to install the required Node.js modules:
npm install
If you encounter any permission issues, you may need to prefix the command with sudo:
sudo npm install
This command reads the package.json file in your 'deployment' folder and installs all the dependencies listed there, which is required for eLinkin to work.
One Thing To Do...
Okay great! You've got your AWS credentials, environment, and CDK set up.
We did all the heavy lifting for you. There's only one more thing you need to do before deploying!
- Upload your media!:
- Navigate to the project and upload your media in the
media
folder. - Any object in there will be available to the public.
- Adding or deleting objects will do the same in the cloud. The cloud will match your media folder after every deployment.
- Navigate to the project and upload your media in the
Deployment
Now that we have all the setup, deployment is easy.
-
Prep AWS for CDK deployment by running the following in your project directory:
cdk bootstrap
-
Once your AWS environment is prepped, run the following command to begin deployment:
node main.js
After running the script for the first time, you may be presented with a table of IAM Policy Changes in which you will be prompted. Simply type
y
for "yes":y
That's It! Navigate to your media content!
After deployment finishes (it may take a couple minutes the first time) your content should be ready to go!
- Visit Your Media:
- Visit your deployed media in your browser. The terminal logs should provide direct links to your content!
- Alternatively, you can construct links to your content by simply pairing the
CloudFrontDistributionDomainName
value in yourcdk-outputs.json
file and path to your media. For example,xxxxxxxxxx.cloudfront.net/example-media.mp4
That's it
Not bad! Your media is now accessible and you can use it in your websites or wherever you need to access it.
Anytime you need to remove or upload new media, simply add/remove content from the media
folder, then redeploy in your project directory with node main.js
. The syncing will happen automatically!
Questions
If you have any questions, feel free to reach out to me on my X handle @realHenryOuang or email admin@enteleca.com!
Enjoy eLinkin!