Skip to content

Refactor AWS session creation with profile support#53

Open
alberttwong wants to merge 4 commits into
Redislabs-Solution-Architects:mainfrom
alberttwong:main
Open

Refactor AWS session creation with profile support#53
alberttwong wants to merge 4 commits into
Redislabs-Solution-Architects:mainfrom
alberttwong:main

Conversation

@alberttwong

@alberttwong alberttwong commented Mar 30, 2026

Copy link
Copy Markdown

Restored direct AWS credential authentication from config.ini in ecstats.py (line 474). process_aws_account() now passes aws_access_key_id and aws_secret_access_key into boto3.Session(...) when those settings are present, includes aws_session_token if provided, and otherwise falls back to profile_name or the default credential chain.

Added regression coverage in test_ecstats.py (line 480) for both cases:

verifies direct access keys from config are forwarded into boto3.Session
verifies direct access keys take precedence over profile_name when both are configured
Validation:

./.env/bin/python -m pytest test_ecstats.py -q passed with 15 passed
Existing datetime.utcnow() deprecation warnings remain unchanged and are unrelated to this fix

Refactor AWS session creation with profile support
Add mock STS client to test cases for AWS services.
Comment thread ecstats.py
identity = sts.get_caller_identity()
print(f"Using AWS identity: {identity['Arn']}")

print(f"Requesting information for the {section} nodes")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is duplicated down below

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alberttwong Can you remove this duplicate log?

Comment thread ecstats.py
aws_session_token = None

# Create session with credentials
session = boto3.Session(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this remove the ability to authenticate using access keys directly?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had codex add this back in.

@alberttwong alberttwong requested a review from ajGingrich April 21, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants