13

Amazon Cognito is a user management and authentication service provided by Amazon through Amazon Web Services:

Amazon Cognito lets you easily add user sign-up and sign-in to your mobile and web apps. With Amazon Cognito, you also have the options to authenticate users through social identity providers such as Facebook, Twitter, or Amazon, with SAML identity solutions, or by using your own identity system. In addition, Amazon Cognito enables you to save data locally on users devices, allowing your applications to work even when the devices are offline. You can then synchronise data across users devices so that their app experience remains consistent regardless of the device they use.

What you are effectively doing is storing your customer data in a closed system hosted by Amazon. If you are a company, such as a social network, who's data represents a significant asset within your organisation how to you ensure that this data is protected from:

  • Amazon Cognito being shut down unexpectedly, i.e. at request from a law enforcement or government agency.
  • Your access keys being compromised and some or all records being corrupted.
  • The relationship between your organisation and Amazon breaking down to the point Amazon withdraws all services with immediate effect.

Amazon Cognito is a huge benefit to organisations and developers as it takes a particularly hard piece of software and makes it easy to implement; from a service operability perspective, we need to find ways to mitigate, remediate or accept risks to the companies assets at all times.

1
  • From a quick look to doc, I'd go with cognito streams to get a redshift backup usable elsewhere.
    – Tensibai
    Apr 13, 2017 at 9:01

4 Answers 4

12

The Amazon Cognito streams feature can be used to backup data.

Currently, Amazon does not provide a solution to backup their Cognito user Pools. You can use the following NPM package called "cognito-backup":

Install:

npm install -g cognito-backup

Usage

cognito-backup backup-users <user-pool-id> <options>  Backup all users in a single user pool
cognito-backup backup-all-users <options>  Backup all users in all user pools for this account

Examples

cognito-backup backup-users eu-west-1_1_12345
cognito-backup backup-users eu-west-1_1_12345 --region eu-west-1 --file mypool.json
cognito-backup backup-all-users eu-west-1_1_12345 --region eu-west-1 --dir output

Source: https://www.npmjs.com/package/cognito-backup

4
  • 5
    Just a word of warning... Read to the bottom of those docs before you start using cognito-backup: "Todo: Implement restore". LOL Mar 11, 2018 at 23:52
  • 3
    Ability to restore the json file is already available: cognito-backup restore-users eu-west-1_12345 Abcd.1234 --file eu-west-1_12345.json
    – schystz
    Oct 17, 2018 at 1:26
  • The passwords won't be in the backup, so I suppose the restore will require all the users to reset their password.
    – benji
    Dec 14, 2018 at 18:32
  • You can also pass --profile (which isn't in the documentation) to specify which account to back up.
    – tschumann
    Mar 23, 2021 at 6:47
1

Amazon has released a Cognito User Profiles Export Reference Architecture for exporting/importing users from a user pool. There are limitations:

  • Passwords not backed up; users will need to reset
  • Pools using MFA are not supported
  • Cognito sub attributes will be new, so if the system depends on them, they need to be copied to a custom user attribute
  • Federated users also pose challenges wrt sub
  • Advanced security - no user history is exported
  • No support for pools that allow the option of either phone or email usernames
  • No support for tracked devices
0

To backup Cognito, we use AWS Glue.

1
  • 3
    Hi, could you please provide a bit more context to your answer? What is AWS Glue, why should it be used here, etc? Perhaps some links to the documentation? thanks Sep 10, 2020 at 7:22
0

As said in other answers, there are two main packages used for this purpose.

None of them seems to have maintainance at this time, but I recommend to use the first one as it has more functionalities implemented. It allows to use the cli and to import the npm package to be used in your own code.

One thing to have in mind is that both of them only allow to export users from a UserPool, but don't allow to export groups. In the case of cognito-backup-restore, there is an issue open and a pull request with changes that implements that functionality, but it is not merged.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.