# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 AWSTemplateFormatVersion: '2010-09-09' Description: 'sputnik - Cognito - Version %%VERSION%%' Parameters: AdministratorName: Type: String Description: Name of the sputnik administrator. AdministratorEmail: Type: String Description: Email address for sputnik administrator. AllowedPattern: "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$" dataBucketArn: Type: String Description: ARN of the sputnik Data Bucket. websiteURL: Type: String Description: sputnik Website URL. fullName: Type: String Description: sputnik application name Resources: identityPoolAuthRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Federated: - "cognito-identity.amazonaws.com" Action: - "sts:AssumeRoleWithWebIdentity" Condition: StringEquals: "cognito-identity.amazonaws.com:aud": !Sub "${identityPool}" "ForAnyValue:StringLike": "cognito-identity.amazonaws.com:amr": "authenticated" Path: "/" identityPoolAuthPolicy: Type: "AWS::IAM::ManagedPolicy" Properties: Description: "Policy for the sputnik identity pool authorized identities." PolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Action: - "mobileanalytics:PutEvents" - "cognito-identity:*" Resource: !Sub "arn:aws:cognito-identity:${AWS::Region}:${AWS::AccountId}:identitypool/${identityPool}" - Effect: "Allow" Action: - "iot:Connect" - "iot:Subscribe" - "iot:Publish" - "iot:Receive" - "iot:DescribeEndpoint" - "iot:AttachPolicy" - "iot:GetThingShadow" - "iot:UpdateThingShadow" - "iot:DeleteThingShadow" Resource: - "*" - Effect: "Allow" Action: # TODO BE MORE RESTRICTIVE - "s3:*" Resource: - !Ref dataBucketArn - !Join ["/", [!Ref dataBucketArn, "*"]] Roles: - !Ref identityPoolAuthRole identityPoolUnauthRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Federated: - "cognito-identity.amazonaws.com" Action: - "sts:AssumeRoleWithWebIdentity" Condition: StringEquals: "cognito-identity.amazonaws.com:aud": !Sub "${identityPool}" "ForAnyValue:StringLike": "cognito-identity.amazonaws.com:amr": "unauthenticated" Path: "/" identityPoolUnauthPolicy: Type: "AWS::IAM::ManagedPolicy" Properties: Description: "Policy for the sputnik identity pool unauthorized identities." PolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Action: - "mobileanalytics:PutEvents" Resource: !Sub "arn:aws:cognito-identity:${AWS::Region}:${AWS::AccountId}:identitypool/${identityPool}" - Effect: "Allow" Action: - "iot:Connect" - "iot:Subscribe" - "iot:Publish" - "iot:Receive" - "iot:DescribeEndpoint" - "iot:AttachPolicy" Resource: - "*" Roles: - !Ref identityPoolUnauthRole websiteCognitoIoTPolicy: Type: "AWS::IoT::Policy" DeletionPolicy: Retain Properties: PolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Action: - "iot:*" Resource: - "*" userPool: Type: "AWS::Cognito::UserPool" Properties: UserPoolName: "sputnik-pool" AdminCreateUserConfig: AllowAdminCreateUserOnly: True InviteMessageTemplate: EmailMessage: !Sub |
You are invited to join sputnik. Your temporary password is as follows:
Password: {####}
id: {username}
Please sign in to sputnik dashboard with your email address and temporary password provided above at: ${websiteURL}
Contact ${AdministratorEmail} if you are experiencing issues.