Skip to main content

lektor-s3

Build Status

lektor-s3 makes it easy to deploy your Lektor project to an S3 bucket.

Before you start

You're going to be storing your website's data in an S3 bucket. The code here won't do anything to create or configure that bucket. You'll have to create the S3 bucket and set it up yourself.

AWS has a pretty good guide for how to set up a bucket to host a static website. You'll need to both create the bucket and set its permissions to allow global read access. Remember to do this first because lektor-s3 won't do it automatically.

Installation and Usage

Install with the usual Lektor toolchain. Within your project, run

lektor plugins add lektor-s3

You should see a message saying lektor-s3 has been added to the project.

Next, add an S3 bucket to your project's servers. In your project file (like blog.lektorproject), add the following:

[servers.s3]
name = S3
enabled = yes
target = s3://<YOUR-BUCKET>

For example, if you wanted to deploy to a bucket named 'huntedwumpus', you'd make that last line

target = s3://huntedwumpus

Now, if you call lektor deploy s3, Lektor will upload your built website to S3 in the bucket you targeted.

CloudFront

Optionally, you can also provide a CloudFront distribution ID. If you do, Lektor will invalidate all objects in that CloudFront distribution after every deploy.

cloudfront = <YOUR-DISTRIBUTION-ID>

Credentials

You need to prove to S3 that you have permission to upload to the bucket you've chosen.

lektor-s3 uses boto, which means it will obey boto's usual flow for gathering credentials.

For a refresher, that means you have two options: you can store your credentials in an INI file at ~/.aws/credentials, or you can pass credentials in through the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

If you have multiple sets of credentials, you can group them into profiles in your credentials file and choose the right one using the AWS_PROFILE environment variable. Your ~/.aws/credenials file might look like this:

[work]
aws_access_key_id = <...>
aws_secret_access_key = <...>

[personal]
aws_access_key_id = <...>
aws_secret_access_key = <...>

And then you can invoke lektor with the environment variable:

$ AWS_PROFILE=personal lektor deploy`

Configuration

You can specify headers to be attached to particular files when uploading them to S3. These can be configured in an INI file at configs/s3.ini under your project root.

You can name the sections anything that makes sense to you, but every section must have either a match or an extensions item to specify which files the configuration applies to. If using match, you should write this as a regular expression that will be applied against the filename using the regular expression's search method. If using extensions, write a comma-separated list of the file extensions to which the configuration applies. Both match and extensions may be specified.

The rest of the items in each section should specify one or more headers and their values. A list of valid headers is defined in the boto documentation as ALLOWED_UPLOAD_ARGS.

Defaults can be defined via the usual INI file way, in a [DEFAULTS] section.

For example, your configuration file might look like this:

[DEFAULT]
CacheControl = public,max-age=3600

[static files]
match = \.(css|js|woff|woff2)$
CacheControl = public,max-age=31536000

[media]
extensions = jpg,jpeg,png,mp4
CacheControl = public,max-age=259200

[fonts]
extensions = woff2
ContentType = application/font-woff2

[documents]
extensions = html,txt
ContentLanguage = en

Contributing

Pull requests are super useful and encouraged! Once accepted, changes are published using lektor with lektor dev publish-plugin.

Run your tests by invoking python setup.py test.

Metadata

Release files for lektor-s3 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lektor-s3 0.5.1
File Size Uploaded
lektor-s3-0.5.1.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lektor-s3 0.5.1
File Interpreter ABI Platform
lektor_s3-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / lektor-s3-0.5.1.tar.gz

Download URL lektor-s3-0.5.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
403a575b4b6ebd3db00d66db66f506019c25deb39b35996b94f1122332ba2f42
BLAKE2b-256 checksum
How to use checksums
c00911537b60565205a86a4a082edbb7338df5ef62038f5fd9a94f0e6e92fa7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / lektor_s3-0.5.1-py3-none-any.whl

Download URL lektor_s3-0.5.1-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f17d2d7f8ee42da17c711f4c2f99d4c1e1e0ba93ae9d192d8a1e8b011572e330
BLAKE2b-256 checksum
How to use checksums
17338041ed421b9a04a0dc783d437f2d6412c0642a255a21a5ab3f048ff2a208
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

3 release files

0.4.0

3 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page