Skip to content

SBT Plugin that adds support for resolving and publishing using Amazon S3

License

Notifications You must be signed in to change notification settings

hubbiz/fm-sbt-s3-resolver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frugal Mechanic SBT S3 Resolver

Build Status

This SBT plugin adds support for using Amazon S3 for resolving and publishing using s3:// urls.

Table of Contents

Example

Resolving Dependencies via S3

resolvers += "FrugalMechanic Snapshots" at "s3://maven.frugalmechanic.com/snapshots"

Publishing to S3

publishTo := Some("FrugalMechanic Snapshots" at "s3://maven.frugalmechanic.com/snapshots")

Valid s3:// URL Formats

The examples above are using the Static Website Using a Custom Domain functionality of S3.

These would also be equivalent (for the maven.frugalmechanic.com bucket):

s3://s3-us-west-2.amazonaws.com/maven.frugalmechanic.com/snapshots
s3://maven.frugalmechanic.com.s3-us-west-2.amazonaws.com/snapshots
s3://maven.frugalmechanic.com.s3.amazonaws.com/snapshots
s3://s3.amazonaws.com/maven.frugalmechanic.com/snapshots

All of these forms should work:

s3://[BUCKET]/[OPTIONAL_PATH]
s3://s3.amazonaws.com/[BUCKET]/[OPTIONAL_PATH]
s3://[BUCKET].s3.amazonaws.com/[OPTIONAL_PATH]
s3://s3-[REGION].amazonaws.com/[BUCKET]/[OPTIONAL_PATH]
s3://[BUCKET].s3-[REGION].amazonaws.com/[OPTIONAL_PATH]

Usage

Add this to your project/plugins.sbt file:

addSbtPlugin("com.frugalmechanic" % "fm-sbt-s3-resolver" % "0.5.0")

S3 Credentials

S3 Credentials are checked in the following places and order:

Bucket Specific Environment Variables

AWS_ACCESS_KEY_ID_<BUCKET_NAME> -or- <BUCKET_NAME>_AWS_ACCESS_KEY_ID
AWS_SECRET_KEY_<BUCKET_NAME> -or- <BUCKET_NAME>_AWS_SECRET_KEY

NOTE - The following transforms are applied to the bucket name before looking up the environment variable:

  1. The name is upper-cased
  2. Dots (.) and dashes (-) are replaced with an underscore (_)
  3. Everything other than A-Z, 0-9, and underscores are removed.

Example:

The bucket name "maven.frugalmechanic.com" becomes "MAVEN_FRUGALMECHANIC_COM":

AWS_ACCESS_KEY_ID_MAVEN_FRUGALMECHANIC_COM="XXXXXX" AWS_SECRET_KEY_MAVEN_FRUGALMECHANIC_COM="XXXXXX" sbt

Bucket Specific Java System Properties

-Daws.accessKeyId.<bucket_name>=XXXXXX -Daws.secretKey.<bucket_name>=XXXXXX
-D<bucket_name>.aws.accessKeyId=XXXXXX -D<bucket_name>.aws.secretKey=XXXXXX

Example:

SBT_OPTS="-Daws.accessKeyId.maven.frugalmechanic.com=XXXXXX -Daws.secretKey.maven.frugalmechanic.com=XXXXXX" sbt

Bucket Specific Property Files

~/.sbt/.<bucket_name>_s3credentials
~/.sbt/.s3credentials_<bucket_name>

Environment Variables

AWS_ACCESS_KEY_ID (or AWS_ACCESS_KEY)
AWS_SECRET_KEY (or AWS_SECRET_ACCESS_KEY)

Example:

AWS_ACCESS_KEY_ID="XXXXXX" AWS_SECRET_KEY="XXXXXX" sbt

Java System Properties

-Daws.accessKeyId=XXXXXX -Daws.secretKey=XXXXXX 

Example:

SBT_OPTS="-Daws.accessKeyId=XXXXXX -Daws.secretKey=XXXXXX" sbt

Property File

~/.sbt/.s3credentials

The property files should have the following format:

accessKey = XXXXXXXXXX
secretKey = XXXXXXXXXX

IAM Policy Examples

I recommend that you create IAM Credentials for reading/writing your Maven S3 Bucket. Here are some examples for our maven.frugalmechanic.com bucket:

Read/Write Policy (for publishing)

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:GetBucketLocation"],
      "Resource": "arn:aws:s3:::*"
    },
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket"],
      "Resource": ["arn:aws:s3:::maven.frugalmechanic.com"]
    },
    {
      "Effect": "Allow",
      "Action": ["s3:DeleteObject","s3:GetObject","s3:PutObject"],
      "Resource": ["arn:aws:s3:::maven.frugalmechanic.com/*"]
    }
  ]
}

Read-Only Policy

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:GetBucketLocation"],
      "Resource": "arn:aws:s3:::*"
    },
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket"],
      "Resource": ["arn:aws:s3:::maven.frugalmechanic.com"]
    },
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject"],
      "Resource": ["arn:aws:s3:::maven.frugalmechanic.com/*"]
    }
  ]
}

Releases Read-Only, Snapshots Read/Write

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:GetBucketLocation"],
      "Resource": "arn:aws:s3:::*"
    },
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket"],
      "Resource": ["arn:aws:s3:::maven.frugalmechanic.com"]
    },
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject"],
      "Resource": ["arn:aws:s3:::maven.frugalmechanic.com/releases/*"]
    },
    {
      "Effect": "Allow",
      "Action": ["s3:DeleteObject","s3:GetObject","s3:PutObject"],
      "Resource": ["arn:aws:s3:::maven.frugalmechanic.com/snapshots/*"]
    }
  ]
}

Authors

Tim Underwood (GitHub, LinkedIn, Twitter, Google Plus)

Copyright

Copyright Frugal Mechanic

License

Apache License, Version 2.0

About

SBT Plugin that adds support for resolving and publishing using Amazon S3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 100.0%