How do you get secrets from GCP's Secret Manager in a local environment?

青春壹個敷衍的年華 提交于 2020-05-30 08:00:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!