New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

serverless-cognito-add-custom-attributes

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-cognito-add-custom-attributes

Add custom attributes to an existing CloudFormation-managed CognitoUserPool and CognitoUserPoolClient without losing all your users.

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
735
increased by15.57%
Maintainers
2
Weekly downloads
 
Created
Source

npm version

serverless-cognito-add-custom-attributes

This plugin allows you to add custom attributes to an existing CloudFormation-managed Cognito User Pool from serverless without losing all your users. At the time of writing (June 2018) CloudFormation doesn't know how to add custom attributes to a user pool without dropping and re-creating it, thus losing all your users.

This plugin also adds the specified attributes to a User Pool Client, giving that client read and write permissions for the new attribute.

Requirements

  • Node 8+
  • serverless 1+

Usage

Install npm i serverless-cognito-add-custom-attributes, then add serverless-cognito-add-custom-attributes to your serverless.yml plugins list.

plugins:
    - serverless-cognito-add-custom-attributes

custom:
  CognitoAddCustomAttributes: 
    CognitoUserPoolIdOutputKey: "CognitoUserPoolApplicationUserPoolId"              # The key of the outputted UserPool Ref 
    CognitoUserPoolClientIdOutputKey: "CognitoUserPoolApplicationUserPoolClientId"  # The key of the outputted UserPoolClient Ref
    CustomAttributes: 
      - 
        AttributeDataType: String
        DeveloperOnlyAttribute: False
        Mutable: True
        Name: "another" # this will end up being custom:another
        Required: False

# Only add this if not already outputting the Cognito User Pool and Client IDs, otherwise, refer to the existing outputs in the custom:CognitoAddCustomAttributes section
resources:
  Outputs:
    CognitoUserPoolApplicationUserPoolId:
      Value:
        Ref: CognitoUserPoolApplicationUserPool
    CognitoUserPoolApplicationUserPoolClientId:
      Value:
        Ref: CognitoUserPoolApplicationUserPoolClient

Details

  1. Output your UserPoolId via resources.Outputs
  2. Output your UserPoolClientId via resources.Outputs
  3. Add CognitoAddCustomAttributes to custom with the following structure:
  CognitoUserPoolIdOutputKey: "UserPool Output Key as a String"
  CognitoUserPoolClientIdOutputKey: "UserPoolClient Output Key as a String"
  CustomAttributes:
    -
        AttributeDataType: String
        DeveloperOnlyAttribute: False
        Mutable: True
        Name: "another"
        Required: False

Note: If you have multiple userPool-userPoolClients you can specify them as an array as well

Example:

plugins:
    - serverless-cognito-add-custom-attributes

custom:
  CognitoAddCustomAttributes:
    -
      CognitoUserPoolIdOutputKey: "CognitoUserPoolApplicationUserPoolId"
      CognitoUserPoolClientIdOutputKey: "CognitoUserPoolApplicationUserPoolClientId"
      CustomAttributes:
        -
          AttributeDataType: String
          DeveloperOnlyAttribute: False
          Mutable: True
          Name: "another" # this will end up being custom:another
          Required: False
    -
      CognitoUserPoolIdOutputKey: "CognitoUserPoolApplicationUserPoolId"
      CognitoUserPoolClientIdOutputKey: "CognitoUserPoolApplicationUserPoolClientId2"
      CustomAttributes:
        -
          AttributeDataType: String
          DeveloperOnlyAttribute: False
          Mutable: True
          Name: "another" # this will end up being custom:another
          Required: False

resources:
  Outputs:
    CognitoUserPoolApplicationUserPoolId:
      Value:
        Ref: CognitoUserPoolApplicationUserPool
    CognitoUserPoolApplicationUserPoolClientId:
      Value:
        Ref: CognitoUserPoolApplicationUserPoolClient
    CognitoUserPoolApplicationUserPoolClientId2:
      Value:
        Ref: CognitoUserPoolApplicationUserPoolClient2

The names of your attributes supplied here will appear as custom:{name} when deployed.

For more information on the schema of attributes see: https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_SchemaAttributeType.html

Keywords

FAQs

Package last updated on 10 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc