Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cognito UserPool presignup trigger #6356

Closed
qalshakhoori opened this issue Jul 10, 2019 · 1 comment
Closed

Cognito UserPool presignup trigger #6356

qalshakhoori opened this issue Jul 10, 2019 · 1 comment
Labels

Comments

@qalshakhoori
Copy link

I am trying to create a cognito user pool trigger, the service get's deployed but when I navigate to the aws console I cannot see the trigger is set on the userpool. I tried to change the names or reference the logical resource but nothing works.

service: cognitoTrigger

provider:
  name: aws
  runtime: nodejs10.x
  profile: free-tier
  region: ${opt:region, 'us-east-1'}
  stage: ${opt:stage, 'dev'}
  memorySize: 128

functions:
  preSignUp:
    handler: handler.hello
    role: LambdaforCognito
    events:
      - cognitoUserPool:
        pool: ${self:custom.userPoolName}
        trigger: PreSignUp
custom:
  userPoolName: myusers
resources:
  Resources:
    LambdaforCognito:
      Type: "AWS::IAM::Role"
      Properties:
        RoleName: ${self:service}-${self:provider.stage}-LambdaforCognito
        AssumeRolePolicyDocument:
          Version: "2012-10-17"
          Statement:
            - Effect: Allow
              Action: "sts:AssumeRole"
              Principal:
                Service: lambda.amazonaws.com
        Policies:
          - PolicyName: LambdaforCognitoPolicy
            PolicyDocument:
              Version: "2012-10-17"
              Statement:
                - Effect: Allow
                  Action:
                    - "logs:CreateLogGroup"
                    - "logs:CreateLogStream"
                    - "logs:PutLogEvents"
                  Resource:
                    - Fn::GetAtt: [PreSignUpLogGroup, Arn]
    UserPool:
      Type: AWS::Cognito::UserPool
      Properties:
        AutoVerifiedAttributes:
          - email
          # - phone_number
        UserPoolName: ${self:custom.userPoolName}
        UsernameAttributes:
          - email
          - phone_number
        Policies:
          PasswordPolicy:
            MinimumLength: 6
            RequireLowercase: true
            RequireUppercase: false
            RequireNumbers: true
            RequireSymbols: false
@pmuens
Copy link
Contributor

pmuens commented Jul 30, 2019

Hey @qalshakhoori you need to indent the events property configuration like this:

events:
  - cognitoUserPool:
      pool: ${self:custom.userPoolName}
      trigger: PreSignUp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants