amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

amplify push hosting has errror ... TypeError: Cannot read property 'client_id' of undefined

Open tatsuyoshi-mashiko opened this issue 6 years ago • 13 comments

Describe the bug When I try to push for amplify hosting. That had error.

UPDATE_FAILED
HostedUIProvidersCustomResourceInputs
Custom::LambdaCallout      Mon Mar 30 2020 18:57:29 GMT+0900 (Japan Standard Time) Failed to update resource. See the details in CloudWatch Log Stream: 2020/03/30/[$LATEST]xxxxxx
UPDATE_ROLLBACK_IN_PROGRESS amplify-xxx-dev-xxxxxx
AWS::CloudFormation::Stack Mon Mar 30 2020 18:57:30 GMT+0900 (Japan Standard Time) The following resource(s) failed to update: [HostedUIProvidersCustomResourceInputs].                                     
⠏ Updating resources in the cloud. This may take a few minutes...

UPDATE_FAILED
authxxxxxxxxx
AWS::CloudFormation::Stack Mon Mar 30 2020 18:57:39 GMT+0900 (Japan Standard Time) Embedded stack arn:aws:cloudformation:ap-northeast-1:xxxxxx:stack/amplify-xxxx-dev-202249-authxxxxxxx-xxxxx/xxxxx-1111-11ea-xxxx-xxxxxxxx was not successfully updated. 
Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to update: [HostedUIProvidersCustomResourceInputs]. 
CREATE_FAILED
hostingS3AndCloudFront AWS::CloudFormation::Stack Mon Mar 30 2020 18:57:39 GMT+0900 (Japan Standard Time) Resource creation cancelled                                                                                                                                                                               

Also the cloud watch error is following.

2020-03-30T09:57:27.950Z	xxxx-xxxx-xxxx-xxxx-xxxx
INFO. TypeError: Cannot read property 'client_id' of undefined
    at getRequestParams (/var/task/index.js:1:1053)
    at updateIdentityProvider (/var/task/index.js:1:1635)
    at hostedUIProviderMeta.forEach (/var/task/index.js:1:2373)
    at Array.forEach (<anonymous>)
    at identity.listIdentityProviders.promise.then (/var/task/index.js:1:2249)
    at process._tickCallback (internal/process/next_tick.js:68:7)
{
    "Status": "FAILED",
    "Reason": "See the details in CloudWatch Log Stream: 2020/03/30/[$LATEST]xxxx",
    "PhysicalResourceId": "2020/03/30/[$LATEST]xxxxx",
    "StackId": "arn:aws:cloudformation:ap-northeast-1:xxxxx:stack/amplify-xxx-dev-xxxx-authxxxx-xxxxxx/xxxxx-xxxx-xxxx-xxxx-xxxx",
    "RequestId": "xxxx-xxxxx-xxxx-xxxx-xxxxxx",
    "LogicalResourceId": "HostedUIProvidersCustomResourceInputs",
    "NoEcho": false,
    "Data": {
        "err": {}
    }
}

Amplify CLI Version

$ amplify -v
4.17.2

To Reproduce

$ amplify add hosting
$ amplify status

Current Environment: dev

| Category | Resource name               | Operation | Provider plugin   |
| -------- | --------------------------- | --------- | ----------------- |
| Hosting  | S3AndCloudFront             | Create    | awscloudformation |
| Auth     | xxxxxxx                 | No Change    | awscloudformation |
| Function | xxxxCustomMessage    | No Change | awscloudformation |
| Function | xxxxPostConfirmation | No Change | awscloudformation |
| Function | AdminQueriesxxxxx        | No Change | awscloudformation |
| Auth     | userPoolGroups              | No Change | awscloudformation |
| Api      | xxx                         | No Change | awscloudformation |
| Api      | AdminQueries                | No Change | awscloudformation |
| Storage  | xxxx                  | No Change | awscloudformation |

GraphQL endpoint: https://xxxx.appsync-api.ap-northeast-1.amazonaws.com/graphql
Hosted UI Endpoint: https://xxxx-xxxx-dev.auth.ap-northeast-1.amazoncognito.com/
Test Your Hosted UI Endpoint: https://xxxx-xxxx-dev.auth.ap-northeast-1.amazoncognito.com/login?response_type=code&client_id=xxxx&xxxirect_uri=http://localhost:3000/thankyou/

$ amplify push 
...
UPDATE_FAILED
HostedUIProvidersCustomResourceInputs
Custom::LambdaCallout      Mon Mar 30 2020 18:57:29 GMT+0900 (Japan Standard Time) Failed to update resource. See the details in CloudWatch Log Stream: 2020/03/30/[$LATEST]xxxxxx
UPDATE_ROLLBACK_IN_PROGRESS amplify-xxx-dev-xxxxxx
AWS::CloudFormation::Stack Mon Mar 30 2020 18:57:30 GMT+0900 (Japan Standard Time) The following resource(s) failed to update: [HostedUIProvidersCustomResourceInputs].                                     
⠏ Updating resources in the cloud. This may take a few minutes...

UPDATE_FAILED
authxxxxxxxxx
AWS::CloudFormation::Stack Mon Mar 30 2020 18:57:39 GMT+0900 (Japan Standard Time) Embedded stack arn:aws:cloudformation:ap-northeast-1:xxxxxx:stack/amplify-xxxx-dev-xxxxx-authxxxxxxx-xxxxx/xxxxx-1111-11ea-xxxx-xxxxxxxx was not successfully updated. 
Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to update: [HostedUIProvidersCustomResourceInputs]. 
CREATE_FAILED
hostingS3AndCloudFront AWS::CloudFormation::Stack Mon Mar 30 2020 18:57:39 GMT+0900 (Japan Standard Time) Resource creation cancelled   

Expected behavior I want to deploy amplify hosting with success.

  • Amplify hosting is success
  • Deploy to Nuxtjs with spa mode.

Desktop

  • OS: OSX Mojave 10.14.5 (18F132)
  • Node Version v10.16.3

tatsuyoshi-mashiko avatar Mar 30 '20 10:03 tatsuyoshi-mashiko

Just running amplify push instead of amplify hosting push should solve the issue. Can you please try that?

kaustavghosh06 avatar Mar 30 '20 15:03 kaustavghosh06

@kaustavghosh06 Thank you for reply. I tried that but I got same error...

$ amplify hosting push
...
UPDATE_FAILED               HostedUIProvidersCustomResourceInputs                Custom::LambdaCallout      Tue Mar 31 2020 13:13:40 GMT+0900 (Japan Standard Time) Failed to update resource. See the details in CloudWatch Log Stream: 2020/03/31/[$LATEST]xxxxxx

UPDATE_FAILED               authxxxxxxx        AWS::CloudFormation::Stack Tue Mar 31 2020 13:13:49 GMT+0900 (Japan Standard Time) Embedded stack arn:aws:cloudformation:ap-northeast-1:xxxxx:stack/amplify-xxx-dev-xxxx-authxxxxx-xxxxxx/xxxxxx-xxxx-xxxx-xxxx-xxxxxx was not successfully updated. Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to update: [HostedUIProvidersCustomResourceInputs]. 
CREATE_FAILED               hostingS3AndCloudFront AWS::CloudFormation::Stack Tue Mar 31 2020 13:13:49 GMT+0900 (Japan Standard Time) Resource creation cancelled  

cloud watch log.

2020-03-31T04:13:38.849Z	xxxx-xxxx-xxxx-xxxx-xxxxxx	INFO	TypeError: Cannot read property 'client_id' of undefined
    at getRequestParams (/var/task/index.js:1:1053)
    at updateIdentityProvider (/var/task/index.js:1:1635)
    at hostedUIProviderMeta.forEach (/var/task/index.js:1:2373)
    at Array.forEach (<anonymous>)
    at identity.listIdentityProviders.promise.then (/var/task/index.js:1:2249)
    at process._tickCallback (internal/process/next_tick.js:68:7)
2020-03-31T04:13:38.850Z	a2341d3a-4a55-4570-ae06-bcff9a692cb4	INFO	Response body:
 
{
    "Status": "FAILED",
    "Reason": "See the details in CloudWatch Log Stream: 2020/03/31/[$LATEST]xxxxxx",
    "PhysicalResourceId": "2020/03/31/[$LATEST]xxxxxx",
    "StackId": "arn:aws:cloudformation:ap-northeast-1:xxx:stack/amplify-xxx-dev-xxxx-authrxxxx-xxxx/xxxxx-xxxx-xxxx-xxxx-xxxxx",
    "RequestId": "xxxxxx-xxxx-xxxx-xxxx-xxxx",
    "LogicalResourceId": "HostedUIProvidersCustomResourceInputs",
    "NoEcho": false,
    "Data": {
        "err": {}
    }
}

tatsuyoshi-mashiko avatar Mar 31 '20 04:03 tatsuyoshi-mashiko

I have multiple github repositories and these are using same amplify cloud formation. (customer, admin)

I can't across to use multiple github repositories when I use amplify?

tatsuyoshi-mashiko avatar Mar 31 '20 04:03 tatsuyoshi-mashiko

@kaustavghosh06 I'm having the exact same problem. I'm running amplify push because this is a React Native app. Notice that the failure is this:

TypeError: Cannot read property 'client_id' of undefined

And is related to a cloud formation update of HostedUIProvidersCustomResourceInputs, and it also started occuring after adding Facebook federation to Cognito.

Something seems to be missing. Any ideas what it could be?

andreialecu avatar Apr 02 '20 12:04 andreialecu

I was able to figure it out.

We were using two environments: dev and prod. The prod environment was missing the Facebook credentials in amplify/team-provider-info.json, only the dev one had it.

So:

"prod": {
        "awscloudformation": {
            ...
        },
        "categories": {
            "auth": {
                "XXXXXXXXXXXXXXX": {
                    "hostedUIProviderCreds": "[{\"ProviderName\":\"Facebook\",\"client_id\":\"XXXXXXX\",\"client_secret\":\"XXXXX\"}]"
                }
            },

The above was needed, it was initially an empty array [].

andreialecu avatar Apr 02 '20 12:04 andreialecu

I had the same issue but with Google as provider, this solution worked

jesuscovam avatar Mar 28 '21 21:03 jesuscovam

Still seeing this in 4.49.0

The hostedUIProviderCreds fix worked the first time, although those values were removed from the team-provider.json file after this step:

? Amplify has been upgraded to handle secrets more securely by migrating some values in team-provider-info.json to deployment-secrets.json

But after making updates to the API component and attempting to push the changes, the same "client_id" error popped up as before.

ajhool avatar Apr 21 '21 04:04 ajhool

Having the same issue. Is there any fix for the same? It's actually taking more time to get the amplify cli work than coding the app. I'm using amplify cli 4.50.2

indrajitb avatar May 12 '21 17:05 indrajitb

Hi @indrajitb,

I had the same problem and I solved it by following the same procedure as @andreialecu but instead of doing it in amplify/team-provider-info.json, I had to do it in ~/.aws/amplify/deployment-secrets.json as these information are moved there with latest versions of the amplify cli

TheMoums avatar Jun 01 '21 14:06 TheMoums

Hello @TheMoums - Thank you for taking your time to share your suggestion. I checked the file that you mentioned (~/.aws/amplify/deployment-secrets.json), the credentials for both FB and Google were present. What ultimately I did was to again run amplify update auth again ! It fixed for me !

indrajitb avatar Jun 11 '21 08:06 indrajitb

The thing that solved it for me was switching to my computer with access to all the social logins I was using. For me, I was using Login with apple, and that can't be configured on windows. So, often when I would run amplify push on Windows I would get the error you are describing, but whenever I used my Macbook it would work.

bencoopertx avatar Jun 17 '21 01:06 bencoopertx

the same thing happened to me @ajhool.

I'm not able to reproduce it now but I'm sure it happened when I set up the auth mechanism using Admin UI and then went back to CLI (Windows installation). I wasn't aware of the ~/.aws/amplify/deployment-secrets.json file thank you @TheMoums , after update its contents it worked

oscarnevarezleal avatar Jul 11 '21 11:07 oscarnevarezleal

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[bot] avatar Sep 10 '21 01:09 github-actions[bot]