Score:0

GCP Secret Manager issue in accessing secrets

cn flag

Trying to access secrets from secret manager connecting from Local STS to GCP while creating client using SecretManagerServiceClient.create() I am getting NullPointerException. I have created service-account and given neccessary permissions to access and used service-account keys in for auth with env variable GOOOGLE_APPLICATION_CREDENTIALS, Please help.

public String getSecrets(String projectId, String secretId) {
    SecretManagerServiceClient smClient;
    Secret secret = null;
    String replication = "";
    try {
        System.out.printf("hello world", SecretManagerServiceClient.create()); // null printing
        smClient = SecretManagerServiceClient.create();
        System.out.printf("good evening", smClient);
        SecretName secretName = SecretName.of(projectId, secretId);
        secret = smClient.getSecret(secretName);
        if (secret.getReplication().getAutomatic() != null) {
            replication = "AUTOMATIC";
        } else if (secret.getReplication().getUserManaged() != null) {
            replication = "MANAGED";
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    System.out.printf("Secret is ", secret.getName(), replication);
    return secret.getName();
}
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.