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

[hostedUIProviderCreds] do not exist in the template

Open R70YNS opened this issue 1 year ago • 5 comments

How did you install the Amplify CLI?

No response

If applicable, what version of Node.js are you using?

No response

Amplify CLI Version

12.10.1

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Describe the bug

Unable to push latest changes to Amplify environment due to bug, 'Reason: [hostedUIProviderCreds] do not exist in the template.

~/.aws/amplify/deployment-secrets.json contains the following for the environment:

{
  "appSecrets": [
    {
      "rootStackId": "ROOT_STACK_ID",
      "environments": {
        "ENV_NAME": {
          "ENV": {
            "COGNITO_USER_POOL": {
              "hostedUIProviderCreds": "[]"
            }
          }
        }
      }
    }
}

But I still receive the issue when trying to push latest changes.

Re-adding:

{
    "hostedUIProviderCreds: "[]"
}

within team-provider-info.json auth field regenerates deployment-secrets.json but still fails to push with the above error remaining.

Deleting the amplify directory, re-pulling and attempting to push new changes still results in the error.

This issue has been reported in previous Github issues and still occurs in latest CLI.

  • https://github.com/aws-amplify/amplify-cli/issues/6563
  • https://github.com/aws-amplify/amplify-cli/issues/5942

Expected behavior

Specifying hostedUIProviderCreds within deployment-secrets.json should enable user to push changes to environment.

Pulling an environment should created default variable when unable to access environment variables related to identify providers.

Reproduction steps

Unsure, but most likely related to external authentication provider.

  • Add external authentication provider
  • Pull/update amplify project
  • Remove authentication provider in AWS console
  • Re-pull/update Amplify project
  • Attempt to push changes

Project Identifier

No response

Log output

# Put your logs below this line

🛑 The following resources failed to deploy:
Resource Name: XYZ (AWS::CloudFormation::Stack)
Event Type: update
Reason: Parameters: [hostedUIProviderCreds] do not exist in the template

Additional information

No response

Before submitting, please confirm:

  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

R70YNS avatar Feb 11 '24 17:02 R70YNS

Hey @R70YNS, thank you for reaching out. could you try running amplify update auth, select Update OAuth social providers, re-enter the credentials and run amplify push. This should update the ~/.aws/amplify/deployment-secrets.json file

ykethan avatar Feb 12 '24 17:02 ykethan

Hi @ykethan

I've tried the above:

amplify update auth
Update OAuth social providers
(Purposely didn't select any) and pressed enter
amplify push 

This still results in being unable to push any updates, even with the updated deployment-secrets.json file

R70YNS avatar Feb 16 '24 11:02 R70YNS

To confirm, it gave the same error message:

🛑 The following resources failed to deploy:
Resource Name: authxyz (AWS::CloudFormation::Stack)
Event Type: update
Reason: Parameters: [hostedUIProviderCreds] do not exist in the template

Tested on both Mac & Linux

R70YNS avatar Feb 16 '24 11:02 R70YNS

Another issue related to the above, raised awhile back.

https://github.com/aws-amplify/amplify-cli/issues/3642

Unfortunately the known fix of adding "hostedUIProviderCreds": "[]" to team-provider-info.json no longer seems to work, instead just prompting to generate deployment-secrets.json instead.

Even though deployment-secrets.json contains the field hostedUIProviderCreds for the relevant environment it still fails as above.

R70YNS avatar Feb 16 '24 12:02 R70YNS

Hey @R70YNS, could you provide us the project identifier by running amplify diagnose --send-report?

Remove authentication provider in AWS console

noticed this, could provide us some information on how the authentication provider was removed?

ykethan avatar Feb 17 '24 02:02 ykethan

Project Identifier: bb01826d6e9e4d639ab999b6a0e018db

Authentication provider was removed via console via Cognito -> User pool -> Sign-in experience -> Federated Identity provider sign-in. I did notice though that the same thing was done in a different environment and this still works fine.

In trying to resolve the above, I deleted the local amplify directory and re-pulled via amplify pull --appId xyz --envName envName but this still resulted in the same issue.

R70YNS avatar Feb 19 '24 09:02 R70YNS

Hey @R70YNS, could you try the following

  1. run amplify update auth -> Update OAuth social providers. deselect the providers.
  2. remove the deployment secrets from team-provider-info.json
  3. delete the ~/.aws/amplify/deployment-secrets.json file
  4. then run amplify push

ykethan avatar Feb 21 '24 19:02 ykethan

Hi @ykethan

My team-provider-info.json file contains:

{
    "auth": {
        "{{ resource name }}": {}
      }
}

I've removed deployment-secrets.json.

I didn't have any social providers selected, so purposely selected one and then deselected it. This changed my Auth resource when doing amplify status.

I then tried pushing via amplify push --force but still receive the issue.

🛑 The following resources failed to deploy:
Resource Name: XYZ (AWS::CloudFormation::Stack)
Event Type: update
Reason: Parameters: [hostedUIProviderCreds] do not exist in the template

Since the above failed, I deleted my amplify directory completely, re-pulled it, and without any modification tried doing amplify push --force. I still wasn't able to update it and received the same issue:

🛑 Resource is not in the state stackUpdateComplete
Name: XYZ (AWS::CloudFormation::Stack), Event Type: update, Reason: Parameters: [hostedUIProviderCreds] do not exist in the template, IsCustomResource: false

I think this clearly shows there is an error in the CLI when pulling the environment. I'm unable to correct it even when using the --force parameter.

R70YNS avatar Feb 26 '24 10:02 R70YNS

@R70YNS thank you for the information. From the project identifier did not observe any reference in the cli-inputs.json or backend-config.json but noticed a reference in the root-cloudformation-stack.json. Do you observe hostedUIProviderCreds in the amplify-meta.json under the auth block?

ykethan avatar Feb 26 '24 22:02 ykethan

Hi @ykethan

I don't have a amplify-meta.json locally, but within the deploymentBucket in S3 there is an amplify-meta.json file. It only contains a awscloudformation field underneath providers. I cannot see a hostedUIProviderCreds within the file.

R70YNS avatar Feb 28 '24 16:02 R70YNS

I've tried regenerating deployment-secrets.json aswell as modifying as below:

{
      "rootStackId": "xxxx-xxxx-xxxx-xxxx",
      "environments": {
        "xxxx": {
          "ENV": {
            "COGNITO_USER_POOL": {
              "hostedUIProviderCreds": "[]"
            }
          },
          "auth": {
            "$RESOURCE_NAME": {
              "hostedUIProviderCreds": "[]"
            }
          }
        }
      }
    }

But both still fail with Event Type: update, Reason: Parameters: [hostedUIProviderCreds] do not exist in the template

R70YNS avatar Feb 28 '24 17:02 R70YNS

Hey @R70YNS, would be open for a quick call wanted to dive into the project. I am available on discord and my handle is ykethan

ykethan avatar Feb 28 '24 20:02 ykethan

Resolved with @ykethan. Updated CLI and re-generated deployment-secrets.json by re-adding:

"hostedUIProviderCreds": "[]"

under resource within auth field in team-provider.json

There was valid config already in deployment-secrets.json, but running amplify push after updating the CLI and triggering the changeover to generate deployment-secrets.json worked.

R70YNS avatar Feb 29 '24 17:02 R70YNS

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Feb 29 '24 17:02 github-actions[bot]