Secret Manager Sample Application with Native Image
The Secret Manager sample application demonstrates some common operations with Google Cloud Secret Manager and is compatible with Native Image compilation.
This application will create a new secret named native-secretmanager-test-secret if it does not already exist.
It will then add a new version of the secret and then attempt to read it.
Setup Instructions
You will need to follow these prerequisite steps in order to run these samples:
-
If you have not already, create a Google Cloud Platform Project.
-
Install the Google Cloud SDK which will allow you to run the sample with your project's credentials.
Once installed, log in with Application Default Credentials using the following command:
gcloud auth application-default loginNote: Authenticating with Application Default Credentials is convenient to use during development, but we recommend alternate methods of authentication during production use.
-
Install the native image compiler.
You can follow the official installation instructions. After following the instructions, ensure that you install the Native Image extension installed by running:
Run with Native Image Compilation
Navigate to this directory in a new terminal.
-
Compile the application using the native image compiler. This step may take a few minutes.
mvn package -P native -DskipTests -
Run the application:
./target/native-image-sample -
The application runs through some basic Secret Manager operations (create, update, read) and then prints some results of the operations.
Created secret: projects/xxxxxx/secrets/graal-secretmanager-test-secret Added Secret Version: projects/xxxxxx/secrets/graal-secretmanager-test-secret/versions/1 Reading secret value: Hello World (Note: Don't print secret values in prod!)
Sample Integration test with Native Image Support
In order to run the sample integration test as a native image, call the following command: