JVM - secret.version.access()

Retrieves the value from a version of a secret.

import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;
public class Application {
public static void main(String[] args) {
var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);
var contents = secrets.latest().access();
System.out.println(contents.toString());
Nitric.INSTANCE.run();
}
}

Examples

Access the latest version of a secret

import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;
public class Application {
public static void main(String[] args) {
var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);
var contents = secrets.latest().access();
System.out.println(contents.toString());
Nitric.INSTANCE.run();
}
}

Access a specific version of a secret

import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;
public class Application {
public static void main(String[] args) {
var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);
var contents = secrets.version("the-version-id").access();
System.out.println(contents.toString());
Nitric.INSTANCE.run();
}
}
Last updated on Dec 5, 2024