Skip to content

Commit

Permalink
add ability to create an aws config when configuring local client
Browse files Browse the repository at this point in the history
  • Loading branch information
safoinme committed Jan 4, 2024
1 parent 0e02dee commit 7452667
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import base64
import datetime
import json
import os
import re
from typing import Any, Dict, List, Optional, Tuple, cast

Expand Down Expand Up @@ -1371,6 +1372,21 @@ def _configure_local_client(
"aws_session_token"
] = credentials.token

aws_credentials_path = os.path.join(
users_home, ".aws", "credentials"
)

# Ensure the .aws directory exists
os.makedirs(os.path.dirname(aws_credentials_path), exist_ok=True)

# Ensure the credentials file exists
if not os.path.isfile(aws_credentials_path):
open(aws_credentials_path, "a").close()

# Set the appropriate permissions for the .aws directory and credentials file
os.chmod(os.path.dirname(aws_credentials_path), 0o700)
os.chmod(aws_credentials_path, 0o600)

common.rewrite_credentials_file(all_profiles, users_home)

logger.info(
Expand Down

0 comments on commit 7452667

Please sign in to comment.