GCP secret manager returns connections string itself, how can I have it return my secret?

379 Views Asked by At

I have a secret on GCP, namely greeting with the secret-value being "Hello". When in my application I have the following code.

@Value("${sm://projects/221608087928/secrets/greeting}")
private String databasePassword;

@RequestMapping(value ="/test-user")
public String getUser()
      return this.databasePassword;
}

I have the value (projects/221608087928/secrets/greeting) by running the following command.

gcloud secrets describe "$secret_name"| grep name

I would assume my browser returning "Hello". However it returns "//projects/221608087928/secrets/greeting". I have the gcp-secret-manager dependency installed in my POM. How can I have the following code return the secret-value?

1

There are 1 best solutions below

0
On

Solved by updating dependency from

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
            <version>1.2.2.RELEASE</version>
        </dependency>

to

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
            <version>1.2.3.BUILD-SNAPSHOT</version>
        </dependency>