Amazon Web Services S3 Maven Wagon Support

Standard Maven wagon support for s3:// urls

License

License

Categories

Categories

AWS Container PaaS Providers Maven Build Tools
GroupId

GroupId

org.springframework.build
ArtifactId

ArtifactId

aws-maven
Last Version

Last Version

5.0.0.RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

Amazon Web Services S3 Maven Wagon Support
Standard Maven wagon support for s3:// urls
Project URL

Project URL

https://github.com/spring-projects/aws-maven
Project Organization

Project Organization

Spring Framework
Source Code Management

Source Code Management

https://github.com/spring-projects/aws-maven

Download aws-maven

How to add to project

<!-- https://jarcasting.com/artifacts/org.springframework.build/aws-maven/ -->
<dependency>
    <groupId>org.springframework.build</groupId>
    <artifactId>aws-maven</artifactId>
    <version>5.0.0.RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/org.springframework.build/aws-maven/
implementation 'org.springframework.build:aws-maven:5.0.0.RELEASE'
// https://jarcasting.com/artifacts/org.springframework.build/aws-maven/
implementation ("org.springframework.build:aws-maven:5.0.0.RELEASE")
'org.springframework.build:aws-maven:jar:5.0.0.RELEASE'
<dependency org="org.springframework.build" name="aws-maven" rev="5.0.0.RELEASE">
  <artifact name="aws-maven" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.springframework.build', module='aws-maven', version='5.0.0.RELEASE')
)
libraryDependencies += "org.springframework.build" % "aws-maven" % "5.0.0.RELEASE"
[org.springframework.build/aws-maven "5.0.0.RELEASE"]

Dependencies

compile (4)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.1.1
com.amazonaws : aws-java-sdk jar 1.7.1
org.slf4j : jcl-over-slf4j jar 1.7.6
org.slf4j : slf4j-api jar 1.7.6

provided (1)

Group / Artifact Type Version
org.apache.maven.wagon : wagon-provider-api jar 2.6

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.mockito : mockito-core jar 1.9.5

Project Modules

There are no modules declared in this project.

AWS Maven Wagon

This project is a Maven Wagon for Amazon S3. In order to to publish artifacts to an S3 bucket, the user (as identified by their access key) must be listed as an owner on the bucket.

Usage

To publish Maven artifacts to S3 a build extension must be defined in a project's pom.xml. The latest version of the wagon can be found on the aws-maven page in Maven Central.

<project>
  ...
  <build>
    ...
    <extensions>
      ...
      <extension>
        <groupId>org.springframework.build</groupId>
        <artifactId>aws-maven</artifactId>
        <version>5.0.0.RELEASE</version>
      </extension>
      ...
    </extensions>
    ...
  </build>
  ...
</project>

Once the build extension is configured distribution management repositories can be defined in the pom.xml with an s3:// scheme.

<project>
  ...
  <distributionManagement>
    <repository>
      <id>aws-release</id>
      <name>AWS Release Repository</name>
      <url>s3://<BUCKET>/release</url>
    </repository>
    <snapshotRepository>
      <id>aws-snapshot</id>
      <name>AWS Snapshot Repository</name>
      <url>s3://<BUCKET>/snapshot</url>
    </snapshotRepository>
  </distributionManagement>
  ...
</project>

Finally the ~/.m2/settings.xml must be updated to include access and secret keys for the account. The access key should be used to populate the username element, and the secret access key should be used to populate the password element.

<settings>
  ...
  <servers>
    ...
    <server>
      <id>aws-release</id>
      <username>0123456789ABCDEFGHIJ</username>
      <password>0123456789abcdefghijklmnopqrstuvwxyzABCD</password>
    </server>
    <server>
      <id>aws-snapshot</id>
      <username>0123456789ABCDEFGHIJ</username>
      <password>0123456789abcdefghijklmnopqrstuvwxyzABCD</password>
    </server>
    ...
  </servers>
  ...
</settings>

Alternatively, the access and secret keys for the account can be provided using

Making Artifacts Public

This wagon doesn't set an explict ACL for each artfact that is uploaded. Instead you should create an AWS Bucket Policy to set permissions on objects. A bucket policy can be set in the AWS Console and can be generated using the AWS Policy Generator.

In order to make the contents of a bucket public you need to add statements with the following details to your policy:

Effect Principal Action Amazon Resource Name (ARN)
Allow * ListBucket arn:aws:s3:::<BUCKET>
Allow * GetObject arn:aws:s3:::<BUCKET>/*

If your policy is setup properly it should look something like:

{
  "Id": "Policy1397027253868",
  "Statement": [
    {
      "Sid": "Stmt1397027243665",
      "Action": [
        "s3:ListBucket"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::<BUCKET>",
      "Principal": {
        "AWS": [
          "*"
        ]
      }
    },
    {
      "Sid": "Stmt1397027177153",
      "Action": [
        "s3:GetObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::<BUCKET>/*",
      "Principal": {
        "AWS": [
          "*"
        ]
      }
    }
  ]
}

If you prefer to use the command line, you can use the following script to make the contents of a bucket public:

BUCKET=<BUCKET>
TIMESTAMP=$(date +%Y%m%d%H%M)
POLICY=$(cat<<EOF
{
  "Id": "public-read-policy-$TIMESTAMP",
  "Statement": [
    {
      "Sid": "list-bucket-$TIMESTAMP",
      "Action": [
        "s3:ListBucket"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::$BUCKET",
      "Principal": {
        "AWS": [
          "*"
        ]
      }
    },
    {
      "Sid": "get-object-$TIMESTAMP",
      "Action": [
        "s3:GetObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::$BUCKET/*",
      "Principal": {
        "AWS": [
          "*"
        ]
      }
    }
  ]
}
EOF
)

aws s3api put-bucket-policy --bucket $BUCKET --policy "$POLICY"
org.springframework.build

Spring

Versions

Version
5.0.0.RELEASE
4.8.0.RELEASE
4.7.0.RELEASE
4.6.0.RELEASE
4.4.0.RELEASE