quarkus-google-cloud-services icon indicating copy to clipboard operation
quarkus-google-cloud-services copied to clipboard

Secret Manager does not work with `@ConfigMapping`

Open marceloverdijk opened this issue 3 years ago • 5 comments
trafficstars

Having an application.properties file with:

%prod.my.username=${sm//MY_USERNAME}

Injecting it with @ConfigProperty it works:

@ApplicationScoped
public class MyHeadersFactory implements ClientHeadersFactory {

    @ConfigProperty(name = "my.username")
    Optional<String> username;

    ..

but using a @ConfigMapping like:

@ConfigMapping(prefix = "my")
public interface MyProperties {

    Optional<String> username();
}

@ApplicationScoped
public class MyHeadersFactory implements ClientHeadersFactory {

    @Inject
    MyProperties myProperties;

   ..

will cause the application not to be started in GCP environment.

The error is somewhat vague on GCP...:

[pid1-app] Exit 1 app (pid 12): /bin/sh -c exec serve /workspace/build/my-1.0.0-SNAPSHOT-runner.jar [session:HVT03PV]
[pid1] A process stopped unexpectedly: <nil> [session:HVT03PV]

Could it be that with @ConfigMapping it tries to "read" the properties to early? And with @ConfigProperty is more of lazy load? I'm wondering as I used Spring GCP before and for Secret Manager they have a special bootstrap.properties files and bootstrap property source: https://googlecloudplatform.github.io/spring-cloud-gcp/3.3.0/reference/html/index.html#secret-manager-property-source

For now I will just use @ConfigProperty(name = "my.username") as that works.

marceloverdijk avatar Aug 12 '22 18:08 marceloverdijk

Hi, Thanks for reporting, can you provide a small reproducer project ?

loicmathieu avatar Aug 16 '22 08:08 loicmathieu

And also confirm it work on dev mode and only fail on GCP. By the way, how do you launch it on GCP ? Which service is use to run it ?

loicmathieu avatar Aug 16 '22 08:08 loicmathieu

Hi,

It fails on Google AppEngine Standard. The application is uploaded using glcoud app deploy so the actual build is done using Google Cloud Build.

Locally I have no Google Secret Manager so not sure if I can try this in dev mode.

marceloverdijk avatar Aug 16 '22 12:08 marceloverdijk

OK, a small reproducer would be great.

loicmathieu avatar Aug 16 '22 12:08 loicmathieu

OK will do that after holidays... I've no access to dev laptop :-D

marceloverdijk avatar Aug 16 '22 12:08 marceloverdijk

@marceloverdijk did you had the time to creat a small reproducer ?

loicmathieu avatar Apr 18 '23 12:04 loicmathieu

I'm sorry Loic, I never did that. Don't have project currently that I can use for this. Probably better to close this issue, and re-open later if needed.

marceloverdijk avatar Apr 18 '23 12:04 marceloverdijk

OK, thanks for the feedback

loicmathieu avatar Apr 18 '23 12:04 loicmathieu