Replies: 3 comments
-
i'm still really stuck on this but I'm working on it. I discovered that there's a way to attach roles later: const idPool = new IdentityPool(stack, "xxx-cognito-id-pool", {
/* DOES NOT WORK - you have to specify the roles! */
identityPoolName: "rocnrebel-id-pool",
allowUnauthenticatedIdentities: false,
authenticationProviders: {
userPools: [new UserPoolAuthenticationProvider({userPool: userPool})]
}
})
/* create authenticated and unauthenticated roles */
const roleAttachment = new IdentityPoolRoleAttachment(stack,
"xxx-id-pool-attachment",
{
identityPool: idPool,
authenticatedRole: authenticatedRole,
unauthenticatedRole: unauthenticatedRole
}) but this doesn't actually work, because authenticatedRole and unauthenticatedRole are required by IdentityPoolProps. That's a problem, because I want to do this: StringEquals: {
/*
* aud is the audience - it needs to be the identity pool
*/
'cognito-identity.amazonaws.com:aud': `${stack.region}:${idPool.identityPoolId}`,
}, That's the circular reference ... I can't create the role with that condition until I have the idPool, but I can't create the idPool until I have the role. I can't find a solution to this. UPDATE: looks like these fields became optional some time recently, updating dependencies. |
Beta Was this translation helpful? Give feedback.
-
I've run into the same problem but eventually worked around it as below: At least in java / kotlin, as of version What I'm doing next is altering these roles with my relevant inline policies: |
Beta Was this translation helpful? Give feedback.
-
I also encountered the same problem, but it is now working fine with the following code.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This says you can assign the authenticated and unauthenticated roles this way:
but I'm having a little trouble with this. I don't understand why it would be service.amazonaws.com with no restrictions. What I really want to do is this:
where I only allow cognito-identity to assume the role, and only for my identity pool, not any random identity pool on AWS. The problem seems to be that to do that I need the roles to have a reference to the federated identity pool, and the federated identity pool to have a reference to the roles. It's a circular dependency that i don't know how to break.
What do I do?
Beta Was this translation helpful? Give feedback.
All reactions