Skip to content

Commit

Permalink
Always pull latest access token
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-finley committed Mar 11, 2024
1 parent 2433093 commit cb7379e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_process_file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
entry_point: "run"
source_dir: "process_file"
memory_mb: 4096
secret_environment_variables: "MYSQL_CONFIG=projects/greg-finley/secrets/MYSQL_CONFIG/versions/latest,DROPBOX_ACCESS_TOKEN=projects/greg-finley/secrets/DROPBOX_ACCESS_TOKEN/versions/latest"
secret_environment_variables: "MYSQL_CONFIG=projects/greg-finley/secrets/MYSQL_CONFIG/versions/latest"
timeout: 540
event_trigger_type: "providers/cloud.pubsub/eventTypes/topic.publish"
event_trigger_resource: "projects/greg-finley/topics/dropbox-backup"
Expand Down
9 changes: 7 additions & 2 deletions process_file/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@

import dropbox
import mysql.connector
from google.cloud import storage
from google.cloud import secretmanager, storage

dbx = dropbox.Dropbox(os.getenv("DROPBOX_ACCESS_TOKEN"))
gcs_client = storage.Client()
gcs_bucket = gcs_client.get_bucket("greg-finley-dropbox-backup")
mysql_config_str = os.environ["MYSQL_CONFIG"]
mysql_config_dict = json.loads(mysql_config_str)
secret_client = secretmanager.SecretManagerServiceClient()
dropbox_access_token = secret_client.access_secret_version(
name="projects/greg-finley/secrets/DROPBOX_ACCESS_TOKEN/versions/latest"
).payload.data.decode("utf-8")
dbx = dropbox.Dropbox(dropbox_access_token)


mysql_connection = mysql.connector.connect(
host=mysql_config_dict["MYSQL_HOST"],
Expand Down

0 comments on commit cb7379e

Please sign in to comment.