odfdata / webflow-aws

Python code to deploy your Webflow static website in AWS using Cloud Formation.
https://pypi.org/project/webflow-aws/
Apache License 2.0
12 stars 3 forks source link
aws aws-cdk python serverless webflow

webflow-aws

🛑 If you already deployed one website using the v1 version of the tool, follow the Migration from v1 to v2 section before updating the tool version.

An out-of-the box tool written in Python to deploy your Webflow static website on AWS with a serverless architecture.

This tool uses the power of Cloud Formation to let you have your website up in minutes, with CDN and SSL Certificate enabled.

You can manage up to an infinite number of websites in the same AWS account, paying only for the real traffic. That's the beautiful part of serverless 😉

☝️ In this version, everything needs to be hosted in AWS, also your domain.

Getting Started

Prerequisites

In order to use this tool, you need to have:

Finally, install the AWS CDK command line tool with the following command

npm install -g aws-cdk

Installation

You can download and install the latest version of this tool from the Python package index (Pypi) as follows:

pip3 install webflow-aws

Advanced Installation

This section explains how build and install the Python package using the source code.

Clone repo & build your package

To use our tool, you have to clone this repository and install:

After you cloned the repository, go inside the webflow-aws folder and generate the .whl package to be installed.

cd webflow-aws
python3 setup.py sdist bdist_wheel
Install the package

The build file (generate above) will be visible in the dist/ folder. You will have a wheel and tar.gz file. If you previously installed another version of webflow-aws, it's recommended to uninstall it running the following command:

pip3 uninstall dist/webflow_aws-{version}-py3-none-any.whl

Now you're ready to install the package inside the dist/folder. Without renaming them, you can install our tool on any computer with the following command

pip3 install dist/webflow_aws-{version}-py3-none-any.whl

You can find the {version} inside the setup.py file.

Check if everything is working

At this point, on your target machine, you will be able to use the tool by typing webflow-aws from any folder. To see the available commands, and check if it's correctly installed, run the following command

webflow-aws --help

Migration from v1 to v2

If you used the v1 version of the tool and you plan to migrate to the v2, remember this:

⚠️ Running the commands below will put your current website offline for couple of minutes. Plan to run the migration when you don't have traffic on your website.

To migrate from v1 to v2, you have to delete the current deployed website from the AWS Console. Unfortunately is not possible to do it using our tool since there are resources that are running at edge and it takes time to complete the deletion on AWS side.

These are the steps to delete your current website:

Update from v1 to v2

Run the following command to update the tool:

pip3 install --upgrade webflow-aws

Now you are ready to deploy your website using the new version running:

webflow-aws publish

Deploy your website

You are now ready to deploy your website. Start by going to Webflow and download your created website as a .zip file (click here to see a detailed guide on how to do it).

Once you downloaded it, create a folder and put the .zip file inside. The folder's name does not matter, but make it meaningful for you. In our guide we will use the example-website folder

Set up DNS record

Once your website is deployed, you will need a DNS Record to point to the file location. With webflow-aws you can do that in two ways:

With webflow-aws you can have one or more subdomain point at your website, such as example.com and www.example.com.

In the webflow-aws-config.yaml file you will need to set the list of domains you would like to have your website pointing at. For example, you can have example.com and www.example.com enabled.

Create webflow-aws-config.yaml file

The webflow-aws-config.yaml file allows you to customize the website you want to publish online. To create it, you have to run this command:

webflow-aws create-config

It will guide you through the creation of the configuration. At the end of this procedure, you will see the webflow-aws-config.yaml in your current directory.

Advanced creation

If you want to create the configuration file on your own, this is an example file you can customize:

# REQUIRED parameters
bucket_name: "www.example.com"
domain_name: "example.com"
CNAMEs:
  - "www.example.com"
route_53_hosted_zone_id: "Z05234556KK8DIAQM"
route_53_hosted_zone_name: "example.com"
stack_name: "WwwExampleComStack"

# OPTIONAL parameters
aws_profile_name: "default"
Optional Parameters

Place this file inside the example-website/ folder previously created. The content of that folder should be

|—— example-website
|    |—— weblfow-files.zip
|    |—— webflow-aws-config.yaml

Publish your website

Now you are ready to publish your website online.

Go inside the folder created before that contains:

To deploy your website, you have to execute this command:

webflow-aws publish

In 2 minutes, the content will be public available under the specified domain names.