Skip to content

Access Denied on bedrock:CreateAgent via CloudFormation, but IAM Simulator shows allowed.

1

Hello, community.

I'm facing what seems to be an impossible IAM permission issue when trying to create an Amazon Bedrock Agent via CloudFormation, and I've exhausted all standard debugging steps.

The Problem: A CloudFormation stack that tries to create a minimal AWS::Bedrock::Agent resource fails with the error: Resource handler returned message: "Access denied for operation 'AWS::Bedrock::Agent'."

The Evidence and The Paradox:

We have proven the following facts, which create a contradiction:

We are using a minimal test template to isolate the problem. It only creates the agent, with no custom roles or action groups (so iam:PassRole is not involved in this specific test).

YAML AWSTemplateFormatVersion: '2010-09-09' Resources: MinimalTestAgent: Type: AWS::Bedrock::Agent Properties: AgentName: minimal-repost-test-agent FoundationModel: "anthropic.claude-3-5-sonnet-20240620-v1:0" Instruction: "This is a test instruction with more than 40 characters to pass initial validation." The IAM User's policy explicitly allows the action. The user (arn:aws:iam::556958795518:user/Gitlab) running the deployment has a managed policy attached with the following statement:

JSON { "Effect": "Allow", "Action": "bedrock:CreateAgent", "Resource": "" } (Note: The full policy also includes all other necessary permissions like cloudformation:, etc., which are working correctly).

The IAM Policy Simulator confirms the permission. When simulating the bedrock:CreateAgent action for this user, the simulator's final result is allowed. It shows no explicit or implicit deny.

There is an anomaly in our AWS Organization console. I am the administrator for the organization (o-oc7n7fewif). When logged in as the root user of the management account:

The Settings page confirms "all features" are enabled. However, the Policies page does not show "Service Control Policies" as an available policy type. Trying to access the SCP page via its direct URL redirects me to the Organizations home page. My Question:

Given that the user's identity-based policy allows the action, and the IAM Policy Simulator confirms this permission, what could be causing a final Access Denied result during the real-world execution?

How can an SCP be denying this action if the interface to manage SCPs is inaccessible even to the root user of the management account? Is there any other "hidden" policy layer or account state that could be causing this block?

I have already confirmed there is no Permissions Boundary set on the user. Any insight into this discrepancy would be greatly appreciated.

2 Answers
0

Based on your description, there appears to be a discrepancy between what the IAM Policy Simulator shows and the actual permissions when executing CloudFormation operations to create a Bedrock Agent. Here are several potential causes and solutions:

  1. Service Role Requirements for Bedrock Agents: Amazon Bedrock Agents may have specific naming requirements for service roles. For example, the role name might need to use the prefix AmazonBedrockExecutionRoleForAgents_ and have a specific path like /service-role/. Even though your minimal template doesn't explicitly create a role, CloudFormation might be attempting to use or create a default role with incorrect naming conventions.

  2. Missing Permissions in the Policy: While your policy includes bedrock:CreateAgent, creating an agent through CloudFormation might require additional permissions that aren't explicitly listed in your policy. The IAM Policy Simulator might not accurately reflect all the permissions needed for the complete operation. Consider adding more comprehensive Bedrock permissions such as:

  • bedrock:ListFoundationModels
  • bedrock:GetFoundationModel
  • bedrock:TagResource
  • And other Bedrock-related permissions
  1. Inference Profile vs Foundation Model: If you're using an inference profile rather than a foundation model, you might need additional permissions like:
  • bedrock:GetInferenceProfile
  • bedrock:ListInferenceProfiles
  • bedrock:UseInferenceProfile
  1. Hidden Service Control Policies (SCPs): Even though you can't see SCPs in the Organizations console, there might still be SCPs applied to your account. The unusual behavior in the Organizations console could indicate an issue with your organization's configuration. SCPs can override identity-based policies even when the simulator shows permissions as allowed.

  2. Region-specific Permissions: Ensure that the model you're trying to use is available in the region where you're deploying the CloudFormation stack. Some models are only available in specific regions.

  3. CloudFormation Service Role: The CloudFormation service itself might be using a role that doesn't have the necessary permissions to create Bedrock resources.

To troubleshoot:

  1. Try creating the Bedrock Agent directly through the AWS CLI instead of CloudFormation to isolate whether the issue is with CloudFormation or with Bedrock permissions.

  2. Check CloudTrail logs for the specific denied action to see more details about why the permission is being denied.

  3. Temporarily grant broader permissions (like AdministratorAccess) to test if it's a permission issue.

  4. Contact AWS Support about the anomaly in your Organizations console, as this might indicate a deeper issue with your account configuration.
    Sources
    I can create Bedrock Agent using console, but can't using CLI. | AWS re:Post
    CDK - Resource handler returned message: "Access denied for operation 'AWS::Bedrock::Agent'." when creating an agent with foundationModel set as inference-profile. | AWS re:Post
    How do I troubleshoot when User: arn is no authorized to perform Create * or Delete * or Update * on resource(s) because no identity- policy allows the actions | AWS re:Post
    Identity-based policy examples for Amazon Bedrock Agents - Amazon Bedrock

answered a year ago

EXPERT

reviewed a year ago

0

Hello.

An IAM user with the IAM policy described in the following document was able to deploy the CloudFormation template you created.
https://docs.aws.amazon.com/bedrock/latest/userguide/security_iam_id-based-policy-examples-agent.html

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "test",
            "Effect": "Allow",
            "Action": [  
                "bedrock:ListFoundationModels",
                "bedrock:GetFoundationModel",
                "bedrock:TagResource", 
                "bedrock:UntagResource", 
                "bedrock:ListTagsForResource", 
                "bedrock:CreateAgent", 
                "bedrock:UpdateAgent", 
                "bedrock:GetAgent", 
                "bedrock:ListAgents", 
                "bedrock:DeleteAgent",
                "bedrock:CreateAgentActionGroup", 
                "bedrock:UpdateAgentActionGroup", 
                "bedrock:GetAgentActionGroup", 
                "bedrock:ListAgentActionGroups", 
                "bedrock:DeleteAgentActionGroup",
                "bedrock:GetAgentVersion",
                "bedrock:ListAgentVersions", 
                "bedrock:DeleteAgentVersion",
                "bedrock:CreateAgentAlias", 
                "bedrock:UpdateAgentAlias",               
                "bedrock:GetAgentAlias",
                "bedrock:ListAgentAliases",
                "bedrock:DeleteAgentAlias",
                "bedrock:AssociateAgentKnowledgeBase",
                "bedrock:DisassociateAgentKnowledgeBase",
                "bedrock:ListAgentKnowledgeBases",
                "bedrock:GetKnowledgeBase",
                "bedrock:ListKnowledgeBases",
                "bedrock:PrepareAgent",
                "bedrock:InvokeAgent",
                "bedrock:AssociateAgentCollaborator",
                "bedrock:DisassociateAgentCollaborator",
                "bedrock:GetAgentCollaborator",
                "bedrock:ListAgentCollaborators",
                "bedrock:UpdateAgentCollaborator"
            ],
            "Resource": "*"
        }
    ]   
}
EXPERT

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.