awslabs / awslabs/agentcore-samples

Amazon Bedrock AgentCore Samples - [Bug] 01-tutorials/utils.py throws MalformedPolicyDocument

Open
#166 0 comments 0 reactions 0 assignees View on GitHub
01-AgentCore-runtime 01-tutorials bug
Dominant language
Python
Stars
3.4k
Forks
1.3k
Avg merge
1d 22h
Merged PRs (30d)
30

Description

**Describe the bug**

`create_agentcore_role` in "01-tutorials/utils.py" errors out with:
```text
An error occurred (MalformedPolicyDocument) when calling the PutRolePolicy operation: The policy failed legacy parsing
```
Root cause is that ARN's like this are produced "arn:aws:logs:None:1111111111:log-group:*"

**To Reproduce**

Run "01-tutorials/01-AgentCore-runtime/01-hosting-agent/01-strands-with-bedrock-model/runtime_with_strands_and_bedrock_models.ipynb" with only AWS_REGION set, but **no** AWS_DEFAULT_REGION set

e.g. run the below python code with

```sh
AWS_REGION=us-west-1 python test.py
```

```python
from boto3.session import Session

if __name__ == "__main__":
boto_session = Session()
region = boto_session.region_name
print(region)
```
reproduces this error (no AWS_DEFAULT_REGION set) ie. prints 'None'

**Expected behavior**

Default to AWS_REGION, and if this is not set default to a pre-set region (e.g. us-east-1)

Contributor guide

Open the contributing guide

Research direction

Start in 01-tutorials/utils.py at create_agentcore_role, then reproduce the region lookup with AWS_REGION set and AWS_DEFAULT_REGION unset. Use the referenced runtime_with_strands_and_bedrock_models.ipynb to verify the change; done means the policy no longer contains a None region and the sample runs with the documented fallback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud, security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.