This SBT plugin adds support for using Amazon S3 for resolving and publishing using s3:// urls.
resolvers += "FrugalMechanic Snapshots" at "s3://maven.frugalmechanic.com/snapshots"
publishTo := Some("FrugalMechanic Snapshots" at "s3://maven.frugalmechanic.com/snapshots")
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]
addSbtPlugin("com.frugalmechanic" % "fm-sbt-s3-resolver" % "0.5.0")
S3 Credentials are checked in the following places and order:
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:
- The name is upper-cased
- Dots (.) and dashes (-) are replaced with an underscore (_)
- 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
-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
~/.sbt/.<bucket_name>_s3credentials
~/.sbt/.s3credentials_<bucket_name>
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
-Daws.accessKeyId=XXXXXX -Daws.secretKey=XXXXXX
Example:
SBT_OPTS="-Daws.accessKeyId=XXXXXX -Daws.secretKey=XXXXXX" sbt
~/.sbt/.s3credentials
The property files should have the following format:
accessKey = XXXXXXXXXX
secretKey = XXXXXXXXXX
I recommend that you create IAM Credentials for reading/writing your Maven S3 Bucket. Here are some examples for our maven.frugalmechanic.com bucket:
{ "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/*"] } ] }
{ "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/*"] } ] }
{ "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/*"] } ] }
Tim Underwood (GitHub, LinkedIn, Twitter, Google Plus)
Copyright Frugal Mechanic