amplify-cli: Current environment cannot be determined

I recently updated the amplify cli and now when running amplify push in my project I receive following error:

$ amplify push
An error occured during the push operation: Current environment cannot be determined
Use 'amplify init' in the root of your app directory to initialize your project with Amplify

Running amplify init again returns following:

$ amplify init
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the environment dev
? Choose your default editor: Visual Studio Code
Using default provider  awscloudformation

For more information on AWS Profiles, see:
https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html

? Do you want to use an AWS profile? Yes
? Please choose the profile you want to use PeskyAWS
Adding backend environment dev to AWS Amplify Console app: d3i74i7p2o0hzv
⠏ Initializing project in the cloud...

CREATE_IN_PROGRESS amplify-amplify-dev-162400 AWS::CloudFormation::Stack Fri Jan 10 2020 16:24:02 GMT+0000 (Greenwich Mean Time) User Initiated             
CREATE_IN_PROGRESS DeploymentBucket           AWS::S3::Bucket            Fri Jan 10 2020 16:24:05 GMT+0000 (Greenwich Mean Time)                            
CREATE_IN_PROGRESS UnauthRole                 AWS::IAM::Role             Fri Jan 10 2020 16:24:05 GMT+0000 (Greenwich Mean Time)                            
CREATE_IN_PROGRESS AuthRole                   AWS::IAM::Role             Fri Jan 10 2020 16:24:05 GMT+0000 (Greenwich Mean Time)                            
CREATE_IN_PROGRESS UnauthRole                 AWS::IAM::Role             Fri Jan 10 2020 16:24:06 GMT+0000 (Greenwich Mean Time) Resource creation Initiated
CREATE_IN_PROGRESS AuthRole                   AWS::IAM::Role             Fri Jan 10 2020 16:24:06 GMT+0000 (Greenwich Mean Time) Resource creation Initiated
CREATE_IN_PROGRESS DeploymentBucket           AWS::S3::Bucket            Fri Jan 10 2020 16:24:06 GMT+0000 (Greenwich Mean Time) Resource creation Initiated
⠴ Initializing project in the cloud...

CREATE_COMPLETE AuthRole   AWS::IAM::Role Fri Jan 10 2020 16:24:21 GMT+0000 (Greenwich Mean Time) 
CREATE_COMPLETE UnauthRole AWS::IAM::Role Fri Jan 10 2020 16:24:21 GMT+0000 (Greenwich Mean Time) 
⠧ Initializing project in the cloud...

CREATE_COMPLETE DeploymentBucket AWS::S3::Bucket Fri Jan 10 2020 16:24:27 GMT+0000 (Greenwich Mean Time) 
⠏ Initializing project in the cloud...

CREATE_COMPLETE amplify-amplify-dev-162400 AWS::CloudFormation::Stack Fri Jan 10 2020 16:24:29 GMT+0000 (Greenwich Mean Time) 
✔ Successfully created initial AWS cloud resources for deployments.
init failed
TypeError [ERR_INVALID_ARG_TYPE]: The 'request' argument must be string. Received type undefined
    at /usr/lib/node_modules/@aws-amplify/cli/lib/lib/init-steps/s9-onSuccess.js:39:32
    at Generator.next (<anonymous>)
    at /usr/lib/node_modules/@aws-amplify/cli/lib/lib/init-steps/s9-onSuccess.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/lib/node_modules/@aws-amplify/cli/lib/lib/init-steps/s9-onSuccess.js:4:12)
    at run (/usr/lib/node_modules/@aws-amplify/cli/lib/lib/init-steps/s9-onSuccess.js:19:12)

After that I still cannot run amplify push. Unfortunately I also can’t remember what the previous version of amplify cli was I used. Otherwise I would have gone back to that version.

Whats the best way to fix that? The only option I see at the moment is to create a new amplify project, then run amplify add api, copy the schema.graphl to the new amplify project and then link the AppSync Data Sources to the old dynamo db tables.

Amplify CLI Version

4.12.0

What AWS Services are you utilizing?

Cognito, AppSync (DynamoDB)

Provide additional details e.g. code snippets

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 24 (8 by maintainers)

Most upvoted comments

I had something similar when I upgraded from 1.x to 4.x and the command amplify configure project created/updated the correct files for me - have tried that?

Running amplify init from the root project’s directory has solved the issue for me.

My issue started when I tried to work on an old project that was initialized by an old version of Amplify CLI.

amplify configure project created/updated the correct file

This worked for me. Thanks

@olivoil I’ve just pinned mine to 4.11.0 and that includes nodejs10.x runtime. My project is now fully working both locally and within Amplify Console:

excerpt amplify.yml

version: 0.1
backend:
  phases:
    preBuild:
      commands:
        - npm install -g @aws-amplify/cli@4.11.0 # pinned known working version