-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-cdk/aws-cognito-identitypool-alpha: Rule based role mapping Circular Dependency #33725
Comments
Hi, Thank you for the report. The ProblemWhen setting up Amazon Cognito Identity Pool with rule-based role mapping, we encounter a "chicken and egg" situation: flowchart TD
%% Problem Section
subgraph Problem["The Problem"]
direction TB
A[Identity Pool with Role Mapping] -->|needs| B[IAM Role ARN]
B -->|needs| C[Identity Pool ID]
C -->|circular dependency| A
end
This creates a circular dependency:
We break this circular dependency by splitting the process into three sequential steps: flowchart TD
%% Solution Section
subgraph Solution["Breaking the Chain"]
direction TB
D[Create Identity Pool] -->|get| E[Identity Pool ID]
E -->|use in| F[Create IAM Role]
F -->|use both in| G[Create Role Mapping]
E -->|use both in| G
end
classDef default fill:#2d2d2d,stroke:#7f7f7f,color:white
Step 1: Create Identity Pool First
Step 2: Create IAM Role
Step 3: Create Role Attachment
By separating the role attachment into its own resource, we avoid the circular dependency and allow CloudFormation to create the resources in the correct order. Let me know if it works for you. |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Hi @pahud , Thank you for your response. Your understanding of the problem and the resolution look good to me. Using the L1 construct for creating the role attachment, I can synth this correctly, but haven't tested with a deployment as I am still developing. Would there be support to do this with the aws-cognito-identitypool-alpha library in the future? I will let you know if I face any other problems. |
Hi, Thanks for your response and the proposed solution. I investigated the suggested approach, but encountered an error when trying to create the AWS::Cognito::IdentityPoolRoleAttachment separately: 'AWS::Cognito::IdentityPoolRoleAttachment' with identifier 'us-east-1:' already exists. This indicates that the Identity Pool Role Attachment cannot be created later as a separate resource, likely because the Identity Pool is already associated with a role attachment. Given this constraint, an alternative approach may be required to avoid the circular dependency while ensuring that the role mappings are correctly established. Let me know if you have any suggestions or if there are any recommended workarounds for this scenario. Best, |
Describe the bug
Describe the bug
We are encountering a circular dependency when configuring rule-based role mapping for an Amazon Cognito Identity Pool using AWS CDK.
The problem arises because:
This creates a dependency loop where:
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
CDK should allow defining role mappings without causing a circular dependency when the IAM role trust policy depends on the Identity Pool ID.
Current Behavior
There is no way to reference the identity pool ID in the IAM role before its creation
Reproduction Steps
Possible Solution
CDK could support lazy evaluation for IAM roles in role mappings, allowing:
Additional Information/Context
No response
CDK CLI Version
2.1001.0 (build 130445d)
Framework Version
No response
Node.js Version
v20.18.0
OS
Ubuntu 22.04.5 LTS
Language
Python
Language Version
Python 3.12.7
Other information
No response
The text was updated successfully, but these errors were encountered: