This is my first foray into CDK, so I'm likely mis...
# help
s
This is my first foray into CDK, so I'm likely missing something very obvious 🙂
f
Hi @Seth Geoghegan, from the error message, it seems you have multiple
IdentityPoolRoleAttachment
resources with the same name.
Can you go into your .build/cdk.out and send me the generated CloudFormation template json file for the cognito stack?
s
If it helps, here's the serverless.yml from my existing auth service. It successfully creates the two policies (guest and authorized). I'm trying to replicate this in CDK https://gist.github.com/SethThomas/1566f19ea58028e5cf673e76ab6643b3
f
Thanks Seth. The problem seems to be you have
IdentityPoolRoleAttachment
defined twice, once inside CognitoAuthRole.js and once inside CognitoGuestRole.js
Copy code
new cognito.CfnIdentityPoolRoleAttachment(
      this,
      "IdentityPoolRoleAttachment",
      {
        identityPoolId: identityPool.ref,
        roles: {unauthenticated: this.role.roleArn}
      }
    );
Notice you have
unauthenticated
role specified in CognitoGuestRole.js
Just create 1
IdentityPoolRoleAttachment
with both
authenticated
and
unauthenticated
roles
s
Thanks a lot, I was able to get it working. It was not clear to me that I could only have one
IdentityPoolRoleAttachment
defined. The stack is now deployed with all the required roles created. Thanks again!