Reputation: 171
I am using Google Cloud Secret Manager in Jupyterlab notebooks in GCP AI Platform notebooks. I am able to access secrets as excepted but my code is printing out a lot of DEBUG lines related to the authentication.
Here is my code:
from google.cloud import secretmanager
PROJECT_ID = "<PROJECT_ID >"
def access_secret_version(secret_id, version_id="latest"):
# Create the Secret Manager client.
client = secretmanager.SecretManagerServiceClient()
# Build the resource name of the secret version.
name = f"projects/{PROJECT_ID}/secrets/{secret_id}/versions/{version_id}"
# Access the secret version.
response = client.access_secret_version(name=name)
# Return the decoded payload.
return response.payload.data.decode('UTF-8')
# Get my secret
mySecret= access_secret_version('mySecret')
Here is the log when running my code (IP address and service account has been changed):
DEBUG:google.auth._default:Checking None for explicit credentials as part of auth process...
DEBUG:google.auth._default:Checking Cloud SDK credentials as part of auth process...
DEBUG:google.auth._default:Cloud SDK credentials not found on disk; not using them
DEBUG:google.auth._default:Checking for App Engine runtime as part of auth process...
DEBUG:google.auth._default:No App Engine library was found so cannot authentication via App Engine Identity Credentials.
DEBUG:google.auth.transport._http_client:Making request: GET http://111.222.333.444
DEBUG:google.auth.transport._http_client:Making request: GET http://metadata.google.internal/computeMetadata/v1/project/project-id
DEBUG:google.auth.transport.requests:Making request: GET http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/?recursive=true
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): metadata.google.internal:80
DEBUG:urllib3.connectionpool:http://metadata.google.internal:80 "GET /computeMetadata/v1/instance/service-accounts/default/?recursive=true HTTP/1.1" 200 193
DEBUG:google.auth.transport.requests:Making request: GET http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/[email protected]/token
DEBUG:urllib3.connectionpool:http://metadata.google.internal:80 "GET /computeMetadata/v1/instance/service-accounts/[email protected]/token HTTP/1.1" 200 260
I have tried both to set compute engine service account explicitly in the terminal and as an environment variable in the script using the service accounts JSON file.
What is the reason the Debug code is being printed, and how do I get it to go away?
Upvotes: 0
Views: 1431
Reputation: 171
Found the reason:
I had set the debugging level to debug for my script:
logging.basicConfig(level=logging.debug)
Upvotes: 1