Search code examples
kubernetesgoogle-kubernetes-enginegcloudgsutil

How can i authenticate to the bucket using hmac keys via command line


Need to move from use of minio client to a docker image having gcloud/gsutil and mysql images.

What i have currently:

  1. /tmp/mc alias set gcs1 https://storage.googleapis.com $ACCESS_KEY $SECRET_KEY
  2. mysqldump --skip-lock-tables --triggers --routines --events --set-gtid-purged=OFF --single-transaction --host=$PXC_SERVICE -u root --all-databases | /tmp/mc pipe gcs1/mysql-test-dr/mdmpdb10.sql

What i need to change to: 3. <something similar to line no.1 (authorization)> 4. mysqldump --skip-lock-tables --triggers --routines --events --set-gtid-purged=OFF --single-transaction --host=$PXC_SERVICE -u root --all-databases --skip-add-locks > $FILE_NAME && gsutil cp $FILE_NAME gs://$BUCKET_NAME/$FILE_NAME

Is there any replacement in gcloud/gsutil for the line no.1? I was able to find gcloud auth activate-service-account [ACCOUNT] --key-file=[KEY_FILE] But that would be the service account key. I need to authenticate to the bucket using hmac keys.


Solution

  • You'll need to generate a boto configuration file using gsutil config -a. If you also have gcloud auth credentials configured, you may have to tell gcloud to not pass those (non-HMAC) credentials to gsutil, as gsutil may not allow you to have multiple credential types active at once. You can do this by running this gcloud command:

    gcloud config set pass_credentials_to_gsutil false
    

    This is all mentioned in the gsutil config docs page:
    https://cloud.google.com/storage/docs/gsutil/commands/config