问题
I created a secret on the Secrets Manager console. Then I took tried using the Go code quickstart guide like
ctx := context.Background()
client, err := secretmanager.NewClient(ctx)
if err != nil {
log.Println(err)
}
// Build the request.
req := &secretmanagerpb.AccessSecretVersionRequest{
Name: "projects/my-project/secrets/API_KEY/versions/latest",
}
// Call the API.
result, err := client.AccessSecretVersion(ctx, req)
if err != nil {
log.Println(err)
}
but then I get
rpc error: code = PermissionDenied desc = Permission 'secretmanager.versions.access' denied for resource 'projects/my-project/secrets/API_KEY/versions/latest' (or it may not exist)
which makes sense because how does the secrets manager api even know that my code has admin privileges?
来源:https://stackoverflow.com/questions/61301133/how-do-you-get-secrets-from-gcps-secret-manager-in-a-local-environment