Skip to content

Instantly share code, notes, and snippets.

@Th0masStorm
Created September 24, 2020 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Th0masStorm/d8b5fa280d12ea9de4813a942f5320af to your computer and use it in GitHub Desktop.
Save Th0masStorm/d8b5fa280d12ea9de4813a942f5320af to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: "2010-09-09"
Resources:
Pool:
Type: AWS::Cognito::UserPool
PoolClient:
Type: "AWS::Cognito::UserPoolClient"
Properties:
UserPoolId: !Ref Pool
ExplicitAuthFlows:
- ALLOW_USER_PASSWORD_AUTH
- ALLOW_REFRESH_TOKEN_AUTH
IdPool:
Type: AWS::Cognito::IdentityPool
Properties:
CognitoIdentityProviders:
-
ClientId: !Ref PoolClient
ProviderName: !GetAtt Pool.ProviderName
AllowUnauthenticatedIdentities: false
Role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
-
Effect: Allow
Action:
- sts:AssumeRoleWithWebIdentity
Principal:
Federated: cognito-identity.amazonaws.com
Condition:
StringEquals:
cognito-identity.amazonaws.com:aud:
- !Ref IdPool
ForAnyValue:StringLike:
cognito-identity.amazonaws.com:amr:
- "authenticated"
Group:
Type: AWS::Cognito::UserPoolGroup
Properties:
RoleArn: !GetAtt Role.Arn
UserPoolId: !Ref Pool
IdPoolRoleAttachment:
Type: AWS::Cognito::IdentityPoolRoleAttachment
Properties:
IdentityPoolId: !Ref IdPool
Roles:
authenticated: !GetAtt Role.Arn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment