My workaround is to put the settings.xml file in the S3 bucket, limited to my CodeBuild role. Then in my buildspec.yaml file add the following:
phases: build: commands: - aws s3 cp s3://MY_SECURE_BUCKET/settings.xml ~/.m2/settings.xml - ls -lhr ~/.m2/settings.xml - mvn -s ~/.m2/settings.xml package
The CodeBuild user has no problem capturing the settings.xml file from S3 using the IAM container role, and the settings.xml file contains the AWS key / secret for a user who has access only to S3 maven repo:
<server> <id>s3repo</id> <username>MYKEY</username> <password>MYSECRET</password> </server>
And then I use the maven-s3-wagon plugin and declare <repository> with <id>s3repo</id> , and my maven settings are fine.
This solution includes an additional step in the assembly, creating an additional IAM user with maven-repo-only (although you may already have one) and saving the additional file in S3; but it works great and seems safe. But if someone can find a way to get the maven repo out of S3 using IAM container loans, send another solution.
Neil
source share