I trying out Google's Batch service and spinning up a compute engine vm for a small python script. I am executing this by referring to a pre-build docker image and would like to access the default application credentials within that docker instance. Though it seems I just cannot access the default application credentials.
Is there something I am doing wrong?
Here is my job.json:
{
"taskGroups": [
{
"taskSpec": {
"runnables": [
{
"container": {
"imageUri": "europe-west3-docker.pkg.dev/project-id/containers/service:v1"
}
}
]
}
}
],
"allocationPolicy": {
"serviceAccount": {
"email": "sa-test@some-project.iam.gserviceaccount.com"
}
},
"logsPolicy": {"destination": "CLOUD_LOGGING"}
}
Here is my Dockerfile:
FROM python:3.10
WORKDIR /app
ENV PATH $PATH:$HOME/.local/bin
COPY . .
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
ENTRYPOINT ["python", "main.py"]
And here my main.py file:
import google.auth
credentials, _ = google.auth.default()
print(f"Service account email: {credentials.service_account_email}")
prints: Service account email: default
I already tested accessing the GOOGLE_APPLICATION_CREDENTIALS environment inside the main.py file but it is not set. When manually setting it with a key.json file it works but this is something I am trying to avoid.