How to use AWS CodeCommit as repository for Spring

2019-09-08 15:31发布

问题:

I am trying to use AWS CodeCommit repository with spring cloud config. I have managed to get it working with SSH. But I would like to use https instead of SSH. AWS suggest to use credential helper. Does anyone know how can I configure spring config cloud to use credential helper? I have looked AWS CodeCommit HTTPS access without setting up credential helper But there is no answer yet and I was wondering if there is some way in spring cloud config to do it.

回答1:

I don't know if you have seen this answer yet, but this explains a little bit and the example with JGit works. AWS CodeCommit HTTPS access without setting up credential helper

Since Spring Cloud Config doesn't yet support adding custom Credential providers you need to implement your own EnvironmentRepository.

For a POC I overrode the JGitEnvironmentRepository, and had to copy almost all the code because what I really needed to override was a private method JGitEnvironmentRepository#setCredentialsProvider. That method is where I used the code from the example I provided above.

Spring Cloud Config uses an auto config to build their MultipleJGitEnvironmentRepository bean and it is annotated with @ConditionalOnMissingBean(EnvironmentRepository.class), so as long as you create a bean of that type you can override their behavior.

So with that said the SSH option is a lot cleaner until Spring expands their support for configuring custom Credential Providers or first class support for CodeCommit.

Open issue for AWS CodeCommit: https://github.com/spring-cloud/spring-cloud-config/issues/334



回答2:

Duplication of a similar question and solution is posted there. AWS CodeCommit HTTPS access without setting up credential helper