Skip to content

Commit 11f862e

Browse files
docs: update secret manager documentation (#3534)
This PR explains the introduction of the `sm@` syntax
1 parent 0ff48fb commit 11f862e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

docs/src/main/asciidoc/secretmanager.adoc

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,31 @@ If set to `true`, `null` will be returned when accessing a non-existent secret;
5151
The Spring Framework on Google Cloud integration for Google Cloud Secret Manager enables you to use Secret Manager as an external config data resource.
5252
This allows you to specify and load secrets from Google Cloud Secret Manager as properties into the application context using https://spring.io/blog/2020/08/14/config-file-processing-in-spring-boot-2-4[Spring Boot's Config Data API].
5353

54+
**NOTE**: In `6.0.0`, we introduced a new syntax for secrets `sm@secret_id`. This new syntax is the recommended one and usage of the old
55+
`sm://secret_id` syntax will issue a warning discouraging its usage.
56+
5457
The Secret Manager config data resource uses the following syntax to specify secrets:
5558

5659
[source]
5760
----
5861
# 1. Long form - specify the project ID, secret ID, and version
59-
sm://projects/<project-id>/secrets/<secret-id>/versions/<version-id>}
62+
sm@projects/<project-id>/secrets/<secret-id>/versions/<version-id>}
6063
6164
# 2. Long form - specify project ID, secret ID, and use latest version
62-
sm://projects/<project-id>/secrets/<secret-id>
65+
sm@projects/<project-id>/secrets/<secret-id>
6366
6467
# 3. Short form - specify project ID, secret ID, and version
65-
sm://<project-id>/<secret-id>/<version-id>
68+
sm@<project-id>/<secret-id>/<version-id>
6669
6770
# 4. Short form - default project; specify secret + version
6871
#
6972
# The project is inferred from the spring.cloud.gcp.secretmanager.project-id setting
7073
# in your application.properties (see Configuration) or from application-default credentials if
7174
# this is not set.
72-
sm://<secret-id>/<version>
75+
sm@<secret-id>/<version>
7376
7477
# 5. Shortest form - specify secret ID, use default project and latest version.
75-
sm://<secret-id>
78+
sm@<secret-id>
7679
----
7780

7881
You can use this syntax in the following places:
@@ -82,8 +85,8 @@ You can use this syntax in the following places:
8285
[source]
8386
----
8487
# Example of the project-secret long-form syntax.
85-
spring.config.import=sm://
86-
spring.datasource.password=${sm://projects/my-gcp-project/secrets/my-secret}
88+
spring.config.import=sm@
89+
spring.datasource.password=${sm@projects/my-gcp-project/secrets/my-secret}
8790
----
8891
The former is used to enable https://spring.io/blog/2020/08/14/config-file-processing-in-spring-boot-2-4[Spring Boot's Config Data API].
8992

@@ -92,7 +95,7 @@ The former is used to enable https://spring.io/blog/2020/08/14/config-file-proce
9295
[source]
9396
----
9497
// Example of using shortest form syntax.
95-
@Value("${sm://my-secret}")
98+
@Value("${sm@my-secret}")
9699
----
97100

98101
=== Secret Manager Template
@@ -149,7 +152,7 @@ However, if your want to use a default value in such a scenario, you can add the
149152
`spring.cloud.gcp.secretmanager.allow-default-secret=true`
150153
----
151154

152-
Therefore, a variable annotated with `@Value("${${sm://application-fake}:DEFAULT}")` will be resolved as `DEFAULT` when there is no `application-fake` in Secret Manager and `application-fake` is NOT a valid application property.
155+
Therefore, a variable annotated with `@Value("${${sm@application-fake}:DEFAULT}")` will be resolved as `DEFAULT` when there is no `application-fake` in Secret Manager and `application-fake` is NOT a valid application property.
153156

154157
=== Sample
155158

0 commit comments

Comments
 (0)