Skip to content

wwbakker/sbt-deploy-static-website-to-s3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sbt-deploy-static-website-to-s3

An sbt plugin for deploying a static website to s3 programmatically.

Requirements.

  • An AWS account with permissions for accessing and modifying S3 resources. Make sure you have configured your access (for example by setting your credentials in ~/.aws/credentials and your region in ~/.aws/config.
  • An SBT project, using the sbt-web plugin

Configuring your project

  • In [yoursbtproject]/project/plugins.sbt add the following:
resolvers ++= Resolver.sonatypeOssRepos("releases")
addSbtPlugin("nl.wwbakker" % "sbt-deploy-static-website-to-s3" % "1.3")
// Add sbt-web if it isn't added to your project already.
addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.4.4")
  • SbtWeb needs to be enabled. When SbtWeb is enabled, this plugin's tasks will be automatically made available. To enable SbtWeb, add .enablePlugins(SbtWeb) to your build.sbt:
lazy val root = (project in file("."))
  .settings(
    name := "your-project",
    organization := "org.example"
  ).enablePlugins(SbtWeb)
  • Then in your project's build.sbt set the following properties
// Configure your bucket name here. The bucketname will be visible in the URL.
// When you want to use S3 to host a website from your domain, be sure to mirror
// the domain name in your bucket name
DeployStaticWebsiteToS3 / bucketName := Some("www.mywebsite.com")
// OPTIONAL: default is index.html
DeployStaticWebsiteToS3 / indexDocument := "index.html"
// OPTIONAL: default is unset
DeployStaticWebsiteToS3 / errorDocument := "error.html"

Deploying your website

Once you have configured the plugin in your project you have the following tasks available in your project:

  • deploy-static-website-to-s3:createS3Bucket: Creates an empty s3 bucket, configured for use for static website.
  • deploy-static-website-to-s3:deployToS3: Uploads your website's files and deletes files in the bucket that do not pertain to your site.
  • deploy-static-website-to-s3:undeployFromS3: Removes all files from the configured S3 bucket.
  • deploy-static-website-to-s3:deleteS3Bucket: Deletes the configured S3 bucket.

Be careful

As this plugin manages your S3 buckets, be careful. Creating buckets and uploading files can incur costs (AWS will charge for storing and serving data on S3). Deleting your files on S3 without having a backup can cause you to lose files.

About

An sbt plugin for deploying a static website to s3.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages