MuddyRumbles
MuddyRumbles
RRunPod
Created by sallok00 on 5/7/2024 in #⚡|serverless
How to authenticate with Google Cloud in a Docker container running Serverless?
@sallok00 Let me know if this helps
28 replies
RRunPod
Created by sallok00 on 5/7/2024 in #⚡|serverless
How to authenticate with Google Cloud in a Docker container running Serverless?
This code snippet might help. Its easy to accomplish in any language. Could be done in straight bash easily.
28 replies
RRunPod
Created by sallok00 on 5/7/2024 in #⚡|serverless
How to authenticate with Google Cloud in a Docker container running Serverless?
def get_service_account_credentials(file="service-account.json"):
"""Get service account from base64 encoded environment variable, if a local file is not found"""
if os.path.exists(file):
# This local file will be used by the google client library
logger.info("Local service account file found, using it for authentication.")
return
else:
# Get the service account from the base64 encoded environment variable
encoded_service_account = os.environ.get("SERVICE_ACCOUNT_JSON", None)
if encoded_service_account is None:
raise ValueError("SERVICE_ACCOUNT_JSON environment variable not set")
else:
# Write the service account to the local file for use by the google client library
logger.info("Writing service account to local file for authentication.")
with open(file, "w") as f:
f.write(base64.b64decode(encoded_service_account).decode("utf-8"))
def get_service_account_credentials(file="service-account.json"):
"""Get service account from base64 encoded environment variable, if a local file is not found"""
if os.path.exists(file):
# This local file will be used by the google client library
logger.info("Local service account file found, using it for authentication.")
return
else:
# Get the service account from the base64 encoded environment variable
encoded_service_account = os.environ.get("SERVICE_ACCOUNT_JSON", None)
if encoded_service_account is None:
raise ValueError("SERVICE_ACCOUNT_JSON environment variable not set")
else:
# Write the service account to the local file for use by the google client library
logger.info("Writing service account to local file for authentication.")
with open(file, "w") as f:
f.write(base64.b64decode(encoded_service_account).decode("utf-8"))
28 replies
RRunPod
Created by sallok00 on 5/7/2024 in #⚡|serverless
How to authenticate with Google Cloud in a Docker container running Serverless?
I save a base64 encoded json credentials file (ala service-account.json) in a secret (previously env var). I opened a ticket a while back to have the limit increased to support my use case. You can look for and decode the file in your entrypoint. If you have questions or anything please @ me because I start work soon and might not see your messages.
28 replies
RRunPod
Created by MuddyRumbles on 2/7/2024 in #⛅|pods
Secrets character limit & validation
Ok. Thanks!
5 replies