Yura Bysaha
Yura Bysaha

Reputation: 778

The best way to store GOOGLE_APPLICATION_CREDENTIALS json on AWS ECS

I have a GOOGLE_APPLICATION_CREDENTIALS json file for access to my bigquery.

Locally I set export GOOGLE_APPLICATION_CREDENTIALS=<path-to-file>.json and all works fine.

What about my server on AWS?

I use docker and ECS with Task Definition and all of my other env variables is setup when I create/update Task definition, but I cant store this json file there.

So ho can I access path to my GOOGLE_APPLICATION_CREDENTIALS json file on my server envs, where I should store it?

Upvotes: 2

Views: 649

Answers (1)

Yura Bysaha
Yura Bysaha

Reputation: 778

I can`t find any solution for this case yet. So, I found a way to read data from json stored in my env.

In my case:

credentials = service_account.Credentials.from_service_account_info(
    json.loads(os.environ.get('GOOGLE_APPLICATION_CREDENTIALS_JSON'))
)

client = bigquery.Client(credentials=credentials, project=credentials.project_id)

Maybe it can help someone.

Upvotes: 1

Related Questions