Package: lektor-s3
lektor-s3lektor-s3 makes it easy to deploy yourLektorproject to an S3 bucket.Before you startYou'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 apretty good guidefor 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 thisfirstbecause lektor-s3 won't do it automatically.Installation and UsageInstall with the usual Lektor toolchain. Within your project, runlektor plugins add lektor-s3You 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
(likeblog.lektorproject), add the following:[servers.s3]name=S3enabled=yestarget=s3://<YOUR-BUCKET>For example, if you wanted to deploy to a bucket named 'huntedwumpus',
you'd make that last linetarget=s3://huntedwumpusNow, if you calllektor deploy s3, Lektor will upload your built
website to S3 in the bucket you targeted.CloudFrontOptionally, you can also provide aCloudFrontdistribution ID. If you do, Lektor will invalidate all objects in that CloudFront
distribution after every deploy.cloudfront=<YOUR-DISTRIBUTION-ID>CredentialsYou 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 obeyboto'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 variablesAWS_ACCESS_KEY_IDandAWS_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 theAWS_PROFILEenvironment variable. Your~/.aws/credenialsfile 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 invokelektorwith the environment variable:$AWS_PROFILE=personallektordeploy`ConfigurationYou can specify headers to be attached to particular files when uploading them
to S3. These can be configured in an INI file atconfigs/s3.iniunder your
project root.You can name the sections anything that makes sense to you, but every section
must have either amatchor anextensionsitem to specify which files the
configuration applies to. If usingmatch, you should write this as a regular
expression that will be applied against the filename using the regular
expression's search method. If usingextensions, write a comma-separated list
of the file extensions to which the configuration applies. Bothmatchandextensionsmay 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 asALLOWED_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,mp4CacheControl=public,max-age=259200[fonts]extensions=woff2ContentType=application/font-woff2[documents]extensions=html,txtContentLanguage=enContributingPull requests are super useful and encouraged! Once accepted, changes
are published using lektor withlektor dev publish-plugin.Run your tests by invokingpython setup.py test.