Set password policy for AWS Cognito with AWS CLI

21 Views Asked by At

I created a new user pool with AWS Cognito and would like to set the password policy.

aws cognito-idp create-user-pool \
  --pool-name <Cognito-userpool-name>

When I am trying to set the password policy as described here

aws cognito-idp update-user-pool \
  --user-pool-id <userpool-id> \
  --policies PasswordPolicy={MinimumLength=10,RequireUppercase=true,RequireLowercase=true,RequireNumbers=true,RequireSymbols=true,TemporaryPasswordValidityDays=7}

then I am receiving the following error message:

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

Unknown options: PasswordPolicy=RequireLowercase=true, PasswordPolicy=RequireNumbers=true, PasswordPolicy=RequireSymbols=true, PasswordPolicy=TemporaryPasswordValidityDays=7, PasswordPolicy=RequireUppercase=true

Am I using the --policies Parameter wrong? How do I need to set it correctly? I am using aws-cli/2.15.19. Thank you very much!

1

There are 1 best solutions below

0
Halod On BEST ANSWER

You will need to put the policy within quotes as below:

aws cognito-idp update-user-pool \
  --user-pool-id <userpool-id> \
  --policies "PasswordPolicy={MinimumLength=10,RequireUppercase=true,RequireLowercase=true,RequireNumbers=true,RequireSymbols=true,TemporaryPasswordValidityDays=7}"