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

Add PreTokenGeneration & UserMigration Cognito triggers #6511

Merged

Conversation

v-anton
Copy link

@v-anton v-anton commented Aug 7, 2019

What did you implement:

Closes #5513

How did you implement it:

Added PreTokenGeneration & UserMigration triggers to the validTriggerSources since CloudFormation already supports it:

const validTriggerSources = [
  'PreSignUp',
  'PostConfirmation',
  'PreAuthentication',
  'PostAuthentication',
  'PreTokenGeneration',
  'CustomMessage',
  'DefineAuthChallenge',
  'CreateAuthChallenge',
  'VerifyAuthChallengeResponse',
  'UserMigration',
];

How can we verify it:

  1. Bootstrap Serverless framework project.
  2. Add the following code to serverless.yml:
service:
  name: testservicename
custom:
  stage: ${opt:stage, 'dev'}
  region: ${opt:region, 'eu-central-1'}
provider:
  name: aws
  runtime: nodejs10.x
  stage: ${self:custom.stage}
  region: ${self:custom.region}
functions:
  user-migration:
    handler: user-migration.handler
    events:
      - cognitoUserPool:
          pool: ${self:service.name}-${self:custom.stage}-user-pool
          trigger: UserMigration
          existing: true
  pre-token-generation:
    handler: pre-token-generation.handler
    events:
      - cognitoUserPool:
          pool: ${self:service.name}-${self:custom.stage}-user-pool
          trigger: PreTokenGeneration
          existing: true
resources:
  Resources:
    CognitoUserPool:
      Type: AWS::Cognito::UserPool
      Properties:
        UserPoolName: ${self:service.name}-${self:custom.stage}-user-pool
        UsernameAttributes:
          - email
        AutoVerifiedAttributes:
          - email

    CognitoUserPoolClient:
      Type: AWS::Cognito::UserPoolClient
      Properties:
        ClientName: ${self:service.name}-${self:custom.stage}-user-pool-client
        UserPoolId:
          Ref: CognitoUserPool
        ExplicitAuthFlows: [ADMIN_NO_SRP_AUTH, USER_PASSWORD_AUTH]
        GenerateSecret: false
  1. Deploy the app.
  2. Check if triggers are referenced properly in AWS Cognito User Pool settings.

Todos:

Note: Run npm run test-ci to run all validation checks on proposed changes

  • Write tests and confirm existing functionality is not broken.
    Validate via npm test
  • Write documentation
  • Ensure there are no lint errors.
    Validate via npm run lint-updated
    Note: Some reported issues can be automatically fixed by running npm run lint:fix
  • Ensure introduced changes match Prettier formatting.
    Validate via npm run prettier-check-updated
    Note: All reported issues can be automatically fixed by running npm run prettify-updated
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: NO
Is it a breaking change?: NO

@pmuens pmuens self-assigned this Aug 7, 2019
@pmuens pmuens added this to the 1.50.0 milestone Aug 7, 2019
Copy link
Contributor

@pmuens pmuens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @v-anton 👍

I just tested it and it worked fine! LGTM :shipit:

@pmuens pmuens merged commit 35d1b8b into serverless:master Aug 7, 2019
@v-anton
Copy link
Author

v-anton commented Aug 7, 2019

Thanks @pmuens

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

Successfully merging this pull request may close these issues.

Support for lambda trigger AWS Cognito UserMigration
2 participants