Skip to main content

Deploy static websites using a single command

Project description

static-deployer

What is static-deployer?

static-deployer aims to simplify the deploy and rollback of your static website (frontend) to AWS using a single command. It still does not create the AWS resources for you, so you need to have a previously configured S3 bucket and a CloudFront distribution configured with an origin to your S3 bucket. The credentials you will use to run the static-deployer need to have permission List+Read+Write permissions to the specified bucket and cloudfront distribution.

How to install?

pip3 install static-deployer

How to configure the AWS credentials?

We recomend using aws-vault because it does not store your credentials in plaintext. But you can also use aws-cli.

After installing aws-vault, add a new profile using the following command:

aws-vault add mysite

How to deploy a static website?

aws-vault exec mysite -- static-deployer deploy \
    --root-dir ROOT_DIR \
    --patterns PATTERNS \
    --bucket-name BUCKET_NAME \
    --distribution-id DISTRIBUTION_ID \
    --origin-name ORIGIN_NAME \
    --version VERSION

The deploy does the following:

  1. Finds all files from ROOT_DIR, including only those that match the patterns specified in PATTERNS (comma separated);
  2. Unside the bucket specified by BUCKET_NAME, creates a new folder/directory with the name specified in VERSION;
  3. Uploads all files to the folder/directory created in step 2;
  4. Changes the CloudFront distribution DISTRIBUTION_ID origin named ORIGIN_NAME to point the folder/directory created in step 2;
  5. Invalidates the CloudFront distribution DISTRIBUTION_ID cache using the pattern /*;
  6. Waits for the distribution changes to complete.

How to rollback to a previous deployed version?

static-deployer rollback \
    --bucket-name BUCKET_NAME \
    --distribution-id DISTRIBUTION_ID \
    --origin-name ORIGIN_NAME \
    --version VERSION

The rollback does the following:

  1. Changes the CloudFront origin ORIGIN_NAME to point to a previously deployed version specified by VERSION.
  2. Waits for the distribution changes to complete.

Example of config file config.toml

dry_run = "false"

[content]
root_dir = "public"
patterns = "**"

[storage]
name = "your-website-domain.com"
prefix = "{{version}}"

[cdn]
distribution_id = "your-cloudfront-distribution-id"
origin_name = "your-cloudfront-origin-name"

How to use the config file?

static-deployer -c config.toml deploy --version VERSION

Once you have settings in a config file, you can tell static-deployer to use the config file by using the arguments -c yourfile.toml. By specifying a config file, you eliminate the need of informing all parameters at every invocation. You're then required to inform only the missing parameters. The command-line arguments override any settings you have in the config file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

static-deployer-0.1.3.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

static_deployer-0.1.3-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file static-deployer-0.1.3.tar.gz.

File metadata

  • Download URL: static-deployer-0.1.3.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for static-deployer-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b03cebff704d1191bf99de2ac0965328f0f2497dc2bf76f8881016edc690100f
MD5 eb27d39e1734b65f737eb93adeec4124
BLAKE2b-256 69bdcad13d770c785e0831b1886b7bf72ce01901800fac2d149abbc209786df7

See more details on using hashes here.

File details

Details for the file static_deployer-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: static_deployer-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for static_deployer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 80daaaac32fc3181a5fad74fbd1d9b66a86e72afab14fb6be17032603db16750
MD5 af3c364ad9c8e0901322acfbf141c3c5
BLAKE2b-256 0349214ea2884ee233c320c5cecf059261c51899b16eecb790da39f264396523

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page