-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloudformation.template.yaml
59 lines (58 loc) · 2.06 KB
/
cloudformation.template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
AWSTemplateFormatVersion: "2010-09-09"
Description: |
This template creates a Cognito identity pool and associated resources
that allow a user to login to AWS via their Source Allies Google credentials
and obtain temporary access keys so that the AWS CLI and APIs can be used.
Parameters:
GoogleClientId:
Type: String
Description: "OAuth 2.0 client id from Google"
Default: "623591274072-kvu1ue0tq9oabke17r80itgpbam81i5f.apps.googleusercontent.com"
AssumedRoleManagedPolicyARNs:
Type: CommaDelimitedList
Description: "ARN of a IAM Managed policies that users signed in with google will assume"
Default: "arn:aws:iam::aws:policy/AdministratorAccess"
Resources:
IdentityPool:
Type: "AWS::Cognito::IdentityPool"
Properties:
AllowUnauthenticatedIdentities: false
SupportedLoginProviders:
"accounts.google.com": !Ref GoogleClientId
FederatedUserRole:
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 IdentityPool
ManagedPolicyArns: !Ref AssumedRoleManagedPolicyARNs
RoleAttachments:
# Warning! this resource "cannot be updated"
Type: "AWS::Cognito::IdentityPoolRoleAttachment"
Properties:
Roles: {}
IdentityPoolId: !Ref IdentityPool
RoleMappings:
"accounts.google.com":
AmbiguousRoleResolution: Deny
Type: Rules
RulesConfiguration:
Rules:
- MatchType: Equals
Value: sourceallies.com
Claim: hd
RoleARN: !GetAtt FederatedUserRole.Arn
Outputs:
GoogleClientId:
Description: OAuth Client ID to use when obtaining tokens
Value: !Ref GoogleClientId
IdentityPoolId:
Description: ID of the Cognito Identity Pool that should be used to login
Value: !Ref IdentityPool