Skip to content

Commit

Permalink
properly write mulesoft creds [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
floptical committed Jul 5, 2024
1 parent 625e35c commit 7402c7e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions write-secrets-to-env.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@
access_key_id = aws_creds["Citygeo AWS Key Pair PROD"]['access_key']
secret_access_key = aws_creds["Citygeo AWS Key Pair PROD"]['secret_key']

home = expanduser("~")
aws_creds = cgs.get_secrets('Mulesoft AWS Key Pair PROD')
ms_access_key_id = aws_creds["Mulesoft AWS Key Pair PROD"]['login']
ms_secret_access_key = aws_creds["Mulesoft AWS Key Pair PROD"]['password']

filename = os.path.join(home, '.aws/credentials')
with open(filename, 'r') as file:
lines = file.readlines()
home = expanduser("~")

new_lines = []
for line in lines:
if line.startswith('aws_access_key_id'):
new_lines.append(f'aws_access_key_id = {access_key_id}\n')
elif line.startswith('aws_secret_access_key'):
new_lines.append(f'aws_secret_access_key = {secret_access_key}\n')
else:
new_lines.append(line)
aws_credentials_path = os.path.join(home, '.aws/credentials')

with open(filename, 'w') as file:
file.writelines(new_lines)
# Open the file in write mode ('w') to ensure it will be overwritten if it exists
with open(aws_credentials_path, 'w') as file:
file.write(f"[default]\n")
file.write(f"aws_access_key_id = {access_key_id}\n")
file.write(f"aws_secret_access_key = {secret_access_key}\n")
file.write(f"[mulesoft]\n")
file.write(f"aws_access_key_id = {ms_access_key_id}\n")
file.write(f"aws_secret_access_key = {ms_secret_access_key}\n")

print("AWS credentials file created and overwritten successfully.")

0 comments on commit 7402c7e

Please sign in to comment.