Skip to content

add optional session parameter to CodeInterpreter for custom credential management #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gonzalo123
Copy link

Add boto3.Session injection support to CodeInterpreter constructor to enable custom credential configurations and role assumption while maintaining full backward compatibility.

Features:

  • Optional session parameter in CodeInterpreter constructor
  • Support for pre-configured boto3 sessions with custom credentials
  • Enable AWS role assumption and cross-account access
  • Session reuse across multiple service clients
  • Full backward compatibility with existing implementations

Use Cases:

  • Dynamic role switching for multi-tenant applications
  • Custom credential configurations beyond environment variables
  • Cross-account resource access with assumed roles
  • Containerized environments with temporary credentials
  • Testing scenarios with mock sessions
  • Fine-grained credential management and security

Configuration:

  • Compatible with all existing CodeInterpreter functionality

Implementation:

  • Updated CodeInterpreter.init() to accept optional session parameter
  • Modified code_session() context manager to support session injection
  • Session validation and client creation logic preserved
  • Comprehensive test coverage for both default and custom session scenarios
  • Updated documentation with usage examples and best practices

Benefits:

  • Enhanced credential flexibility for enterprise applications
  • Improved security through controlled session management
  • Better testing capabilities with session mocking
  • Simplified multi-account and role-based access patterns
  • Maintains existing API contract and behavior

Breaking Changes: None

  • Default behavior remains identical to previous implementation
  • All existing code continues to work without modification
  • New functionality only active when session parameter is provided

CLOSES #40

…edential management

Add boto3.Session injection support to CodeInterpreter constructor to enable
custom credential configurations and role assumption while maintaining
full backward compatibility.

Features:
- Optional session parameter in CodeInterpreter constructor
- Support for pre-configured boto3 sessions with custom credentials
- Enable AWS role assumption and cross-account access
- Session reuse across multiple service clients
- Full backward compatibility with existing implementations

Use Cases:
- Dynamic role switching for multi-tenant applications
- Custom credential configurations beyond environment variables
- Cross-account resource access with assumed roles
- Containerized environments with temporary credentials
- Testing scenarios with mock sessions
- Fine-grained credential management and security

Configuration:
- Compatible with all existing CodeInterpreter functionality

Implementation:
- Updated CodeInterpreter.__init__() to accept optional session parameter
- Modified code_session() context manager to support session injection
- Session validation and client creation logic preserved
- Comprehensive test coverage for both default and custom session scenarios
- Updated documentation with usage examples and best practices

Benefits:
- Enhanced credential flexibility for enterprise applications
- Improved security through controlled session management
- Better testing capabilities with session mocking
- Simplified multi-account and role-based access patterns
- Maintains existing API contract and behavior

Breaking Changes: None
- Default behavior remains identical to previous implementation
- All existing code continues to work without modification
- New functionality only active when session parameter is provided

CLOSES aws#40
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.

Add optional session parameter to CodeInterpreter for custom credential management
1 participant