The JVM SDK currently only supports legacy versions of Nitric prior to v1. This version is maintained for compatibility with existing projects and not recommended for new projects. New projects should be started using a supported SDK (presented automatically using the `nitric new` command) orget in touch to request an update to the latest version.
JVM - secret()
Creates a reference to a secret in the secrets manager.
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;
public class Application {
public static void main(String[] args) {
var secrets = Nitric.INSTANCE.secret("apiKey").with(SecretPermission.Access);
Nitric.INSTANCE.run();
}
}
Parameters
- Name
name
- Required
- Required
- Type
- String
- Description
The unique name of this secret within the secrets manager.
Access
All Nitric resources provide access permissions you can use to specify the level of access your code needs to the resource. See here for details Access Control documentation.
Available permissions:
SecretPermission.Put
This permission allows your code to set a new latest value for a secret.
SecretPermission.Access
This permission allows your code to retrieve secret values.
Examples
Create a reference to 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("apiKey").with(SecretPermission.Put);
Nitric.INSTANCE.run();
}
}