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

Amplify Console Build Failure - facebookAppId, amazonAppId, googleClientId, hostedUIProviderCreds] must have values #206

Closed
KidSysco opened this issue Oct 22, 2019 · 135 comments
Labels
archived This issue has been locked. backend-builds bug Something isn't working

Comments

@KidSysco
Copy link

KidSysco commented Oct 22, 2019

I added auth to my project with the Facebook, Google, and Amazon Logins. I got Cognito working well, so I decided to add an API using the AppPool for security.

I added the default graphQL API that adds todos with a simple one-to-many relationship, I ran amplify push and everything worked great. AppSync, Dynamo, and Cognito were all looking perfectly in each console.

I committed my code to git and pushed, which kicked off an Amplify Console build that failed with the following error message. Notice how it is complaining that it cannot find values for my facebookAppId, amazonAppId, googleClientId, hostedUIProviderCreds. That is confusing because Cognito is working perfectly with all 3 providers...

UPDATE_FAILED               authdevilsswille50c45c5         AWS::CloudFormation::Stack Tue Oct 22 2019 14:04:31 GMT+0000 (Coordinated Universal Time) Parameters: [facebookAppId, amazonAppId, googleClientId, hostedUIProviderCreds] must have values

I expected the Amplify console to be able to build and deploy this project since amplify push worked fine from my machine.

If I remove the API, Cognito still works fine, I can commit and push at this point and the Amplify Console will build and deploy my project fine.

Any insight is always appreciated.

@swaminator swaminator added backend-builds bug Something isn't working labels Oct 29, 2019
@swaminator
Copy link
Contributor

@KidSysco are you creating a new backend environment through the Amplify Console or are you reusing one created through the CLI?

@KidSysco
Copy link
Author

KidSysco commented Oct 30, 2019

That is a really good question, I guess it is unclear what I am supposed to do here.

I use the CLI to push everything and test my code locally.

In the Amplify Console, I noticed there is a setting only available when setting up the app for the first time. It asks me if I want to deploy the backend, or only deploy the front end. I tried to change this setting after the app was created but I was unable to find a way. The only way to change that setting appears to be to delete the app from the Amplify Console and add it again.

Even when I deleted the app, added it again so I could try to only deploy the front end, I ran into permissions problems. I followed the directions to remove the aws-exports.js file from the GitIgnore file. But once I hit save, it complained about the role that is needed to deploy backend resources and gave me an error. However, it still added the app, but it would not deploy and just gives me a permissions error about the account needed to deploy the backend resources whenever it tries to build.

@ihao8
Copy link
Contributor

ihao8 commented Nov 11, 2019

@KidSysco The amplifyPush script has an issue with new stack creation when using social federation. As a workaround you could try:

  1. Create your own amplifypush.sh like myamplifypush.sh in root folder amplify-auth-app/myamplifypush.sh
  2. Add your authconfigs to the bash script
#!/usr/bin/env bash
set -e
IFS='|'
help_output () {
    echo "usage: amplify-push <--environment|-e <name>> <--simple|-s>"
    echo "  --environment  The name of the Amplify environment to use"
    echo "  --simple  Optional simple flag auto-includes stack info from env cache"
    exit 1
}

init_env () {
    ENV=$1
    AMPLIFY=$2
    PROVIDERS=$3
    CODEGEN=$4
    AWSCONFIG=$5
    CATEGORIES=$6
    echo "# Start initializing Amplify environment: ${ENV}"
    if [[ -z ${STACKINFO} ]];
    then
        echo "# Initializing new Amplify environment: ${ENV} (amplify init)"
        amplify init --amplify ${AMPLIFY} --providers ${PROVIDERS} --codegen ${CODEGEN} --categories ${CATEGORIES} --yes;
        echo "# Environment ${ENV} details:"
        amplify env get --name ${ENV}
    else
        echo "STACKINFO="${STACKINFO}
        echo "# Importing Amplify environment: ${ENV} (amplify env import)"
        amplify env import --name ${ENV} --config "${STACKINFO}" --awsInfo ${AWSCONFIG} --categories ${CATEGORIES} --yes;
        echo "# Initializing existing Amplify environment: ${ENV} (amplify init)"
        amplify init --amplify ${AMPLIFY} --providers ${PROVIDERS} --codegen ${CODEGEN} --yes;
        echo "# Environment ${ENV} details:"
        amplify env get --name ${ENV}
    fi
    echo "# Done initializing Amplify environment: ${ENV}"
}

ENV=""
IS_SIMPLE=false
POSITIONAL=()
while [[ $# -gt 0 ]]
do
    key="$1"
    case ${key} in
        -e|--environment)
            ENV=$2
            shift
            ;;
        -r|--region)
            REGION=$2
            shift
            ;;
        -s|--simple)
            IS_SIMPLE=true
            shift
            ;;
        *)
            POSITIONAL+=("$1")
            shift
            ;;
    esac
done

set -- "${POSITIONAL[@]}"

# if no provided environment name, use default env variable, then user override
if [[ ${ENV} = "" ]];
then
    ENV=${AWS_BRANCH}
fi
if [[ ${USER_BRANCH} != "" ]];
then
    ENV=${USER_BRANCH}
fi

# Check valid environment name
if [[ -z ${ENV} || "${ENV}" =~ [^a-zA-Z0-9\-]+ ]] ; then help_output ; fi

AWSCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":true,\
\"profileName\":\"default\"\
}"

AMPLIFY="{\
\"envName\":\"${ENV}\"\
}"

PROVIDERS="{\
\"awscloudformation\":${AWSCONFIG}\
}"

CODEGEN="{\
\"generateCode\":false,\
\"generateDocs\":false\
}"

AUTHCONFIG="{\
\"facebookAppIdUserPool\":\"888888888888888\",\
\"facebookAppSecretUserPool\":\"88888888888888888\"\
}"

CATEGORIES="{\
\"auth\":$AUTHCONFIG\
}"

# Handle old or new config file based on simple flag
if [[ ${IS_SIMPLE} ]];
then
    echo "# Getting Amplify CLI Cloud-Formation stack info from environment cache"
    export STACKINFO="$(envCache --get stackInfo)"
    init_env ${ENV} ${AMPLIFY} ${PROVIDERS} ${CODEGEN} ${AWSCONFIG} ${CATEGORIES}
    echo "# Store Amplify CLI Cloud-Formation stack info in environment cache"
    STACKINFO="$(amplify env get --json --name ${ENV})"
    envCache --set stackInfo ${STACKINFO}
    echo "STACKINFO="${STACKINFO}
else
    # old config file, above steps performed outside of this script
    init_env ${ENV} ${AMPLIFY} ${PROVIDERS} ${CODEGEN} ${AWSCONFIG} ${CATEGORIES}
fi
  1. Edit Build setting in amplify console
version: 0.1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - chmod u+x ./myamplifypush.sh
        - ./myamplifypush.sh
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
  1. Redeploy the app

This worked on my app. If you could not reproduce it, please let me know.

@ihao8 ihao8 added the pending-prioritization Added to the backlog. Pending prioritization. label Nov 20, 2019
@swaminator swaminator changed the title Amplify Console Build Failure Amplify Console Build Failure - facebookAppId, amazonAppId, googleClientId, hostedUIProviderCreds] must have values Dec 2, 2019
@kevin-mitchell
Copy link

I'm having similar issues, or at least they appear to be closely related. I posted details here https://github.com/aws-amplify/amplify-cli/issues/2833

@KidSysco
Copy link
Author

KidSysco commented Dec 9, 2019

Yep, looks exactly the same as my experience.

@kevin-mitchell
Copy link

@KidSysco what are you doing in the meantime? Are you just deploying via amplify push && amplify publish locally in the cli?

@KidSysco
Copy link
Author

Pushing locally worked fine, and all functions worked fine locally. So I could develop locally but I just couldn't get it to production.

I decided to give amplify publish a try by setting up the publishing options in Amplify that would post the website to an S3 bucket, instead of using the Amplify Console.

However, amplify publish to S3 did not work for me either.

Same error.

I think what Joycehao19 said above is correct...

"The amplifyPush script has an issue with new stack creation when using social federation."

Official AWS Support just sent me to GitHub for Amplify support, but I was already here.

So I froze the idea there and moved on to write classic Restify services on an EC2 linux instance.

I think you could try to remove all social media functions and try it. I want to say I tried that and it did not work either, but based on what Joyce said above, it might work. I can't remember from a month ago. I also don't have any more time to sink into testing this for AWS. I already have a job, and a boss, and many deadlines of my own. lol

However, I am keeping on eye on Amplify and this issue. I will still comment and help out the community if I can.

I absolutely love the idea of Amplify, they need to keep pushing... But if you really need to go serverless, the best option right now is Azure. AWS is very new to writing dev tools, MS has been doing this since the dawn of time. The MS tools are very slick, from ORM (Entity Framework), to Web Server, source control, to multiple environments of Cloud resources. All one company. They are light years ahead in that game.

Fortunately for me, I do not NEED to go serverless right now, we are not huge fans of MS either. And we still get lots done on EC2, in record time.

Keep us posted if you make any break throughs!

@kevin-mitchell
Copy link

Thanks for all of the info, the insight / experiences you've had are super helpful as I think through this stuff.

RE: try without social, in my case social sign in is actually the ONLY option that I want to support. My "app" is for a limited set of "internal" users (hint: it's actually my family :)), but I want to build something robust / secure as a way to learn a new set of tools (e.g. Amplify) for evaluation in future professional projects. In my case, I know my family members all have gmail accounts so I want them to just sign in with Google credentials and save worry about / thinking about anything else.

RE: switching to something else, honestly Amplify is just sort of the entry point for a bunch of other things going on. Most important is AWS IoT, which I've spent a decent chunk of time implementing on physical hardware I'm making, so I'm pretty married to AWS at the moment.

I think for now I'll wait and watch this ticket and see what happens. I don't need to go to "production" at the moment, and truthfully I could live with only a single production environment if that solved my issue.

@KidSysco
Copy link
Author

I understand completely.

As a Node.js programmer, the huge answer for social media SSO is passport.js.

However, I prefer Restify over Express, which has lead a pretty big divide in the Node community I'd say.

Passport.js is express based.

There are other services out there that are like Cognito, and we could use them too. I even have some training here from Udemy.com on getting AWS Developer certified. That class teaches new folks how to use Cognito directly using an older jQuery style of programming. It was not Vue, or React.

However, my instructor clearly indicated to his class that Amplify was not ready for production. I didn't believe him. I ended up here anyway because AWS makes amplify sound so awesome. I couldn't resist, even though I was warned by my instructor who was an Amplify Beta user.

I eventually decided that oAuth and social SSO logins are not really worth it on this platform yet.

Restify seems to have a real problem with JWT, and the AWS answer for something like that is just too much work to justify. There are easier ways to get social media SSO, but honestly, just writing my own login form seems to be much less work than all of this. Once I gave up on this, I started making huge gains in progress just writing it myself.

Now on Azure... OAuth was all super slick. This is why Amplify deserves a chance...

Years ago when I was on Azure, the default new project in Visual Studio for creating a new site, ships with oAuth stuff built in, all you need to do is fill in the keys and secrets into your code. No services needed, no passport.js, no express, OAuth just worked there. And that was back in 2015.

I know how it is supposed to work, because I have seen things like this elsewhere.

So it's just not worth fighting the platform. If it's not ready, then it's just not ready yet.

But DOn't get me wrong, I am still AWS 4 LYFE!!!! WOOT!!!!

So I agree, let's watch and see what happens next!

@w3kp
Copy link

w3kp commented Dec 22, 2019

Confirming @Joycehao19 's workaround. This worked also on my end. Just did a little adjustment on the AUTH_CONFIG for social feds authentication. Created config variables per environment on App settings > Environment variables tab and use it in my custom amplify push script myamplifypush.sh like below.

AUTHCONFIG="{\
\"googleAppIdUserPool\":\"${GOOGLE_CLIENT_ID}\",\
\"googleAppSecretUserPool\":\"${GOOGLE_CLIENT_SECRET}\",\
\"loginwithamazonAppIdUserPool\":\"${AMAZON_APP_ID}\",\
\"loginwithamazonAppSecretUserPool\":\"${AMAZON_APP_SECRET}\"\
}"

Then push and redeploy environment(s). I have 3 environments as of the moment master, local, staging with different auth config in each cognito per env respectively. Working fine now. Thanks!

@danieletieghi
Copy link

@Joycehao19 's workaround seemed to work for me for the "Backend" phase of the build process which now passes, but now it hangs on the "Frontend" phase (which was working fine before I ended up in this mess) because it seams the file aws-exports.js is no longer generated. Any suggestions?

@yuyokk
Copy link

yuyokk commented Jan 5, 2020

Facing Error: auth headless init is missing the following inputParams facebookAppIdUserPool, facebookAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool as well.
Unfortunately, the workaround did not help us :(

@yuyokk
Copy link

yuyokk commented Jan 5, 2020

Based on the comment, I modified the script from here and it worked for me

#!/usr/bin/env bash
set -e
IFS='|'
help_output () {
    echo "usage: amplify-push <--environment|-e <name>> <--simple|-s>"
    echo "  --environment  The name of the Amplify environment to use"
    echo "  --simple  Optional simple flag auto-includes stack info from env cache"
    exit 1
}

init_env () {
    ENV=$1
    AMPLIFY=$2
    PROVIDERS=$3
    CODEGEN=$4
    AWSCONFIG=$5
    CATEGORIES=$6
    echo "# Start initializing Amplify environment: ${ENV}"
    if [[ -z ${STACKINFO} ]];
    then
        echo "# Initializing new Amplify environment: ${ENV} (amplify init)"
        amplify init --amplify ${AMPLIFY} --providers ${PROVIDERS} --codegen ${CODEGEN} --categories ${CATEGORIES} --yes;
        echo "# Environment ${ENV} details:"
        amplify env get --name ${ENV}
    else
        echo "STACKINFO="${STACKINFO}
        echo "# Importing Amplify environment: ${ENV} (amplify env import)"
        amplify env import --name ${ENV} --config "${STACKINFO}" --awsInfo ${AWSCONFIG} --categories ${CATEGORIES} --yes;
        echo "# Initializing existing Amplify environment: ${ENV} (amplify init)"
        amplify init --amplify ${AMPLIFY} --providers ${PROVIDERS} --codegen ${CODEGEN} --categories ${CATEGORIES} --yes;
        echo "# Environment ${ENV} details:"
        amplify env get --name ${ENV}
    fi
    echo "# Done initializing Amplify environment: ${ENV}"
}

ENV=""
IS_SIMPLE=false
POSITIONAL=()
while [[ $# -gt 0 ]]
do
    key="$1"
    case ${key} in
        -e|--environment)
            ENV=$2
            shift
            ;;
        -r|--region)
            REGION=$2
            shift
            ;;
        -s|--simple)
            IS_SIMPLE=true
            shift
            ;;
        *)
            POSITIONAL+=("$1")
            shift
            ;;
    esac
done

set -- "${POSITIONAL[@]}"

# if no provided environment name, use default env variable, then user override
if [[ ${ENV} = "" ]];
then
    ENV=${AWS_BRANCH}
fi
if [[ ${USER_BRANCH} != "" ]];
then
    ENV=${USER_BRANCH}
fi

# Check valid environment name
if [[ -z ${ENV} || "${ENV}" =~ [^a-zA-Z0-9\-]+ ]] ; then help_output ; fi

AWSCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":true,\
\"profileName\":\"default\"\
}"

AMPLIFY="{\
\"envName\":\"${ENV}\"\
}"

PROVIDERS="{\
\"awscloudformation\":${AWSCONFIG}\
}"

CODEGEN="{\
\"generateCode\":false,\
\"generateDocs\":false\
}"

AUTHCONFIG="{\
\"facebookAppIdUserPool\":\"XXXXXXXXXXXXXX\",\
\"facebookAppSecretUserPool\":\"XXXXXXXXXXXXXX\"\
}"

CATEGORIES="{\
\"auth\":$AUTHCONFIG\
}"

# Handle old or new config file based on simple flag
if [[ ${IS_SIMPLE} ]];
then
    echo "# Getting Amplify CLI Cloud-Formation stack info from environment cache"
    export STACKINFO="$(envCache --get stackInfo)"
    init_env ${ENV} ${AMPLIFY} ${PROVIDERS} ${CODEGEN} ${AWSCONFIG} ${CATEGORIES}
    echo "# Store Amplify CLI Cloud-Formation stack info in environment cache"
    STACKINFO="$(amplify env get --json --name ${ENV})"
    envCache --set stackInfo ${STACKINFO}
    echo "STACKINFO="${STACKINFO}
else
    # old config file, above steps performed outside of this script
    init_env ${ENV} ${AMPLIFY} ${PROVIDERS} ${CODEGEN} ${AWSCONFIG} ${CATEGORIES}
fi

@BabyDino
Copy link

For some reason I am really struggling with the --categories parameter on amplify init. I cannot find any documentation on it and I cannot get the CATEGORIES with AUTHCONFIG to work. At this point I'm not even sure if I am in the right direction.

Every time I run the script, I am unable to add environment variables like @paulbartocillo to the script.

In the team-provider-info.json file I expect:

"categories": {
  "auth": {
    "cognito": {
      "myVar": "abc",
      "myOtherVar": "def"
    }
  },
  "function": {
    "functionName": {
      "RECAPTCHASECRET": "6Lfy_..."
    }
  }
}

Instead, I get all empties:

"categories": {
  "auth": {
    "cognito": {}
  },
  "function": {
    "functionName": {}
  }
}

Anyone who can point me in the right direction? I am using myscript.sh --environment test --simple . It works alright, but I really need those custom variables.

Many thanks!

@evertson90
Copy link

Any update on this issue that is not the workaround mentioned above?

@evertson90
Copy link

Facing Error: auth headless init is missing the following inputParams facebookAppIdUserPool, facebookAppSecretUserPool, googleAppIdUserPool, googleAppSecretUserPool as well.
Unfortunately, the workaround did not help us :(

Make sure you have the right amount of quotes and backslashes when adding your own "AUTH" variables.

It didn't work for me either because I had a "/" too much.

@vajafari
Copy link

vajafari commented Feb 9, 2020

I face this problem and solve it.
1- Create amplfypush.sh file and add it to the root of project and put the following scripts in it:


#!/usr/bin/env bash
set -e
IFS='|'
help_output () {
    echo "usage: amplify-push <--environment|-e <name>> <--simple|-s>"
    echo "  --environment  The name of the Amplify environment to use"
    echo "  --simple  Optional simple flag auto-includes stack info from env cache"
    exit 1
}

init_env () {
    ENV=$1
    AMPLIFY=$2
    PROVIDERS=$3
    CODEGEN=$4
    AWSCONFIG=$5
    CATEGORIES=$6
    echo "# Start initializing Amplify environment: ${ENV}"
    if [[ -z ${STACKINFO} ]];
    then
        echo "# Initializing new Amplify environment: ${ENV} (amplify init)"
        amplify init --amplify ${AMPLIFY} --providers ${PROVIDERS} --codegen ${CODEGEN} --categories ${CATEGORIES} --yes;
        echo "# Environment ${ENV} details:"
        amplify env get --name ${ENV}
    else
        echo "STACKINFO="${STACKINFO}
        echo "# Importing Amplify environment: ${ENV} (amplify env import)"
        amplify env import --name ${ENV} --config "${STACKINFO}" --awsInfo ${AWSCONFIG} --categories ${CATEGORIES} --yes;
        echo "# Initializing existing Amplify environment: ${ENV} (amplify init)"
        amplify init --amplify ${AMPLIFY} --providers ${PROVIDERS} --codegen ${CODEGEN} --categories ${CATEGORIES} --yes;
        echo "# Environment ${ENV} details:"
        amplify env get --name ${ENV}
    fi
    echo "# Done initializing Amplify environment: ${ENV}"
}

ENV=""
IS_SIMPLE=false
POSITIONAL=()
while [[ $# -gt 0 ]]
do
    key="$1"
    case ${key} in
        -e|--environment)
            ENV=$2
            shift
            ;;
        -r|--region)
            REGION=$2
            shift
            ;;
        -s|--simple)
            IS_SIMPLE=true
            shift
            ;;
        *)
            POSITIONAL+=("$1")
            shift
            ;;
    esac
done

set -- "${POSITIONAL[@]}"

# if no provided environment name, use default env variable, then user override
if [[ ${ENV} = "" ]];
then
    ENV=${AWS_BRANCH}
fi
if [[ ${USER_BRANCH} != "" ]];
then
    ENV=${USER_BRANCH}
fi

# Check valid environment name
if [[ -z ${ENV} || "${ENV}" =~ [^a-zA-Z0-9\-]+ ]] ; then help_output ; fi

AWSCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":true,\
\"profileName\":\"default\"\
}"

AMPLIFY="{\
\"envName\":\"${ENV}\"\
}"

PROVIDERS="{\
\"awscloudformation\":${AWSCONFIG}\
}"

CODEGEN="{\
\"generateCode\":false,\
\"generateDocs\":false\
}"

AUTHCONFIG="{\
\"facebookAppId\":\"${FACEBOOK_CLIENT_ID}\",\
\"facebookAppSecret\":\"${FACEBOOK_CLIENT_SECRET}\",\
\"googleAppId\":\"${GOOGLE_CLIENT_ID}\",\
\"googleAppSecret\":\"${GOOGLE_CLIENT_SECRET}\"\
}"

CATEGORIES="{\
\"auth\":$AUTHCONFIG\
}"

# Handle old or new config file based on simple flag
if [[ ${IS_SIMPLE} ]];
then
    echo "# Getting Amplify CLI Cloud-Formation stack info from environment cache"
    export STACKINFO="$(envCache --get stackInfo)"
    init_env ${ENV} ${AMPLIFY} ${PROVIDERS} ${CODEGEN} ${AWSCONFIG} ${CATEGORIES}
    echo "# Store Amplify CLI Cloud-Formation stack info in environment cache"
    STACKINFO="$(amplify env get --json --name ${ENV})"
    envCache --set stackInfo ${STACKINFO}
    echo "STACKINFO="${STACKINFO}
else
    # old config file, above steps performed outside of this script
    init_env ${ENV} ${AMPLIFY} ${PROVIDERS} ${CODEGEN} ${AWSCONFIG} ${CATEGORIES}
fi

2- In amplify console --> App Settings ----> Environment variables add FACEBOOK_CLIENT_ID, FACEBOOK_CLIENT_SECRET, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET to the environment varibale and set values for each environment

3- Change console --> App Settings ---->Build Setting to

version: 0.1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - chmod u+x ./vertrun-amplifypush.sh
        - ./amplfypush.sh
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

@ohadts
Copy link

ohadts commented Mar 14, 2020

I'm getting the following message:
[hostedUIProviderCreds] must have values

I don't have a frontend setup in the amplify console, i don't use the hosted UI at all.
I'm using Auth, Api and Storage services. I just want to add some fields in my schema and i'm stuck with this error...

This is the only issue that i found related to my error message. can someone help?

@zahydo
Copy link

zahydo commented Mar 20, 2020

I'm getting the following message:
[hostedUIProviderCreds] must have values

I don't have a frontend setup in the amplify console, i don't use the hosted UI at all.
I'm using Auth, Api and Storage services. I just want to add some fields in my schema and i'm stuck with this error...

This is the only issue that i found related to my error message. can someone help?

I have the same issue @ohadts

@litwicki
Copy link
Contributor

@kimfucious that's correct; the standard social credentials login will not require a custom amplifyPush script

@kimfucious
Copy link

Thanks for that clarification, @litwicki

Things seem to be working now! No need to disconnect and re-attach the front-end, too!

Thanks to you, @swaminator, and the Amplify team for addressing this issue and getting it resolved.

@swaminator
Copy link
Contributor

Finally closign this issue as it has been resolved. For those landing here now, check out this post

@ianmartorell
Copy link

ianmartorell commented Aug 24, 2020

Shouldn't the amplify-cli add these variables automatically, or at the very least the documentation be updated? As a new Amplify user following the official docs, the first build will fail with a cryptic error and they'll have to Google the error to find this thread and then read the entire thing to find the correct answer, like I did. Not the best solution IMHO.

@Redid
Copy link

Redid commented Aug 29, 2020

For those who still have problems verify if you don't have whitespaces in front or at the end. This was my stupid issue, because of copy-paste. +1 for not adding this variables by hand 😄

@swaminator
Copy link
Contributor

swaminator commented Sep 2, 2020

@ianmartorell good feedback.

Docs are updated: https://docs.amplify.aws/lib/auth/social/q/platform/js#deploying-to-amplify-console

@jackscotti
Copy link

jackscotti commented Nov 1, 2020

@abhi7cr @swaminator as by 01/11/2020 this issue still appears when I turn on PR Previews that create a new backend environment for every PR.

I have done as suggested in your comment, the required env variables are set for all branches:

Screenshot 2020-11-01 at 11 05 43

The dev branch works as expected but the backend build for the PR environments fails in the same way (Error: auth headless is missing the following inputParams googleClientId, facebookAppId).

Is this a known bug? Do I need a custom build script if I want to turn on PR previews?

@idobleicher
Copy link

Same goes here @jackscotti thanks for posting!

@NikolaBo
Copy link

NikolaBo commented Dec 9, 2020

I followed the instructions for setting up the environment variables in the web console for my automatic github deploys and that worked well for me. Afterward I ran into issues where amplify push would fail after adding user pools to my auth. I was able to fix it by amplify pulling which prompted me for my identity provider keys, and the next push worked. For anyone that runs into the same issue.

@krikork
Copy link

krikork commented Feb 4, 2021

I just created a new amplify environment so i do not interfere with a team member. After successfully creating the new backend I made some changes to a function. Pushing those changes with amplify push failes with
UPDATE_FAILED authcognito AWS::CloudFormation::Stack Wed Feb 03 2021 23:40:18 GMT-0500 (Eastern Standard Time) Parameters: [hostedUIProviderCreds] must have values"

@fkunecke
Copy link

fkunecke commented Jul 5, 2021

@swaminator This issue needs to be reopened. I'm seeing the same thing @jackscotti sees.

@DeerajTheepshi
Copy link

DeerajTheepshi commented Jul 8, 2021

Hey Everyone!
We are also stuck with the same problem today.
When doing amplify pull in headless mode we are facing the same error.

Why is this behavior different for headless mode ? Why isn't the configuration as simple as it is for non headless mode ? Why is app secrets even required for this process ? Everything is so bleak...

What exactly is the solution/workaround for this? Shouldn't this be documented in the headless cli page ?

The issue seems to be open for almost 2 year and we still don't have clarity

@swaminator swaminator reopened this Jul 9, 2021
@adi518
Copy link

adi518 commented Jul 21, 2021

I ran into this as well once I tried "Previews". It throws an error for a missing googleClientId parameter. For a user-generated environment the default amplifyPush worked just fine, but for this I had to get the script (https://github.com/aws-amplify/amplify-console/blob/master/scripts/amplifyPush.sh), commit and patch it to include the missing parameter. It worked and my build continued, but then I ran into another frustrating issue, which is envCache --get stackInfo being unable to retrieve the environment that was stored while building the initial commit of the PR, thus it tries to create the same environment again and throws AlreadyExistsException, which fails the build. Sad to say the "Previews" feature feels experimental at best.

@swaminator
Copy link
Contributor

@KidSysco KidSysco closed this as completed Sep 4, 2021
@NikolaBo
Copy link

NikolaBo commented Sep 4, 2021 via email

@adi518
Copy link

adi518 commented Sep 4, 2021

@adi518 did you follow docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html#creating-a-new-backend-environment-with-authentication-parameters @DeerajTheepshi could you also share your appid?

appId: dazj4he0xk1lv

Yeah, our user-generated environments work just fine. It's these Preview builds that have issues. However, at this point in time, I already found the bug, it's the envCache service! it lower-cases whatever key you give it and also seems to override stackInfo, so even when you fix it to be stackinfo, you still don't get the environment metadata for subsequent builds, hence an "already exists" exception. I wrote about it in my issue: #2096 (comment). I changed the key to something else, all lowercase of course, and the main issue in this thread was resolved.

To add to that, Preview builds have another serious issue. If an error occurs during the first build, where the environment is created, it always fails the rollback at some point and doesn't save the partially completed environment metadata (since it exits with non-zero), so at the next build, it tries to build the same environment and expectedly, fails. When an error occurs in the first build, it should catch that error, delete everything and start from scratch on the next build. That would be easier than trying to rollback. I've had build failures for all kinds of reasons, sometimes it's an availability issue, another time it's a limit issue, etc'.

I'm afraid we might have to abandon Amplify for these issues, because it's been really time-consuming, as in weeks and weeks of having to deal with things that should have worked out of the box.

@aws-amplify aws-amplify deleted a comment from KidSysco Sep 23, 2021
@samlaf
Copy link

samlaf commented Oct 1, 2021

Also getting headaches' worth of issues with this...
What exactly is amplifyPush? And when/what/how are environment variables treated by the backend phase of the amplify build server?

We added a few commands to the backend phase of our amplify.yml file:

commands:
   - set -x
   - cat $(whereis amplifyPush | cut -d ' ' -f 2)
   - AMPLIFY_GOOGLE_CLIENT_ID=...
   - AMPLIFY_GOOGLE_CLIENT_SECRET=...
   - echo $AMPLIFY_GOOGLE_CLIENT_ID
   - AMPLIFY_GOOGLE_CLIENT_ID=$AMPLIFY_GOOGLE_CLIENT_ID AMPLIFY_GOOGLE_CLIENT_SECRET=$AMPLIFY_GOOGLE_CLIENT_SECRET amplifyPush --simple

which still resulted in the same error

2021-10-01T03:15:13.586Z [INFO]: �[0mAmplify AppID found: d2nvp1g11xxgci. Amplify App name is: web-app�[0m
2021-10-01T03:15:13.633Z [INFO]: �[0mBackend environment staging found in Amplify Console app: web-app�[0m
2021-10-01T03:15:15.146Z [WARNING]: - Fetching updates to backend environment: staging from the cloud.
2021-10-01T03:15:16.371Z [WARNING]: ✔ Successfully pulled backend environment staging from the cloud.
2021-10-01T03:15:16.421Z [WARNING]: ✖ There was an error initializing your environment.
2021-10-01T03:15:16.439Z [INFO]: �[31mFailed to pull the backend.�[39m
2021-10-01T03:15:16.441Z [INFO]: �[31mauth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool�[39m
2021-10-01T03:15:16.478Z [INFO]: �[0mError: auth headless is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool�[0m
                                 �[0m    at updateConfigOnEnvInit (/root/.nvm/versions/node/v14.18.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/src/provider-utils/awscloudformation/index.js:134:15)�[0m
                                 �[0m    at /root/.nvm/versions/node/v14.18.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/src/index.js:304:28�[0m
                                 �[0m    at /root/.nvm/versions/node/v14.18.0/lib/node_modules/@aws-amplify/cli/node_modules/promise-sequential/index.js:16:18�[0m
                                 �[0m    at runMicrotasks (<anonymous>)�[0m
                                 �[0m    at processTicksAndRejections (internal/process/task_queues.js:95:5)�[0m

but we also observed a few 'interesting things...

  1. amplifyPush is located in /usr/bin/amplifyPush and is the same as https://github.com/aws-amplify/amplify-console/blob/master/scripts/amplifyPush.sh, except for the --forcePush on line 20: [[ -z ${CATEGORIES} ]] && amplify init --amplify ${AMPLIFY} --providers ${PROVIDERS} --codegen ${CODEGEN} --yes --forcePush || amplify init --amplify ${AMPLIFY} --providers ${PROVIDERS} --codegen ${CODEGEN} --categories ${CATEGORIES} --yes --forcePush
  2. each command is logged on the console. For example, the echo $AMPLIFY_GOOGLE_CLIENT_ID command is logged as (notice that the variable is evaluated before being logged... not sure why)
2021-10-01T03:14:51.284Z [INFO]: # Executing command: echo XXXXXXXX.apps.googleusercontent.com
                                 XXXXXXXXXX.apps.googleusercontent.com
  1. Most importantly, there is no such # Executing command logged for the amplifyPush command!! Notice the first error log above... it's as if the amplifyPush command is treated differently from other commands... what exactly is happening with this Amplify?!

Furthermore, the script doesn't read from the environment variables that were set in the previous commands... it only reads from the env variables set in the console. This is awful behavior... as these env variables are not checked into git, and it becomes very hard to redeploy the project in another account without forgetting about all of these ad-hoc console settings that have to be entered manually.

Please Amplify, can this issue be reopened and fixed once and for all?

@thejasonfisher
Copy link

I can't believe this is still an issue. This project is a complete joke.

@github-actions
Copy link

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

@github-actions github-actions bot added the archived This issue has been locked. label Oct 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. backend-builds bug Something isn't working
Projects
None yet
Development

No branches or pull requests