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

(CLI v6.4.0) - amplify init is failing both in the Amplify pipeline and in CodeBuild #11481

Closed
5 tasks done
dragosiordachioaia opened this issue Nov 28, 2022 · 3 comments
Closed
5 tasks done
Labels
bug Something isn't working dependency-issue Issue with another dependency used

Comments

@dragosiordachioaia
Copy link

dragosiordachioaia commented Nov 28, 2022

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists. (I didn't really, since this is an issue that has started to happen for an older version of the CLI and I can't just update it right now.)
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

How did you install the Amplify CLI?

npm

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

16.14.2

Amplify CLI Version

6.4.0

What operating system are you using?

Amazon Linux 2

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

No manual changes

Amplify Categories

Not applicable

Amplify Commands

init

Describe the bug

In the Amplify console, it's failing to generate the aws-exports.json file. In a separate CodeBuild pipeline, I'm getting this error when trying to run amplify init:

Initializing your environment: test
Could not initialize 'test': Request is missing Authentication Token

Expected behavior

It should not fail to initialise the environment. The very same setup worked earlier today.

Reproduction steps

Run the init script in a CodeBuild environment (assuming you have provided the environment variables to it) - this was taken from the Amplify examples in GitHub and it worked until now:

#!/bin/bash
set -e
IFS='|'

REACTCONFIG="{\
\"SourceDir\":\"src\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"npm run build\",\
\"StartCommand\":\"npm run start\"\
}"
AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":false,\
\"accessKeyId\":\"$ACCESS_KEY_ID\"\
\"secretAccessKey\":\"$SECRET_ACCESS_KEY\"\
\"region\":\"eu-west-2\"\
}"
AMPLIFY="{\
\"projectName\":\"draughthub\",\
\"envName\":\"test\",\
\"defaultEditor\":\"code\"\
}"
FRONTEND="{\
\"frontend\":\"javascript\",\
\"framework\":\"react\",\
\"config\":$REACTCONFIG\
}"
PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"

amplify init \
--amplify $AMPLIFY \
--frontend $FRONTEND \
--providers $PROVIDERS \
--yes

GraphQL schema(s)

# Put schemas below this line

Project Identifier

I don't have this in v6.4.0

Log output

# Put your logs below this line

CodeBuild:

Running command ci_scripts/amplify_init.sh
--
Note: It is recommended to run this command from the root of your app directory
- Initializing your environment: test
Could not initialize 'test': Request is missing Authentication Token



Amplify console:

Module not found: Error: Can't resolve 'aws-exports' in '/codebuild/output/src637345195/src/draughthub/src/common'



Additional information

No response

@dragosiordachioaia dragosiordachioaia added the pending-triage Issue is pending triage label Nov 28, 2022
@jhockett jhockett added the dependency-issue Issue with another dependency used label Nov 28, 2022
@jhockett
Copy link
Contributor

HI @dragosiordachioaia thanks for reporting this issue!

We were able to root cause this back to a bug in the aws-sdk: aws/aws-sdk-js#4286

This issue is fixed in the latest version of the CLI and we recommend upgrading to the latest version if possible.

If for some reason, you cannot upgrade, you can probably override the dependency. This Stack Overflow question may be helpful: https://stackoverflow.com/questions/15806152/how-do-i-override-nested-npm-dependency-versions

You can also wait for the aws-sdk fix to be deployed, and then uninstall & reinstall the same Amplify CLI version.

@josefaidt josefaidt added the pending-response Issue is pending response from the issue author label Nov 29, 2022
@dragosiordachioaia
Copy link
Author

dragosiordachioaia commented Nov 29, 2022

Thanks @jhockett, overriding the aws-sdk dependency fixed part of the issue - it's now succeeding in CodeBuild, where I am running a separate pipeline for tests. In the Amplify pipeline however, it's a different story, as no matter what I do, it doesn't seem to work. I've tried:

  • installing aws-sdk@2.1030.0 with npm install aws-sdk@2.1030.0 --force
  • putting the exact version (no ^) in the package.json file
  • ensuring the exact version is listed in npm-shrinkwrap.json

None of these had any effect on the build step in the Amplify pipeline. The thing is though that I've also tried to disable the back-end and only leave the front-end step, which doesn't even have any Amplify commands in it, but the aws-exports.js file still isn't there, which leads me to believe that the problem happens when the environment is set up, rather than when my commands start running.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Nov 29, 2022
@josefaidt josefaidt added bug Something isn't working and removed pending-triage Issue is pending triage labels Nov 29, 2022
@josefaidt josefaidt reopened this Nov 29, 2022
@josefaidt
Copy link
Contributor

Hey @dragosiordachioaia please upgrade the Amplify CLI to one of the more recent versions, or override aws-sdk to the latest version.

The thing is though that I've also tried to disable the back-end and only leave the front-end step, which doesn't even have any Amplify commands in it, but the aws-exports.js file still isn't there, which leads me to believe that the problem happens when the environment is set up, rather than when my commands start running.

When toggling Amplify Hosting to frontend-only, it will still run an amplify pull behind the scenes to generate this file for you. If you continue to experience this, please file a separate bug report so we can track this occurrence separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependency-issue Issue with another dependency used
Projects
None yet
Development

No branches or pull requests

3 participants