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

Failure editing auth sign-in/sign-out domain #3273

Closed
kernwig opened this issue Jan 26, 2020 · 8 comments
Closed

Failure editing auth sign-in/sign-out domain #3273

kernwig opened this issue Jan 26, 2020 · 8 comments
Assignees
Labels
auth Issues tied to the auth category of the CLI pending-triage Issue is pending triage platform Issues tied to the general CLI platform

Comments

@kernwig
Copy link

kernwig commented Jan 26, 2020

Describe the bug
I setup my own domain name to use in place of the CloudFront distribution domain, and need to update the auth redirects using the Amplify CLI. This resulted in an undefined being dereferenced in the Amplify CLI code.

Amplify CLI Version
4.10.0

To Reproduce
Clone repo: https://github.com/kernwig/sqac-amplify/tree/part7/go-live3
Then attempt inputs shown in Screenshot section below.

Expected behavior
I expect configuration to change with no crash of the CLI.

Screenshots

$ amplify update auth
Please note that certain attributes may not be overwritten if you choose to use defaults settings.

You have configured resources that might depend on this Cognito resource.  Updating this Cognito resource could have unintended side effects.

Using service: Cognito, provided by: awscloudformation
 What do you want to do? Add/Edit signin and signout redirect URIs
 Which redirect signin URIs do you want to edit? https://d3l0j9nusq7n6r.cloudfront.net/
? Update https://d3l0j9nusq7n6r.cloudfront.net/ https://sqac.fanello.net/
 Do you want to add redirect signin URIs? No
 Which redirect signout URIs do you want to edit? https://d3l0j9nusq7n6r.cloudfront.net/
? Update https://d3l0j9nusq7n6r.cloudfront.net/ https://sqac.fanello.net/
 Do you want to add redirect signout URIs? No
TypeError: Cannot use 'in' operator to search for 'dev' in undefined
    at keys.forEach.key (/Users/adamfanello/.nvm/versions/node/v10.16.3/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/envResourceParams.js:33:19)
    at Array.forEach (<anonymous>)
    at getOrCreateSubObject (/Users/adamfanello/.nvm/versions/node/v10.16.3/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/envResourceParams.js:32:10)
    at AmplifyToolkit.saveEnvResourceParameters [as _saveEnvResourceParameters] (/Users/adamfanello/.nvm/versions/node/v10.16.3/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/envResourceParams.js:66:23)
    at Object.saveResourceParameters (/Users/adamfanello/.nvm/versions/node/v10.16.3/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/resourceParams.js:26:19)
    at saveResourceParameters (/Users/adamfanello/.nvm/versions/node/v10.16.3/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/provider-utils/awscloudformation/index.js:110:12)
    at serviceQuestions.then (/Users/adamfanello/.nvm/versions/node/v10.16.3/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/provider-utils/awscloudformation/index.js:330:7)
    at process._tickCallback (internal/process/next_tick.js:68:7)
There was an error adding the auth resource

Desktop (please complete the following information):

  • OS: Mac v10.15.2
  • Node Version: 10.16.3

Additional context
Add any other context about the problem here.

@kernwig
Copy link
Author

kernwig commented Jan 26, 2020

It seems this deleted my amplify/team-provider-info.json file. 😢

@yuth yuth added pending-triage Issue is pending triage platform Issues tied to the general CLI platform auth Issues tied to the auth category of the CLI labels Jan 28, 2020
@kaustavghosh06
Copy link
Contributor

kaustavghosh06 commented Jan 28, 2020

@kernwig I'm using CLI version 4.13.1 (latest) and I was able to clone the above-mentioned repo (https://github.com/kernwig/sqac-amplify/tree/part7/go-live3) and run amplify init and successfully run amplify push. The init step asked me for my google client appID and setup my team-provider-info and then amplify auth update worked as expected - please take a look at the flow below for auth update

f45c89966b0d:sqac-amplify kaustavg$ amplify update auth
Please note that certain attributes may not be overwritten if you choose to use defaults settings.

You have configured resources that might depend on this Cognito resource.  Updating this Cognito resource could have unintended side effects.

Using service: Cognito, provided by: awscloudformation
 What do you want to do? Add/Edit signin and signout redirect URIs
 Which redirect signin URIs do you want to edit? http://localhost:4200/
? Update http://localhost:4200/ https://google.com/
 Do you want to add redirect signin URIs? No
 Which redirect signout URIs do you want to edit? https://d3l0j9nusq7n6r.cloudfront.net/
? Update https://d3l0j9nusq7n6r.cloudfront.net/ https://facebook.com/
 Do you want to add redirect signout URIs? No
Successfully updated resource sqacauth locally

Some next steps:
"amplify push" will build all your local backend resources and provision it in the cloud
"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud

Did you follow a different flow which gave you the error?
Also the team-provider-info needs to be checked into source control as we don't store appClientIDs and appClientSecrets in our service. If it's missing we ask questions to re-create the team-provider-info.json file like the following flow:

f45c89966b0d:sqac-amplify kaustavg$ amplify init
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the environment dev
? Choose your default editor: Visual Studio Code
Using default provider  awscloudformation



For more information on AWS Profiles, see:
https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html

? Do you want to use an AWS profile? Yes

? Please choose the profile you want to use default
Adding backend environment dev to AWS Amplify Console app: d3e04hhfww0e6k
⠸ Initializing project in the cloud...

CREATE_IN_PROGRESS DeploymentBucket                AWS::S3::Bucket            Tue Jan 28 2020 12:21:47 GMT-0800 (Pacific Standard Time) Resource creation Initiated
CREATE_IN_PROGRESS UnauthRole                      AWS::IAM::Role             Tue Jan 28 2020 12:21:47 GMT-0800 (Pacific Standard Time) Resource creation Initiated
CREATE_IN_PROGRESS AuthRole                        AWS::IAM::Role             Tue Jan 28 2020 12:21:46 GMT-0800 (Pacific Standard Time) Resource creation Initiated
CREATE_IN_PROGRESS UnauthRole                      AWS::IAM::Role             Tue Jan 28 2020 12:21:46 GMT-0800 (Pacific Standard Time)                            
CREATE_IN_PROGRESS DeploymentBucket                AWS::S3::Bucket            Tue Jan 28 2020 12:21:46 GMT-0800 (Pacific Standard Time)                            
CREATE_IN_PROGRESS AuthRole                        AWS::IAM::Role             Tue Jan 28 2020 12:21:46 GMT-0800 (Pacific Standard Time)                            
CREATE_IN_PROGRESS amplify-sqac-amplify-dev-122138 AWS::CloudFormation::Stack Tue Jan 28 2020 12:21:42 GMT-0800 (Pacific Standard Time) User Initiated             
⠹ Initializing project in the cloud...

CREATE_COMPLETE UnauthRole AWS::IAM::Role Tue Jan 28 2020 12:22:00 GMT-0800 (Pacific Standard Time) 
CREATE_COMPLETE AuthRole   AWS::IAM::Role Tue Jan 28 2020 12:22:00 GMT-0800 (Pacific Standard Time) 
⠹ Initializing project in the cloud...

CREATE_COMPLETE amplify-sqac-amplify-dev-122138 AWS::CloudFormation::Stack Tue Jan 28 2020 12:22:10 GMT-0800 (Pacific Standard Time) 
CREATE_COMPLETE DeploymentBucket                AWS::S3::Bucket            Tue Jan 28 2020 12:22:08 GMT-0800 (Pacific Standard Time) 
✔ Successfully created initial AWS cloud resources for deployments.
✔ Initialized provider successfully.
  
 You've opted to allow users to authenticate via Google.  If you haven't already, you'll need to go to https://developers.google.com/identity an
d create an App ID. 
 
 Enter your Google Web Client ID for your OAuth flow:  xyz
 Enter your Google Web Client Secret for your OAuth flow:  awesome
? Do you want to configure Lambda Triggers for Cognito? No
Initialized your environment successfully.

Your project has been successfully initialized and connected to the cloud!

Some next steps:
"amplify status" will show you what you've added already and if it's locally configured or deployed
"amplify add <category>" will allow you to add features like user login or a backend API
"amplify push" will build all your local backend resources and provision it in the cloud
“amplify console” to open the Amplify Console and view your project status
"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud

Pro tip:
Try "amplify add api" to create a backend API and then "amplify publish" to deploy everything

Could you please try the above mentioned flow with the latest version of the CLI and let us know if you're still stuck with this?

@kernwig
Copy link
Author

kernwig commented Jan 28, 2020

Excluding the team-provider-info.json file is the recommended practice for public repositories, per the end of this part of the documentation: https://aws-amplify.github.io/docs/cli-toolchain/quickstart#sharing-projects-outside-the-team-

I had the team-provider-info.json file. Would the error I experienced be what happens if that file went missing? I assumed that this failure is what deleted it, and then filed Issue #3274 for the failure that follows.

I don't know how else the team-provider-info.json file would vanish, but it was a risk. The OAuth secret really aught to be stored in a separate file so that team-provider-info.json can be source controlled.

@kaustavghosh06
Copy link
Contributor

kaustavghosh06 commented Jan 28, 2020

Correct, if you're making your repo - public you wouldn't want to share the team-provider-info.json file - as it is recommended to source control it only when working with teams and is specific to an individuals deployment. When I pulled in your repo - on the init step I was asked to enter the information which is required to fill in and that created a team-provider-info.json file for my deployment/environment.

Are you sure that the team-provider-info.json file vanished and wasn't a part of the source control in the first place?

@kernwig
Copy link
Author

kernwig commented Jan 28, 2020

It was part of source control. About a month ago I added OAuth, and so removed it from source control before committing the secret. I had copied the file away, git removed it and added to .gitignore, git commit, and then copied it back.

If the stack trace is consistent with that file missing though, then it seems probable that it had disappeared somehow between then and now. I did restore the old version of the file from source control and recovered the OAuth settings upon doing an amplify env pull.

The fact that I wasn't able to recreate that file entirely via amplify env pull is the subject of issue #3274 .

@stale
Copy link

stale bot commented May 9, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented May 16, 2020

This issue has been automatically closed because of inactivity. Please open a new issue if you are still encountering problems.

@stale stale bot closed this as completed May 16, 2020
@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 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auth Issues tied to the auth category of the CLI pending-triage Issue is pending triage platform Issues tied to the general CLI platform
Projects
No open projects
Development

No branches or pull requests

3 participants