<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chandi Datta</title>
    <description>The latest articles on DEV Community by Chandi Datta (@cdatta).</description>
    <link>https://dev.to/cdatta</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3896107%2F741f82bd-f7c3-4a41-9b8e-319fd40ed64f.png</url>
      <title>DEV Community: Chandi Datta</title>
      <link>https://dev.to/cdatta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cdatta"/>
    <language>en</language>
    <item>
      <title>The iam: PassRole Nightmare - 3 Weeks of My Life I Will Never Get Back</title>
      <dc:creator>Chandi Datta</dc:creator>
      <pubDate>Mon, 11 May 2026 01:31:33 +0000</pubDate>
      <link>https://dev.to/cdatta/the-iam-passrole-nightmare-3-weeks-of-my-life-i-will-never-get-back-1285</link>
      <guid>https://dev.to/cdatta/the-iam-passrole-nightmare-3-weeks-of-my-life-i-will-never-get-back-1285</guid>
      <description>&lt;p&gt;Let me tell you the story of three weeks of my life I will never get back.&lt;/p&gt;

&lt;p&gt;We were building an AI agent on AMAZON Bedrock — an autonomous system that manages infrastructure lifecycle operations. The agent worked perfectly in our sandbox. Time to deploy it to the enterprise environment. Should take an afternoon, right?&lt;/p&gt;

&lt;p&gt;It took three weeks.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Setup
&lt;/h2&gt;

&lt;p&gt;To deploy a Bedrock Agent, you need to attach an IAM role — the execution role that the agent assumes when it invokes foundation models. This requires the &lt;code&gt;iam:PassRole&lt;/code&gt; permission. Simple enough.&lt;/p&gt;

&lt;p&gt;In our enterprise environment, there is a managed policy attached to every developer role. Let's call it &lt;code&gt;OrgDenyEscalation&lt;/code&gt;. This policy contains an &lt;strong&gt;explicit deny&lt;/strong&gt; on &lt;code&gt;iam:PassRole&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Deny"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"iam:PassRole"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"iam:CreateRole"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"iam:AttachRolePolicy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"iam:DeleteRole"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The critical thing about IAM evaluation: &lt;strong&gt;explicit deny always wins.&lt;/strong&gt; It does not matter if you have &lt;code&gt;AdministratorAccess&lt;/code&gt;. It does not matter if you create a custom policy that allows &lt;code&gt;iam:PassRole&lt;/code&gt;. An explicit deny on any policy attached to your identity overrides every allow, period.&lt;/p&gt;

&lt;p&gt;So we could not deploy the agent via CLI. The &lt;code&gt;aws bedrock-agent create-agent&lt;/code&gt; command returned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AccessDeniedException: User is not authorized to perform iam:PassRole
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We spent three days trying to figure out why. Read every IAM doc, every blog post, every Stack Overflow answer. Added broader permissions. Tried different roles. Nothing worked.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Root Cause Nobody Talks About
&lt;/h2&gt;

&lt;p&gt;Enterprise IAM is not "add permissions until it works." It is a policy evaluation chain with multiple layers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request -&amp;gt; SCP (Organization level)
       -&amp;gt; Permission Boundary (Account level)
       -&amp;gt; Managed Policies (Role/User level)
       -&amp;gt; Inline Policies (Role/User level)
       -&amp;gt; Resource Policies (Bucket/Queue/etc. level)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our organization has:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Service Control Policies (SCPs)&lt;/strong&gt;: Org-level restrictions. Immovable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permission Boundaries&lt;/strong&gt;: Account-level caps on maximum permissions a role can have.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Managed Policies&lt;/strong&gt;: Enterprise-wide policies attached to all developer roles. These deny dangerous actions (&lt;code&gt;iam:PassRole&lt;/code&gt;, &lt;code&gt;iam:CreateRole&lt;/code&gt;). You cannot modify or detach them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your Custom Policies&lt;/strong&gt;: Only effective for actions not explicitly denied by layers 1-3.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We were fighting layer 3. You cannot win that fight by adding more permissions.&lt;/p&gt;

&lt;h2&gt;
  
  
  The CloudFormation Escape Hatch
&lt;/h2&gt;

&lt;p&gt;The non-obvious solution: CloudFormation uses a &lt;strong&gt;service role&lt;/strong&gt;, not your user identity. When CloudFormation creates resources, it assumes a role (like &lt;code&gt;cloudformation-service-role&lt;/code&gt;) that has the necessary permissions. If that service role has &lt;code&gt;iam:PassRole&lt;/code&gt; — and it typically does for infrastructure provisioning — the explicit deny on your developer role does not apply.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This works even when your CLI identity has explicit deny on iam:PassRole&lt;/span&gt;
&lt;span class="na"&gt;Resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;BedrockAgent&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;Type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AWS::Bedrock::Agent&lt;/span&gt;
    &lt;span class="na"&gt;Properties&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;AgentName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;my-agent&lt;/span&gt;
      &lt;span class="na"&gt;AgentResourceRoleArn&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;!Ref&lt;/span&gt; &lt;span class="s"&gt;AgentExecutionRole&lt;/span&gt;
      &lt;span class="na"&gt;FoundationModel&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;anthropic.claude-sonnet-4-20250514&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The catch: someone on the cloud platform team needs to have already configured the CloudFormation service role with the right permissions. In our case, this required a change request, a security review, and a 5-business-day SLA.&lt;/p&gt;

&lt;p&gt;A colleague on the platform team finally pointed us at the managed policy with the explicit deny. Three weeks later (after the change request process ground through), the CloudFormation service role was updated, and the deployment worked in 30 seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Permissions You Will Actually Need
&lt;/h2&gt;

&lt;p&gt;For anyone building Bedrock Agents in enterprise, here is the full list of permissions that will cause problems and where:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Why You Need It&lt;/th&gt;
&lt;th&gt;Enterprise Blocker&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;iam:PassRole&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Attach execution role to agent&lt;/td&gt;
&lt;td&gt;Explicit deny in managed policy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;bedrock:CreateAgent&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create the agent&lt;/td&gt;
&lt;td&gt;Usually allowed, but may need SCP update&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kms:CreateGrant&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Use KMS key for Bedrock encryption&lt;/td&gt;
&lt;td&gt;Key policy must allow your role&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;s3:PutObject&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Store state files&lt;/td&gt;
&lt;td&gt;Bucket policy + VPC endpoint policy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lambda:InvokeFunction&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call action group Lambdas&lt;/td&gt;
&lt;td&gt;Function resource policy must allow agent&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How to Work With Platform Teams (Without Losing Your Mind)
&lt;/h2&gt;

&lt;p&gt;Your ability to deploy agents depends on your relationship with the platform team. After two failed attempts, here is what actually moves the needle:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Come with a specific ask&lt;/strong&gt;: Not "I need more permissions" but "I need &lt;code&gt;iam:PassRole&lt;/code&gt; scoped to &lt;code&gt;arn:aws:iam::*:role/BedrockExecRole*&lt;/code&gt; for the CloudFormation service role."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Provide the policy JSON&lt;/strong&gt;: Do not make them write it. Draft the policy, explain each permission, justify the scope.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Show the error&lt;/strong&gt;: Share the exact &lt;code&gt;AccessDeniedException&lt;/code&gt; with the request ID. This helps the security team trace the denial.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Schedule an architecture review BEFORE you start building&lt;/strong&gt;: A 30-minute meeting upfront saves three weeks of tickets later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Never ask for &lt;code&gt;"Resource": "*"&lt;/code&gt;&lt;/strong&gt;: Always scope to specific ARN patterns. Least privilege is not optional — it is what gets your request approved.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Lesson
&lt;/h2&gt;

&lt;p&gt;In enterprise environments, the IAM model is not "add permissions until it works." It is "understand the full policy evaluation chain — managed policies, permission boundaries, SCPs, resource policies — and find the path through the maze." Sometimes that path is CloudFormation. Sometimes it is assuming a different role. Sometimes it is waiting for a change request.&lt;/p&gt;

&lt;p&gt;Nobody tells you this in the Bedrock quickstart guide. The 5-minute demo assumes you have &lt;code&gt;AdministratorAccess&lt;/code&gt;. In enterprise, that assumption is the first thing that breaks.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This is one of 13 chapters from my book *&lt;/em&gt;&lt;a href="https://leanpub.com/enterprise-ai-agents/c/DEVTO50" rel="noopener noreferrer"&gt;Enterprise AI Agents: From POC to Production on AWS&lt;/a&gt;*&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The book covers the full architecture, IAM patterns, state management, observability, and 12 more war stories from going POC -&amp;gt; production. Use code **DEVTO50&lt;/em&gt;* for 50% off (launch pricing, next 20 days only).*&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Found this helpful? Follow me here on Dev.to — I post weekly about enterprise AI engineering on AWS.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>aiops</category>
      <category>bedrock</category>
      <category>agents</category>
    </item>
  </channel>
</rss>
