title: How do I deploy jars to S3 with maven?
body: <p>I have a project that is using Maven to build and I need to publish it to a private S3 repository.</p>
  
  <p>I found <a href="https://github.com/spring-projects/aws-maven" rel="noreferrer">AWS Maven Wagon</a> but when I try to deploy I get an authentication error:</p>
  
  <pre><code>[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ custom-file-extension-windows-bundler ---
  Downloading from aws-snapshot: s3://project-x-support/maven2/de/dynamicfiles/projects/javafx/bundler/custom-file-extension-windows-bundler/1.0.1-SNAPSHOT/maven-metadata.xml
  Uploading to aws-snapshot: s3://project-x-support/maven2/de/dynamicfiles/projects/javafx/bundler/custom-file-extension-windows-bundler/1.0.1-SNAPSHOT/custom-file-extension-windows-bundler-1.0.1-20180119.133946-1.jar
  Uploading to aws-snapshot: s3://project-x-support/maven2/de/dynamicfiles/projects/javafx/bundler/custom-file-extension-windows-bundler/1.0.1-SNAPSHOT/custom-file-extension-windows-bundler-1.0.1-20180119.133946-1.pom
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 5.773 s
  [INFO] Finished at: 2018-01-19T13:39:46Z
  [INFO] Final Memory: 23M/254M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project custom-file-extension-windows-bundler: Failed to deploy artifacts: Could not transfer artifact de.dynamicfiles.projects.javafx.bundler:custom-file-extension-windows-bundler:jar:1.0.1-20180119.133946-1 from/to aws-snapshot (s3://project-x-su
  pport/maven2): Cannot write directory 'maven2/': Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: CE401778F4180C1E) -&gt; [Help 1]
  [ERROR]
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR]
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
  </code></pre>
  
  <p>I'm pretty sure the credentials and permissions are correct because I'm using them to deploy a jar with Gradle (I copied from .aws/credentials to .m2/settings.xml). My full <code>pom.xml</code> file looks like this:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;de.dynamicfiles.projects.javafx.bundler&lt;/groupId&gt;
      &lt;artifactId&gt;custom-file-extension-windows-bundler&lt;/artifactId&gt;
      &lt;version&gt;1.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;developers&gt;
          &lt;developer&gt;
              &lt;name&gt;Danny Althoff&lt;/name&gt;
              &lt;email&gt;fibrefox@dynamicfiles.de&lt;/email&gt;
              &lt;url&gt;https://www.dynamicfiles.de&lt;/url&gt;
          &lt;/developer&gt;
      &lt;/developers&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
  
          &lt;version.java.source&gt;1.8&lt;/version.java.source&gt;
          &lt;version.java.target&gt;1.8&lt;/version.java.target&gt;
      &lt;/properties&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.3&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;${version.java.source}&lt;/source&gt;
                      &lt;target&gt;${version.java.target}&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.0.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;archive&gt;
                          &lt;manifest&gt;
                              &lt;addDefaultImplementationEntries&gt;true&lt;/addDefaultImplementationEntries&gt;
                              &lt;addDefaultSpecificationEntries&gt;true&lt;/addDefaultSpecificationEntries&gt;
                          &lt;/manifest&gt;
                          &lt;manifestEntries&gt;
                              &lt;display_version&gt;${display_version}&lt;/display_version&gt;
                          &lt;/manifestEntries&gt;
                      &lt;/archive&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
          &lt;extensions&gt;
              &lt;extension&gt;
                  &lt;groupId&gt;org.springframework.build&lt;/groupId&gt;
                  &lt;artifactId&gt;aws-maven&lt;/artifactId&gt;
                  &lt;version&gt;5.0.0.RELEASE&lt;/version&gt;
              &lt;/extension&gt;
          &lt;/extensions&gt;
      &lt;/build&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javafx-packager&lt;/groupId&gt;
              &lt;artifactId&gt;javafx-packager&lt;/artifactId&gt;
              &lt;version&gt;1.8.0_40&lt;/version&gt;
              &lt;scope&gt;system&lt;/scope&gt;
              &lt;systemPath&gt;${java.home}/../lib/ant-javafx.jar&lt;/systemPath&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;distributionManagement&gt;
          &lt;repository&gt;
              &lt;id&gt;aws-release&lt;/id&gt;
              &lt;name&gt;AWS Release Repository&lt;/name&gt;
              &lt;url&gt;s3://project-x-support/maven2&lt;/url&gt;
          &lt;/repository&gt;
          &lt;snapshotRepository&gt;
              &lt;id&gt;aws-snapshot&lt;/id&gt;
              &lt;name&gt;AWS Snapshot Repository&lt;/name&gt;
              &lt;url&gt;s3://project-x-support/maven2&lt;/url&gt;
          &lt;/snapshotRepository&gt;
      &lt;/distributionManagement&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I've noticed that AWS Maven Wagon is quite old and using an obsolete authentication mechanism:</p>
  
  <ul>
  <li><a href="https://github.com/spring-projects/aws-maven/issues/48" rel="noreferrer">https://github.com/spring-projects/aws-maven/issues/48</a></li>
  <li><a href="https://github.com/spring-projects/aws-maven/issues/44" rel="noreferrer">https://github.com/spring-projects/aws-maven/issues/44</a></li>
  <li><a href="https://github.com/spring-projects/aws-maven/issues/50" rel="noreferrer">https://github.com/spring-projects/aws-maven/issues/50</a></li>
  </ul>
  
  <p>so, I also tried with:</p>
  
  <pre><code>&lt;groupId&gt;org.zalando.org.springframework.build&lt;/groupId&gt;
  &lt;artifactId&gt;aws-maven&lt;/artifactId&gt;
  &lt;version&gt;5.0.0.RELEASE-zal-2&lt;/version&gt;
  </code></pre>
  
  <p>but I get the same result.</p>
  
  <p>My credentials are configured in C:\Users\pupeno.m2\settings.xml and look like this:</p>
  
  <pre><code>&lt;settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"&gt;
    &lt;servers&gt;
      &lt;server&gt;
        &lt;id&gt;aws-release&lt;/id&gt;
        &lt;username&gt;BLAHBLAH&lt;/username&gt;
        &lt;password&gt;SECRETBLAHBLAH&lt;/password&gt;
      &lt;/server&gt;
      &lt;server&gt;
        &lt;id&gt;aws-snapshot&lt;/id&gt;
        &lt;username&gt;BLAHBLAH&lt;/username&gt;
        &lt;password&gt;SECRETBLAHBLAH&lt;/password&gt;
      &lt;/server&gt;
    &lt;/servers&gt;
  &lt;/settings&gt;
  </code></pre>
  
  <p>My relevant policies looks like this:</p>
  
  <pre><code>{
      "Version": "2012-10-17",
      "Statement": [
          {
              "Sid": "VisualEditor0",
              "Effect": "Allow",
              "Action": [
                  "s3:PutAnalyticsConfiguration",
                  "s3:GetObjectVersionTagging",
                  "s3:CreateBucket",
                  "s3:ReplicateObject",
                  "s3:GetObjectAcl",
                  "s3:DeleteBucketWebsite",
                  "s3:PutLifecycleConfiguration",
                  "s3:GetObjectVersionAcl",
                  "s3:PutObjectTagging",
                  "s3:DeleteObject",
                  "s3:GetIpConfiguration",
                  "s3:DeleteObjectTagging",
                  "s3:GetBucketWebsite",
                  "s3:PutReplicationConfiguration",
                  "s3:DeleteObjectVersionTagging",
                  "s3:GetBucketNotification",
                  "s3:PutBucketCORS",
                  "s3:GetReplicationConfiguration",
                  "s3:ListMultipartUploadParts",
                  "s3:PutObject",
                  "s3:GetObject",
                  "s3:PutBucketNotification",
                  "s3:PutBucketLogging",
                  "s3:GetAnalyticsConfiguration",
                  "s3:GetObjectVersionForReplication",
                  "s3:GetLifecycleConfiguration",
                  "s3:ListBucketByTags",
                  "s3:GetInventoryConfiguration",
                  "s3:GetBucketTagging",
                  "s3:PutAccelerateConfiguration",
                  "s3:DeleteObjectVersion",
                  "s3:GetBucketLogging",
                  "s3:ListBucketVersions",
                  "s3:ReplicateTags",
                  "s3:RestoreObject",
                  "s3:ListBucket",
                  "s3:GetAccelerateConfiguration",
                  "s3:GetBucketPolicy",
                  "s3:GetObjectVersionTorrent",
                  "s3:AbortMultipartUpload",
                  "s3:PutBucketTagging",
                  "s3:GetBucketRequestPayment",
                  "s3:GetObjectTagging",
                  "s3:GetMetricsConfiguration",
                  "s3:DeleteBucket",
                  "s3:PutBucketVersioning",
                  "s3:ListBucketMultipartUploads",
                  "s3:PutMetricsConfiguration",
                  "s3:PutObjectVersionTagging",
                  "s3:GetBucketVersioning",
                  "s3:GetBucketAcl",
                  "s3:PutInventoryConfiguration",
                  "s3:PutIpConfiguration",
                  "s3:GetObjectTorrent",
                  "s3:PutBucketWebsite",
                  "s3:PutBucketRequestPayment",
                  "s3:GetBucketCORS",
                  "s3:GetBucketLocation",
                  "s3:ReplicateDelete",
                  "s3:GetObjectVersion"
              ],
              "Resource": [
                  "arn:aws:s3:::project-x-support/*",
                  "arn:aws:s3:::project-x-support"
              ]
          },
          {
              "Sid": "VisualEditor1",
              "Effect": "Allow",
              "Action": [
                  "s3:ListAllMyBuckets",
                  "s3:HeadBucket",
                  "s3:ListObjects"
              ],
              "Resource": "*"
          }
      ]
  }
  {
      "Version": "2012-10-17",
      "Statement": [
          {
              "Sid": "VisualEditor0",
              "Effect": "Allow",
              "Action": "s3:GetBucketLocation",
              "Resource": "*"
          },
          {
              "Sid": "VisualEditor1",
              "Effect": "Allow",
              "Action": "s3:ListAllMyBuckets",
              "Resource": "*"
          }
      ]
  }
  </code></pre>