I created a service account for a specific role by going through the steps mentioned here.
https://cloud.google.com/iam/docs/creating-managing-service-accounts
https://cloud.google.com/iam/docs/creating-managing-service-account-keys
after generating the keys in json file when i am trying to authenticate with credentials using gcloud using
gcloud auth activate-service-account ACCOUNT --key-file=KEY-FILE
ERROR: (gcloud.auth.activate-service-account) Unable to read file [#path of file#]: [Errno 2] No such file or directory: 'filename.json'
As per your question the key file basically is the service account key file that we have downloaded and in the command gcloud auth activate-service-account ACCOUNT --key-file=KEY-FILE we need to give the path of the json keyfile .
I faced this same issue ,so I created the json keys through gcloud .
steps-
gcloud iam service-accounts keys create OUTPUT-FILE --iam-account=IAM_ACCOUNT [--key-file-type=KEY_FILE_TYPE; default="json"] [GCLOUD_WIDE_FLAG …]
example-
gcloud iam service-accounts keys create key.json [email protected]
gcloud auth activate-service-account ACCOUNT --key-file=KEY-FILE
Give the service account email that you have created in Account and the key we generated using gcloud command
example-
gcloud auth activate-service-account [service-account-name-]@[projectID].iam.gserviceaccount.com --key-file=key.json
i am attaching public docs links for reference.