awslabs / awslabs/agentcore-samples
Confusing way of initiating boto sessions
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 1.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 30
Description
https://github.com/awslabs/amazon-bedrock-agentcore-samples/blame/86139a1bb70117c5fd66eca11b423e2119a1ac16/03-integrations/IDP-examples/EntraID/Step_by_Step_Entra_ID_for_Inbound_Auth.ipynb#L150-L153
This piece of code is creating two different sessions - one using Session() and another using boto3.client() directly. It's quite confusing which session being used through out the sample.
I am changing it to
```
boto_session = Session()
sts = boto_session.client('sts')
account_id = sts.get_caller_identity().get("Account")
region = boto_session.region_name
print (account_id)
```
And I have also set up my os.environ['AWS_ACCESS_KEY_ID'] etc accordingly to make it work.
I believe the sample code is running a notebook running inside AWS thus some part of the code might be assuming roles being attached to IDE run time, but when running the code from local, the different sessions are very confusing and causing issue.
Contributor guide
Research direction
Open 03-integrations/IDP-examples/EntraID/Step_by_Step_Entra_ID_for_Inbound_Auth.ipynb and inspect lines 150-153, starting with how the two session sources are created. Run the notebook with its current environment and verify the account and region come from one consistent session; done when the sample is no longer confusing and still retrieves the caller identity.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, jupyter-notebook, python
- Domain
- authentication, cloud
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100