fix(eks): add IRSA role for CloudWatch Agent and support custom IAM policies#341
Merged
unni-facets merged 2 commits intomainfrom May 8, 2026
Merged
fix(eks): add IRSA role for CloudWatch Agent and support custom IAM policies#341unni-facets merged 2 commits intomainfrom
unni-facets merged 2 commits intomainfrom
Conversation
…olicies Problem: The amazon-cloudwatch-observability addon had no IRSA role (service_account_role_arn was null), so the CloudWatch Agent fell back to the node IAM role for AWS API calls. This caused failures on Karpenter-provisioned nodes where the node role lacks CloudWatch/X-Ray permissions. The OTEL auto-instrumentation injected by the addon's mutating webhook would fail with: AccessDeniedException: xray:PutTraceSegments Changes: - Create a dedicated IRSA role for the CloudWatch Agent service account (amazon-cloudwatch:cloudwatch-agent) with CloudWatchAgentServerPolicy - Pass the IRSA role ARN to the addon via service_account_role_arn - Add configurable cloudwatch_agent_policies spec field so users can attach additional IAM policies (e.g., AWSXRayDaemonWriteAccess) - Retain the existing node-level CloudWatchAgentServerPolicy attachment on managed node groups to avoid breaking existing customers With IRSA, the CloudWatch Agent gets permissions via its service account regardless of which node it runs on (managed node group or Karpenter), following the same pattern used for the EBS CSI driver. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…policies ARN field Enables dropdown selection of IAM policy ARNs from blueprint outputs while still allowing manual entry. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
unni-facets
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
amazon-cloudwatch:cloudwatch-agentservice account) when Container Insights is enabledamazon-cloudwatch-observabilityaddon viaservice_account_role_arncloudwatch_agent_policiesspec field (usingpatternProperties) so users can attach additional IAM policies to the CloudWatch Agent IRSA roleCloudWatchAgentServerPolicyattachment on managed node groups to avoid breaking existing customersProblem
The
amazon-cloudwatch-observabilityEKS addon hadservice_account_role_arn = null, causing the CloudWatch Agent to fall back to the node IAM role for all AWS API calls. This caused two issues:CloudWatchAgentServerPolicyattachedmpod.kb.io). Traces are sent to the CloudWatch Agent which forwards to X-Ray, butAWSXRayDaemonWriteAccesswas never attached to any role, causing:Solution
Create an IRSA role for the CloudWatch Agent (same pattern as the existing EBS CSI driver IRSA), so it gets permissions via the service account regardless of which node type it runs on.
Architecture:
Usage - to fix X-Ray errors, add to blueprint:
Files Changed
main.tfamazon-cloudwatch:cloudwatch-agentSA, policy attachments, and wiredservice_account_role_arnto addon config. Kept existing node-level policy attachment unchanged.variables.tfcloudwatch_agent_policiesasoptional(map(object({ arn = string })), {})facets.yamlcloudwatch_agent_policieswithpatternPropertiesand ARN validation, visible whencontainer_insights_enabledis trueBackward Compatibility
cloudwatch_agentresource (node-level policy attachment) is untouched — same resource name, same logiccloudwatch_agent_irsasuffix to avoid state conflictscloudwatch_agent_policiesdefaults to{}, so existing customers with no custom policies are unaffectedTest plan
raptor create iac-module -f modules/kubernetes_cluster/eks_standard/1.0 --dry-runcontainer_insights_enabled: trueand verify CloudWatch Agent uses the IRSA roleAWSXRayDaemonWriteAccessviacloudwatch_agent_policiesand verify OTEL trace export to X-Ray works on both managed and Karpenter nodescloudwatch_agent_policiesto confirm backward compatibilityCloudWatchAgentServerPolicyon their node roles🤖 Generated with Claude Code