<?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: Clinton Fernandes</title>
    <description>The latest articles on DEV Community by Clinton Fernandes (@clinton).</description>
    <link>https://dev.to/clinton</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%2F652688%2F5c45e8f8-3977-43a4-a037-b000885e7216.jpeg</url>
      <title>DEV Community: Clinton Fernandes</title>
      <link>https://dev.to/clinton</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/clinton"/>
    <language>en</language>
    <item>
      <title>How to resolve the dreadful 'Need to perform AWS calls for account xxx, but no credentials have been configured' error</title>
      <dc:creator>Clinton Fernandes</dc:creator>
      <pubDate>Sun, 22 Jun 2025 16:42:12 +0000</pubDate>
      <link>https://dev.to/clinton/how-to-resolve-the-dreadful-need-to-perform-aws-calls-for-account-xxx-but-no-credentials-have-3moo</link>
      <guid>https://dev.to/clinton/how-to-resolve-the-dreadful-need-to-perform-aws-calls-for-account-xxx-but-no-credentials-have-3moo</guid>
      <description>&lt;p&gt;When working with AWS CDK in environments where OpenID Connect (OIDC) is used for role assumption—especially in CI/CD pipelines—developers often encounter cryptic permission-related errors. These can be frustrating, time-consuming, and opaque, even for experienced engineers. In this post, I’ll walk through a real-world debugging experience that took me nearly four hours to resolve, along with general strategies that can help others avoid similar pitfalls.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem: OIDC Role Has Insufficient Permissions
&lt;/h2&gt;

&lt;p&gt;In many cases, the error manifests as a deployment failure due to an OIDC role not having enough permissions. You might see vague messages like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"AccessDenied: User is not authorized to perform: xyz on resource abc"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But there's no clear indication of &lt;em&gt;why&lt;/em&gt; it's happening or &lt;em&gt;what&lt;/em&gt; exactly is missing.&lt;/p&gt;

&lt;p&gt;This typically happens because the CDK code performs a &lt;em&gt;lookup&lt;/em&gt;—for example, fetching a KMS Key, a Route53 Hosted Zone, or an existing VPC—during the &lt;code&gt;cdk synth&lt;/code&gt; or &lt;code&gt;cdk deploy&lt;/code&gt; process. These lookups require the caller (in this case, the assumed OIDC role) to have explicit IAM permissions for the respective services and resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common CDK Lookup Triggers
&lt;/h3&gt;

&lt;p&gt;Some of the typical constructs or functions that can trigger lookups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;HostedZone.fromLookup(...)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Key.fromLookup(...)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Vpc.fromLookup(...)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the role doesn’t have access to query these resources, CDK fails silently or with a vague message.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-Step Debugging Guide
&lt;/h2&gt;

&lt;p&gt;After hitting this issue myself, here’s what I recommend based on what finally worked:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Run CDK with Verbose Logging
&lt;/h3&gt;

&lt;p&gt;Start with:&lt;/p&gt;

&lt;p&gt;cdk synth --verbose&lt;/p&gt;

&lt;p&gt;Or if you're deploying:&lt;/p&gt;

&lt;p&gt;cdk deploy --verbose&lt;/p&gt;

&lt;p&gt;Verbose logging can sometimes reveal additional clues around what resource is being accessed when the error is thrown.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In my case, this step was partially useful. It hinted at a HostedZone lookup, but the error message lacked enough context to resolve it immediately.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2. Sign In with the AWS CLI and Run &lt;code&gt;cdk synth&lt;/code&gt; Locally
&lt;/h3&gt;

&lt;p&gt;The key insight came when I ran the same &lt;code&gt;cdk synth&lt;/code&gt; locally after explicitly signing in using the AWS CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws sso login --profile your-profile-name
cdk synth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does is allow CDK to perform any required lookups (e.g., KMS Key ARNs or HostedZone IDs) using your credentials, and &lt;strong&gt;cache the results into &lt;code&gt;cdk.context.json&lt;/code&gt;&lt;/strong&gt;. This file then serves as a snapshot that your CI/CD pipeline or OIDC-based role can consume without needing additional permissions.&lt;/p&gt;

&lt;p&gt;You can inspect &lt;code&gt;cdk.context.json&lt;/code&gt; and confirm that things like Hosted Zone IDs or VPCs have been resolved.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Check and Clean Up Your &lt;code&gt;cdk.json&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Sometimes, CDK tags or configuration in &lt;code&gt;cdk.json&lt;/code&gt; can also interfere with deploys—especially if they're applied globally or passed to stacks as environment values. If you're stuck, try temporarily removing any custom tags from &lt;code&gt;cdk.json&lt;/code&gt; to isolate the issue.&lt;/p&gt;

&lt;p&gt;Example:&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;"app"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx ts-node bin/my-app.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"context"&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="nl"&gt;"@aws-cdk/core:enableStackNameDuplicates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"true"&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;"tags"&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="nl"&gt;"Project"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"my-project"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Environment"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dev"&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="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;What this does is allow CDK to perform any required lookups (e.g., KMS Key ARNs or HostedZone IDs) using your credentials, and &lt;strong&gt;cache the results into &lt;code&gt;cdk.context.json&lt;/code&gt;&lt;/strong&gt;. This file then serves as a snapshot that your CI/CD pipeline or OIDC-based role can consume without needing additional permissions. Not having profile and using default profile can also lead to errors so make sure you set the profile if you have one&lt;/p&gt;

&lt;p&gt;You can inspect &lt;code&gt;cdk.context.json&lt;/code&gt; and confirm that things like Hosted Zone IDs or VPCs have been resolved.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Check and Clean Up Your &lt;code&gt;cdk.json&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Sometimes, CDK tags or configuration in &lt;code&gt;cdk.json&lt;/code&gt; can also interfere with deploys—especially if they're applied globally or passed to stacks as environment values. If you're stuck, try temporarily removing any custom tags from &lt;code&gt;cdk.json&lt;/code&gt; to isolate the issue.&lt;/p&gt;

&lt;p&gt;Example:&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;"app"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx ts-node bin/my-app.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"context"&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="nl"&gt;"@aws-cdk/core:enableStackNameDuplicates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"true"&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;"tags"&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="nl"&gt;"Project"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"my-project"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Environment"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dev"&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="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;Try removing the tags section during debugging.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Re-run &lt;code&gt;cdk diff&lt;/code&gt; and &lt;code&gt;cdk deploy&lt;/code&gt; with Context Cached
&lt;/h3&gt;

&lt;p&gt;Once your &lt;code&gt;cdk.context.json&lt;/code&gt; is populated, try:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cdk diff
cdk deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should avoid real-time lookups and instead use the cached values, sidestepping the permission issues that the OIDC role cannot handle directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Always suspect a lookup&lt;/strong&gt; when you hit vague permission errors during CDK deploys.&lt;/li&gt;
&lt;li&gt;CDK’s logs are not always sufficient. You need to combine them with local synths and AWS CLI access to get the full picture.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cdk.context.json&lt;/code&gt; is your friend. Populate it ahead of time if your CI/CD environment lacks the IAM privileges to resolve lookups.&lt;/li&gt;
&lt;li&gt;Be mindful of &lt;code&gt;cdk.json&lt;/code&gt; tags and environment settings—they can interfere with deployments in subtle ways.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Troubleshooting CDK issues in CI/CD with OIDC roles is not always straightforward. While CDK abstracts a lot of complexity, it also hides some of the details that are crucial for debugging. Understanding when and how lookups happen—and what roles are executing them—can save you hours of trial and error.&lt;/p&gt;

&lt;p&gt;If you're hitting these issues, start local, synth with context, and deploy only after you've validated the lookup dependencies are resolved. It’s a bit of a dance, but one that’s unavoidable when security boundaries and automation intersect.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you’ve run into similar CDK lookup issues with OIDC roles or have alternative strategies, feel free to reach out - &lt;a href="https://clinton1719.github.io/clinton-blogs/aws/Need-to-perform-AWS-calls-for-account-xxx,-but-no-credentials-have-been-configured/" rel="noopener noreferrer"&gt;My blog&lt;/a&gt;, or drop your thoughts in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cdk</category>
      <category>cloud</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
