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

Console build fails during initialization of environment #223

Closed
mcg5de opened this issue Nov 1, 2019 · 11 comments
Closed

Console build fails during initialization of environment #223

mcg5de opened this issue Nov 1, 2019 · 11 comments
Labels
archived This issue has been locked. backend-builds bug Something isn't working

Comments

@mcg5de
Copy link

mcg5de commented Nov 1, 2019

Describe the bug
I am developing a web app using React and deploying through Amplify Console. So far I had successfully built several commits on Amplify Console on the master branch of my repo, but on the next build after a commit that removed 2 other amplify cli envs other than master, the build began to fail despite the fact that those edits should not have affected it. The error is during the backend build portion of the build step of the process and is Error: auth headless init is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool (Full log below). Despite failing on the Amplify Console, the repo can be cloned and Amplify init run without issue on a local computer. The app also then runs like normal on localhost.

To Reproduce
Steps to reproduce the behavior:

  1. Both the Google App ID and App Secret seem to properly be definied in backend-config.json
  2. Commit a change to github and let Amplify console build the new commit
  3. See error logs in the backend build phase
                                 # Starting phase: build
                                 # Executing command: amplifyPush --simple
2019-10-18T01:13:00.274Z [INFO]: # Getting Amplify CLI Cloud-Formation stack info from environment cache
2019-10-18T01:13:00.312Z [INFO]: # Start initializing Amplify environment: master
2019-10-18T01:13:00.313Z [INFO]: STACKINFO={
                                 "awscloudformation": {
                                 "AuthRoleName": "XXXX",
                                 "UnauthRoleArn": "XXXX",
                                 "AuthRoleArn": "XXXX",
                                 "Region": "us-east-1",
                                 "DeploymentBucketName": "XXXX",
                                 "UnauthRoleName": "XXXX",
                                 "StackName": "XXXX",
                                 "StackId": "XXXX"
                                 },
                                 "categories": {
                                 "auth": {
                                 "motorsportsWebAppCat": {
                                 "hostedUIProviderCreds": "[{\"ProviderName\":\"Google\",\"client_id\":\"XXXX\",\"client_secret\":\"XXXX\"}]"
                                 }
                                 }
                                 }
                                 }
                                 # Importing Amplify environment: master (amplify env import)
2019-10-18T01:13:22.001Z [INFO]: Successfully added environment from your project
2019-10-18T01:13:22.063Z [INFO]: # Initializing existing Amplify environment: master (amplify init)
2019-10-18T01:13:26.043Z [INFO]: Note: It is recommended to run this command from the root of your app directory
2019-10-18T01:13:31.259Z [WARNING]: - Initializing your environment: master
2019-10-18T01:13:31.577Z [WARNING]: ✔ Initialized provider successfully.
2019-10-18T01:13:31.598Z [WARNING]: ✖ There was an error initializing your environment.
2019-10-18T01:13:31.598Z [INFO]: init failed
2019-10-18T01:13:31.600Z [INFO]: Error: auth headless init is missing the following inputParams googleAppIdUserPool, googleAppSecretUserPool
                                 at updateConfigOnEnvInit (/root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/provider-utils/awscloudformation/index.js:315:15)
                                 at /root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-auth/index.js:241:28
                                 at /root/.nvm/versions/node/v10.16.0/lib/node_modules/@aws-amplify/cli/node_modules/promise-sequential/index.js:16:18
                                 at process._tickCallback (internal/process/next_tick.js:68:7)
2019-10-18T01:13:31.649Z [ERROR]: !!! Build failed
2019-10-18T01:13:31.649Z [ERROR]: !!! Non-Zero Exit Code detected
2019-10-18T01:13:31.650Z [INFO]: # Starting environment caching...
2019-10-18T01:13:31.650Z [INFO]: # Uploading environment cache artifact...
2019-10-18T01:13:31.740Z [INFO]: # Environment caching completed
Terminating logging...

Expected behavior
Successful Build

Additional context
Attempts to revert to a commit earlier than the first failing build also result in a failing build despite previously having been built successfully.

I am still getting used to using the Amplify framework so forgive me if I'm missing something obvious. I found a similar issue over at aws-amplify/amplify-js#2478 (comment) but have no idea what changed that fixed that issue.

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

swaminator commented Nov 5, 2019

Are you using the latest version of the Amplify CLI? If not please try: https://docs.aws.amazon.com/amplify/latest/userguide/custom-build-image.html#setup-live-updates

Also, are you using the Console to create a new backend environment?

@mcg5de
Copy link
Author

mcg5de commented Nov 5, 2019

@swaminator I setup the live updates as described and set it to latest, but the build still failed.

For setting up the backend, most everything was setup using my Amplify CLI. I tweaked some settings using the console afterwards but nothing that should have broken it/ it still works using localhost with the same cloud resources.

@swaminator
Copy link
Contributor

@mcg5de please refer to #206 (comment)

@mcg5de
Copy link
Author

mcg5de commented Nov 14, 2019

I was able to get that workaround working. Thank you for the help!

@mcg5de mcg5de closed this as completed Nov 14, 2019
@mcg5de mcg5de reopened this Dec 12, 2019
@mcg5de
Copy link
Author

mcg5de commented Dec 12, 2019

So following this thread I was able to implement the workaround talked about in #206, and up until now that had worked to fix the initial issue of the console not seeing the parameters.

Describe the bug
Now I have run into a different issue that is still causing same error that I posted above previously: When I switch between cloud backends using amplify env checkout and try to do a push, the *-cloudformation-template.json (in amplify/backend/function) of my lambda function for presignup in Cognito changes the S3Key associated with the deployment bucket for the lambda function. When this change kicks off a new build in the console, I receive the same errors as above that auth headless init is missing the following inputParams.

I found this specific issue discussed here aws-amplify/amplify-cli#1194 (comment) as well as seemingly fixed in this merge here aws-amplify/amplify-cli#1668 (comment).

I'm not 100% sure if this is the driving issue behind the build failures, but it seems to be the only thing changing between a working and a failing build.

Expected Behavior
My understanding is that the S3Key should only be updating if there are changes to the actual lambda function, so I am not sure what is going wrong there as I have not changed anything with the function.

OS Version
Issues on both OSX and Windows 10

Additional Context
I was originally having this issue with Amplify CLI v3.17.0, so I updated to v4.6.0 with no change in the resulting errors & changing keys.

@kaustavghosh06
Copy link

@mcg5de Do you see a list of inputParams which are missing? Also, can you share your headless script?

@mcg5de
Copy link
Author

mcg5de commented Dec 13, 2019

Yes @kaustavghosh06 the missing params are googleAppIdUserPool, googleAppSecretUserPool which was the same as my original issue. Attached here is the script with the AppId & Secret values scrubbed. I copied and modified that script from the one discussed in #206.

workaroundAmplifyPush.txt

@kaustavghosh06
Copy link

@mcg5de In the following section of the script (the one bolded out), could you replace that with

amplify init --amplify ${AMPLIFY} --providers ${PROVIDERS} --codegen ${CODEGEN} --categories ${CATEGORIES} --yes;

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}"
}

@mcg5de
Copy link
Author

mcg5de commented Dec 18, 2019

@kaustavghosh06 That seems to have fixed it so now all of my branches are building correctly. Thanks for the help with the fix.

@BhanukaUOM
Copy link

Include googleAppIdUserPool and googleAppSecretUserPool in auth categories flag.

amplify init \
--amplify "{\"envName\":\"dev\"}" \
--categories "{\"auth\":{\"googleAppIdUserPool\":\"googleAppId\",\"googleAppSecretUserPool\":\"googleAppSecret\"}}" \
--yes

@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 29, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 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

5 participants