Using S3 as Maven repository
Amazon S3 seems to be a good candidate for keeping private Maven artifacts. You can have , both, private and public repositories, saving you from the trouble of maintaining any other maven repository server like nexus, artifactory etc. For Private artifacts, you might want to deploy your Jar or war files on the server and make sure that they are visible only to your team. I am a big fan of nexus but due to some other requirements, I needed to setup S3 as maven repository. Here are some steps that I have taken to accomplish the same.
Create an S3 bucket for a component with 2 folders in it , with say bucket name as repo.component1 and two folders in it for release and snapshot. If you prefer this to be a public repository, then make these two folders as publicly accessible. Or else move to the next step.
If we want to have a private repository then you need to create a user in IAM say; repoMaster with having read, write access on the s3 bucket that we created before. We should be setting the policy for read, write on that particular bucket for this user.
Your policy should be like:
Now we can go on to the development side. In the main pom.xml just add the s3 bucket under the repository tag inside distribution management as shown below:
<name>Release Repository for Component1</name>
<name>Snapshot Repository for Component1</name>
<name>S3 Release Repository for component1</name>
Additionally, you should also add the plugin in pom.xml
So now, if we build on aws EC2 machine and it has an IAM user assigned with authority to connect with s3 bucket , then it should start working now. Incase, you are running it on your local machine and want to test the artifact upload with this s3, then you have to set the password in the setting.xml. This usually resides in the <user_home>/.m2 folder. In this setting.xml you should define the server and its credentials,. In our case we have to provide the s3 credential. Which should look something like this:
Now you can test with mvn deploy and it should work.