awslabs / awslabs/agentcore-samples

02-use-cases - [Bug]

Open
#377 0 comments 0 reactions 1 assignee Claimed by @EashanKaushik View on GitHub
02-use-cases bug
Dominant language
Python
Stars
3.4k
Forks
1.3k
Avg merge
1d 22h
Merged PRs (30d)
30

Description

Bug Report: Malformed JSON in IAM Role Creation Policy Document
Description
The deploy.sh script in the device-management folder fails during IAM role creation due to malformed JSON in the assume role policy document.

Error Message
An error occurred (MalformedPolicyDocument) when calling the CreateRole operation: This policy contains invalid Json
Root Cause
In the create_agent_gateway_iam() function (lines 67-85), the assume role policy document JSON structure contains extra closing braces that make it invalid:

Problematic Code:

--assume-role-policy-document "{
\"Version\": \"2012-10-17\",
\"Statement\": [
{
\"Sid\": \"GatewayAssumeRolePolicy\",
\"Effect\": \"Allow\",
\"Principal\": {
\"Service\": \"bedrock-agentcore.amazonaws.com\"
},
\"Action\": \"sts:AssumeRole\"
} # ← Extra closing brace
} # ← Extra closing brace
} # ← Extra closing brace
]
}"
Impact
The IAM role creation fails with MalformedPolicyDocument error
The script continues execution but subsequent operations fail because the role doesn't exist
Results in NoSuchEntity error when trying to attach policies to the non-existent role
Fix
Remove the extra closing braces to create valid JSON:

Corrected Code:

--assume-role-policy-document "{
\"Version\": \"2012-10-17\",
\"Statement\": [
{
\"Sid\": \"GatewayAssumeRolePolicy\",
\"Effect\": \"Allow\",
\"Principal\": {
\"Service\": \"bedrock-agentcore.amazonaws.com\"
},
\"Action\": \"sts:AssumeRole\"
}
]
}"
Files Affected
02-use-cases/device-management-agent/device-management/deploy.sh (lines 67-85)
Steps to Reproduce
Run ./deploy.sh in the device-management folder
Observe the MalformedPolicyDocument error during IAM role creation
Script continues but fails on subsequent policy attachment
Environment
AWS CLI version: [your version]
Operating System: macOS/Linux
Shell: bash/zsh
This JSON syntax error prevents the successful deployment of the device management system and should be fixed to ensure proper IAM role creation.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.