auth.yaml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. AWSTemplateFormatVersion: "2010-09-09"
  2. Transform: AWS::Serverless-2016-10-31
  3. Description: Amazon S3 Find and Forget Auth Infrastructure
  4. Parameters:
  5. CognitoAdvancedSecurity:
  6. Type: String
  7. ResourcePrefix:
  8. Type: String
  9. Resources:
  10. CognitoIdentityPool:
  11. Type: AWS::Cognito::IdentityPool
  12. Properties:
  13. IdentityPoolName: !Sub ${ResourcePrefix}IdentityPool
  14. CognitoIdentityProviders:
  15. - ClientId: !Ref CognitoUserPoolClient
  16. ProviderName: !GetAtt CognitoUserPool.ProviderName
  17. AllowUnauthenticatedIdentities: false
  18. CognitoIdentityPoolRole:
  19. Type: AWS::Cognito::IdentityPoolRoleAttachment
  20. Properties:
  21. IdentityPoolId: !Ref CognitoIdentityPool
  22. Roles:
  23. authenticated: !GetAtt ServiceInvokeRole.Arn
  24. CognitoUserPool:
  25. Type: AWS::Cognito::UserPool
  26. Properties:
  27. UserPoolName: !Sub ${ResourcePrefix}UserPool
  28. AdminCreateUserConfig:
  29. AllowAdminCreateUserOnly: true
  30. InviteMessageTemplate:
  31. EmailMessage: 'Your Amazon S3 Find and Forget username is {username} and the temporary password is {####}'
  32. EmailSubject: 'Your temporary password for Amazon S3 Find and Forget'
  33. AutoVerifiedAttributes:
  34. - email
  35. UserPoolAddOns:
  36. AdvancedSecurityMode: !Ref CognitoAdvancedSecurity
  37. Policies:
  38. PasswordPolicy:
  39. MinimumLength: 8
  40. RequireLowercase: true
  41. RequireNumbers: true
  42. RequireSymbols: true
  43. RequireUppercase: true
  44. CognitoUserPoolClient:
  45. Type: AWS::Cognito::UserPoolClient
  46. Properties:
  47. UserPoolId: !Ref CognitoUserPool
  48. ClientName: !Sub ${ResourcePrefix}UserPoolClientName
  49. GenerateSecret: false
  50. RefreshTokenValidity: 1
  51. PreventUserExistenceErrors: ENABLED
  52. ServiceInvokeRole:
  53. Type: AWS::IAM::Role
  54. Properties:
  55. ManagedPolicyArns:
  56. - !Sub arn:${AWS::Partition}:iam::aws:policy/AmazonAPIGatewayInvokeFullAccess
  57. AssumeRolePolicyDocument:
  58. Statement:
  59. - Effect: Allow
  60. Principal:
  61. Federated:
  62. - cognito-identity.amazonaws.com
  63. Action: sts:AssumeRoleWithWebIdentity
  64. Condition:
  65. StringEquals:
  66. "cognito-identity.amazonaws.com:aud": !Ref CognitoIdentityPool
  67. Path: "/"
  68. Policies:
  69. - PolicyName: WebServicesExecutionPolicy
  70. PolicyDocument:
  71. Version: "2012-10-17"
  72. Statement:
  73. - Effect: Allow
  74. Action: "s3:ListAllMyBuckets"
  75. Resource: !Sub "arn:${AWS::Partition}:s3:::*"
  76. - Effect: Allow
  77. Action: "sts:GetCallerIdentity"
  78. Resource: "*"
  79. - Effect: "Allow"
  80. Action:
  81. - "glue:BatchGetPartition"
  82. - "glue:GetDatabase*"
  83. - "glue:GetPartition*"
  84. - "glue:GetTable*"
  85. Resource:
  86. - !Sub "arn:${AWS::Partition}:glue:*:${AWS::AccountId}:catalog*"
  87. - !Sub "arn:${AWS::Partition}:glue:*:${AWS::AccountId}:database*"
  88. - !Sub "arn:${AWS::Partition}:glue:*:${AWS::AccountId}:table*"
  89. - !Sub "arn:${AWS::Partition}:glue:*:${AWS::AccountId}:partition*"
  90. Outputs:
  91. CognitoIdentityPoolId:
  92. Description: Cognito Identity Pool Id
  93. Value: !Ref CognitoIdentityPool
  94. CognitoUserPoolArn:
  95. Description: Cognito User Pool Arn
  96. Value: !GetAtt CognitoUserPool.Arn
  97. CognitoUserPoolId:
  98. Description: Cognito User Pool Id
  99. Value: !Ref CognitoUserPool
  100. CognitoUserPoolName:
  101. Description: Cognito User Pool Name
  102. Value: !Sub ${ResourcePrefix}UserPool
  103. CognitoUserPoolClientId:
  104. Description: Cognito User Pool Client Id
  105. Value: !Ref CognitoUserPoolClient
  106. ServiceInvokeRole:
  107. Description: Role used by the Web UI
  108. Value: !Ref ServiceInvokeRole