Search code examples
google-cloud-platformgcloudgoogle-iam

Unable to create key file for iam account GCP using gcloud


I am trying to create a key file for a service account on GCP with gcloud

gcloud iam service-accounts keys create ~/.config/gcloud/key.json \
--iam-account terraform@$myproject.iam.gserviceaccount.com

Unfortunately, it responds

(gcloud) Unable to create private file [~/.config/gcloud/key.json]: [Errno 2] No such file or directory: '~/.config/gcloud/key.json'

The folder

 '~/.config/gcloud/'

exists.


Solution

  • the problem is:

    '~/.config/gcloud/'
    

    this should be

    '/home/mike/.config/gcloud/'
    

    as John Hanley correctly pointed out.