Spring Cloud config authentication with AWS Code Commit - java

I'm novice to use spring cloud config server, so is first time for me and i hope i can receive help, thanks in advance for this.
What i can try to do is to configure Spring cloud Configuration Server as central server for configurations among all Microservices.
We are using AWS CodeCommit as SCM repository.
The problem is that i receive always the same error once i try to inve an existing file on AWS CC.
I suppose is a problem of authentication, but i'm not sure
Error screenshot
This is the bootstrap configuration on Spring CSC
server.port=9090
management.security.enabled=false
logging.level.org.springframework.web: TRACE
spring.application.name=config-service
spring.cloud.config.server.git.uri: https://git-codecommit.eu-west-1.amazonaws.com/v1/repos/ServiceLayer
This is the file in my SCM repository that i'm trying to call:
configuration:
projectName: ms-login
server:
port: 8000
message:
greeting: Hello from the configuration
I've make a several try:
Placed the AWS GIT Credential (NOT the AWS Secret key) in bootstrap properties, but without result. Example:
spring.cloud.config.server.git.username: sergio.greco-at-682088819034
spring.cloud.config.server.git.password: xxxxxxx
Placed the AWS Secret Key \ Identity ID as java parameter once start, as follow:
-Daws.accessKeyId=xxxxxxxxYNOA -Daws.secretKey=xxxxxxxxxxxxxxxx
Set environment variables AWS_ACCESS_KEY_ID \ AWS_SECRET_ACCESS_KEY.
Can someone help me?

You need has the AWS SDK in the classpath.
Relevant documentation on this: http://cloud.spring.io/spring-cloud-static/spring-cloud-config/1.3.1.RELEASE/
Search for “Authentication with AWS CodeCommit”.
Note: The aws-java-sdk-core jar is an optional dependency. If the aws-java-sdk-core jar is not on your classpath, then the AWS Code Commit credential provider will not be created regardless of the git server URI.

Related

Quarkus Consul Config: how to inject application.yaml file from Consul Agent?

I am using Quarkus inside a microservice Java application.
I recently started to migrate from Spring Boot to Quarkus itself.
I am having some trouble while migrating "Spring Cloud Consul" to "Quarkus Consul Config". In order to be more specific, I am getting the following error:
java.lang.RuntimeException: Key 'my/consul/path/application.yaml' not found in Consul
at io.quarkus.consul.config.runtime.ConsulConfigSourceProvider$1.accept(ConsulConfigSourceProvider.java:66)
at io.quarkus.consul.config.runtime.ConsulConfigSourceProvider$1.accept(ConsulConfigSourceProvider.java:56)
at io.smallrye.context.impl.wrappers.SlowContextualConsumer.accept(SlowContextualConsumer.java:21)
at io.smallrye.mutiny.operators.uni.UniOnItemConsume$UniOnItemComsumeProcessor.invokeEventHandler(UniOnItemConsume.java:77)
at io.smallrye.mutiny.operators.uni.UniOnItemConsume$UniOnItemComsumeProcessor.onItem(UniOnItemConsume.java:42)
at io.smallrye.mutiny.operators.uni.UniOnItemTransform$UniOnItemTransformProcessor.onItem(UniOnItemTransform.java:43)
at io.smallrye.mutiny.vertx.AsyncResultUni.lambda$subscribe$1(AsyncResultUni.java:35)
(...)
Inside my Consul instance, the key my/consul/path/application.yaml corresponds to an application.yaml external file that I would like to import from there during the startup phase.
Below you can find my consul config (application.yaml):
quarkus:
application:
name: myapplication
consul-config:
enabled: true
properties-value-keys: my/consul/path/application.yaml
agent:
host-port: http://localhost:9500
prefix: myappprefix
If I try to switch from properties-value-keys to properties-raw-value-keys, I see that my property is not being injected inside my application context:
#ConfigProperty(name = "consultest")
String test;
java.util.NoSuchElementException: SRCFG00014: The config property consultest is required but it could not be found in any config source
Below you can find the application.yaml content (located on Consul):
consultest: testtest
The intent, here, is to delegate application.yaml properties to Consul, divided by environment (dev, test, prod).
I would like to threat my local application.yaml file (located in src/main/resources) as a bootstrap.yaml file, similarly to Spring Boot approach.
How could this be done with Quarkus? Thank you a lot for your support.

Spring Config-server throwing 404 on config file only from my git repository

I've been following this microservices tutorial and launching the config server with these properties:
spring.application.name=configuration-server
server.port=8888
spring.cloud.config.server.git.uri=https://github.com/sylleryum/microservices-config-server
spring.cloud.config.server.git.clone-on-start=true
the config server runs fine, but when trying to access it through http://localhost:8888/order-service/default i get a 404.
if i change the spring.cloud.config.server.git.uri to https://github.com/SaiUpadhyayula/microservices-config-server which has exactly the same files, it works.
found out, apparently the config files have to be on master branch

Setting GCP environment variable in Spring boot with vs code

I'm trying to set up GOOGLE_APPLICATION_CREDENTIALS but keep getting this error
java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credential
I have defined in my application properties:
spring.cloud.gcp.project-id=PROJECT_ID
spring.cloud.gcp.credentials.location=lasspath:/src/main/resources/key.json
Added the dependency in the pom file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-dialogflow</artifactId>
<version>1.0.0</version>
</dependency>
Tried to do it from the terminal(windows) as well no luck:
> set GOOGLE_APPLICATION_CREDENTIALS="C:\Users\user\Desktop\****\******\src\main\resources\key.json"
If you have Google Cloud SDK installed you can run this command in the console to set up application default credentials:
gcloud auth application-default login
Please, see more details in the documentation:
https://cloud.google.com/sdk/gcloud/reference/auth/application-default
Solved by running in the terminal:
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\Users\user\Desktop\*****\****\src\main\resources\*****.json"
In addition to setting the relevant role in IAM section of GCP since I've encountered a PERMISSION_DENIED Error after

Accessing Jenkins build version in code

Using the spring-boot-actuator, I can access my project's current build version when I enter the uri myApp:8080/.../env. Env is a spring actuator endpoint.
This uri, returns, among other data, my current build version -- info.build.version_component":"1.0.101".
I want to have access to the build version in my code for logging purposes. Is there a way I can access this data coming from the env endpoint and print it in my code?

Using Nexus as feature repository

Is there a way to add a secured Nexus repository as feature repository to Apache Karaf?
I tried to run the command:
karaf#root()> feature:repo-add http://<user>:<password>#<my-repository>
But I get the following error:
Adding feature url http://<user>:<password>#<my-repository> Error executing command: Server returned HTTP response code: 401 for URL: http://<user>:<password>#<my-repository>
I'm using Apache Karaf 3.0.0.
Thanks,
Mickael
The solution is simple.
Install Maven on the server on which Karaf is running and configure it. Generally, you will configure it through the file settings.xml present in ~/.m2. The credentials for accessing the Nexus repository are indicated in the file.
Finally, instead of using an HTTP URL for referencing your feature, use a Maven URL of the form:
mvn:<groupId>/<artifactId>/<version>/xml/features
The feature will be resolved through Maven.
You can add your own Maven repository to org.ops4j.pax.url.mvn.repositories.
config:edit org.ops4j.pax.url.mvn
config:property-set org.ops4j.pax.url.mvn.repositories http://your.nexus.repo/here
config:update

Categories

Resources