Skip to content
Advertisement

Why do I get `secretmanager.versions.access` denied in GCP?

I am trying to access a secret stored in secrets manager.

I created a service account with owner role. I created a key from it. I run:

JavaScript

but I get:

JavaScript

I checked the secret_name was the same as the secret’s value in secret manager.

I have tried adding Secret Manager Secret Accessor and Secret Manager Viewer roles.

Edit: running this from cloud shell.

Advertisement

Answer

I think the issue is that the code is taking the Default Credentials of the Cloud Shell instead of using your SA key.

You can specify the credentials when creating the client

JavaScript

Another option using some of the methods found in the library docs:

JavaScript

Just as an advice, being newbie does not mean you cannot Google a little more to search for something like how to use a SA as credential for the client of the library you’re using.

For example you could easily find this doc which shows a sample.

Anyway, good luck with GCP!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement