Skip to content
Merged
7 changes: 6 additions & 1 deletion .github/workflows/python-eks-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ jobs:
RDS_MYSQL_CLUSTER_SECRETS, ${{env.RDS_MYSQL_CLUSTER_CREDENTIAL_SECRET_NAME}}
parse-json-secrets: true

- name: Convert RDS database credentials to base64
continue-on-error: true
run: |
echo "RDS_MYSQL_CLUSTER_SECRETS_PASSWORD_BASE64=$(echo -n '${{env.RDS_MYSQL_CLUSTER_SECRETS_PASSWORD}}' | base64)" >> $GITHUB_ENV
- name: Initiate Terraform
uses: ./.github/workflows/actions/execute_and_retry
with:
Expand Down Expand Up @@ -246,7 +251,7 @@ jobs:
-var='python_remote_app_image=${{ env.REMOTE_SAMPLE_APP_IMAGE_ARN }}' \
-var='rds_mysql_cluster_endpoint=${{env.RDS_MYSQL_CLUSTER_ENDPOINT}}' \
-var='rds_mysql_cluster_username=${{env.RDS_MYSQL_CLUSTER_SECRETS_USERNAME}}' \
-var='rds_mysql_cluster_password=${{env.RDS_MYSQL_CLUSTER_SECRETS_PASSWORD}}' \
-var='rds_mysql_cluster_password=${{env.RDS_MYSQL_CLUSTER_SECRETS_PASSWORD_BASE64}}' \
-var='rds_mysql_cluster_database=information_schema' \
-var='account_id=${{ env.ACCOUNT_ID }}' \
|| deployment_failed=$?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
## SPDX-License-Identifier: Apache-2.0
import logging
import os
import base64
import threading
import time

Expand Down Expand Up @@ -110,10 +111,14 @@ def get_xray_trace_id():

def mysql(request):
logger.info("mysql received")

encoded_password = os.environ["RDS_MYSQL_CLUSTER_PASSWORD"]
decoded_password = base64.b64decode(encoded_password).decode('utf-8')

try:
connection = pymysql.connect(host=os.environ["RDS_MYSQL_CLUSTER_ENDPOINT"],
user=os.environ["RDS_MYSQL_CLUSTER_USERNAME"],
password=os.environ["RDS_MYSQL_CLUSTER_PASSWORD"],
password=decoded_password,
database=os.environ["RDS_MYSQL_CLUSTER_DATABASE"])
with connection:
with connection.cursor() as cursor:
Expand Down