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

Changing Auth 'parameters.json' and 'template.yml' fails #5761

Closed
xitanggg opened this issue Nov 3, 2020 · 5 comments
Closed

Changing Auth 'parameters.json' and 'template.yml' fails #5761

xitanggg opened this issue Nov 3, 2020 · 5 comments

Comments

@xitanggg
Copy link

xitanggg commented Nov 3, 2020

Which Category is your question related to?
Auth

Amplify CLI Version
4.32.0

What AWS Services are you utilizing?
AWS Cognito

Provide additional details e.g. code snippets
Hi, I am adding Auth with amplify auth add. The default Auth created by Amplify uses case sensitive username. For example, if email is used as username alias, hi@gmail.com and HI@gmail.com would be treated as two different usernames, which is not what most people wanted (This has been brought up before #4185 and remains unresolved).

With the old version of Amplify CLI, we can modify the Auth Cloudformation Template directly by adding UsernameConfiguration to enable case insensitivity. (As mentioned in #3494)

  UsernameConfiguration:
    CaseSensitive: false

However, with the new CLI that creates two files parameters.json and xxx-cloudformation-template.yml, I am confused as to where to add this.

In parameters.json, I had tried "usernameConfiguration": {"CaseSensitive": false} or "usernameConfiguration": "{\n \"CaseSensitive\": false \n}".

In xxx-cloudformation-template.yml, I added

Parameters:
  (...skip)
  usernameConfiguration:
    Type: String

Resources:
  (...skip)
  UserPool:
    (...skip)
    Properties:
      UsernameConfiguration: !Ref usernameConfiguration

but I received the error Property validation failure: [Value UsernameConfiguration} does not match type {Object}] when I do amplify push. I would appreciate any helps to resolve this. Thanks.

@xitanggg
Copy link
Author

xitanggg commented Nov 3, 2020

Sorry, I had a brain fart.

Basically, simply add it to xxx-cloudformation-template.yml solves it. No need to touch parameters.json

Resources:
  (...skip)
  UserPool:
    (...skip)
    Properties:
      (..skip)
      UsernameAttributes: !Ref usernameAttributes

      (...I add the following right below usernameAttributes)
      UsernameConfiguration:
        CaseSensitive: false

@xitanggg xitanggg closed this as completed Nov 3, 2020
@sanjukris
Copy link

@xitanggg, I just updated yaml, but amplify push failed with the following error. I selected Email with amplify auth add and the default configuration option. Any idea what the issue could be? I didn't find any official aws documentation related to updating the template before the amplify push.
CREATE_FAILED UpdateRolesWithIDPFunctionRole AWS::IAM::Role Thu Nov 19 2020 17:31:37 GMT-0500 (Eastern Standard Time) Resource creation cancelled UPDATE_FAILED DeploymentBucket AWS::S3::Bucket Thu Nov 19 2020 17:31:37 GMT-0500 (Eastern Standard Time) Resource update cancelled CREATE_FAILED authcognitoui0e05feaf AWS::CloudFormation::Stack Thu Nov 19 2020 17:31:37 GMT-0500 (Eastern Standard Time) Parameters: [usernameConfiguration] must have values

@xitanggg
Copy link
Author

xitanggg commented Nov 19, 2020

Which yml file you changed? It should be the one under amplify/backend/auth/{YourAuthResource}/ and it is called {YourAuthResource}-cloudformation-template.yml?

Your error seems to says that it couldn't read [usernameConfiguration], make sure you indent correctly for CaseSensitive: false with 2 spaces in front.


Also, make sure you haven't push auth before you changed yml file. Once auth is pushed, which means Cognito is created and the setting can no longer be changed.

@sanjukris
Copy link

Thanks for the quick response. With trial and error found that the below code is what is needed in the template file to do the magic. Meanning...no need to mention usernameConfiguration: Type: String under Parameters.
Properties: <<skip>> UsernameConfiguration: CaseSensitive: false

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants