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

Amplify init errors out for appsync event starter app

Open rubyrose-alexis opened this issue 7 years ago • 2 comments

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the official AWS Amplify Console forum

Describe the bug

Create the AppSync API using the Events Starter through the AppSync console. Clone appsync events starter for Android Run amplify init

Note: It is recommended to run this command from the root of your app directory
? Enter a name for the project awsmobileappsynceven
? Enter a name for the environment beta
? Choose your default editor: Sublime Text
? Choose the type of app that you're building android
Please tell us about your project
? Where is your Res directory:  app/src/main/res
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 default
⠦ Initializing project in the cloud...

CREATE_IN_PROGRESS awsmobileappsynceven-20190415094023 AWS::CloudFormation::Stack Mon Apr 15 2019 09:40:23 GMT-0700 (PDT) User Initiated
CREATE_IN_PROGRESS UnauthRole                          AWS::IAM::Role             Mon Apr 15 2019 09:40:27 GMT-0700 (PDT)
CREATE_IN_PROGRESS AuthRole                            AWS::IAM::Role             Mon Apr 15 2019 09:40:27 GMT-0700 (PDT)
CREATE_IN_PROGRESS DeploymentBucket                    AWS::S3::Bucket            Mon Apr 15 2019 09:40:28 GMT-0700 (PDT)
CREATE_IN_PROGRESS UnauthRole                          AWS::IAM::Role             Mon Apr 15 2019 09:40:28 GMT-0700 (PDT) Resource creation Initiated
⠇ Initializing project in the cloud...

CREATE_IN_PROGRESS AuthRole AWS::IAM::Role Mon Apr 15 2019 09:40:29 GMT-0700 (PDT) Resource creation Initiated
⠦ Initializing project in the cloud...

CREATE_IN_PROGRESS DeploymentBucket AWS::S3::Bucket Mon Apr 15 2019 09:40:29 GMT-0700 (PDT) Resource creation Initiated
⠴ Initializing project in the cloud...

CREATE_COMPLETE UnauthRole AWS::IAM::Role Mon Apr 15 2019 09:40:46 GMT-0700 (PDT)
CREATE_COMPLETE AuthRole   AWS::IAM::Role Mon Apr 15 2019 09:40:46 GMT-0700 (PDT)
⠴ Initializing project in the cloud...

CREATE_COMPLETE DeploymentBucket AWS::S3::Bucket Mon Apr 15 2019 09:40:50 GMT-0700 (PDT)
⠦ Initializing project in the cloud...

CREATE_COMPLETE awsmobileappsynceven-20190415094023 AWS::CloudFormation::Stack Mon Apr 15 2019 09:40:54 GMT-0700 (PDT)
✔ Successfully created initial AWS cloud resources for deployments.
✔ Initialized provider successfully.
✖ There was an error initializing your environment.
init failed
SyntaxError: Unexpected token  in JSON at position 0
    at JSON.parse (<anonymous>)
    at getCurrentAWSConfig (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-frontend-android/lib/frontend-config-creator.js:84:22)
    at createAWSConfig (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-frontend-android/lib/frontend-config-creator.js:26:28)
    at Object.createFrontendConfigs (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-frontend-android/index.js:23:10)
    at Object.onCategoryOutputsChange (/usr/local/lib/node_modules/@aws-amplify/cli/src/extensions/amplify-helpers/on-category-outputs-change.js:22:33)
    at initializeEnv (/usr/local/lib/node_modules/@aws-amplify/cli/src/lib/initialize-env.js:79:27)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)

To Reproduce Steps to reproduce the behavior:

  1. Create the AppSync API using the Events Starter through the AppSync console.
  2. Clone appsync events starter for Android
  3. Run amplify init

Expected behavior Amplify init to succeed.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

rubyrose-alexis avatar Apr 15 '19 17:04 rubyrose-alexis

It turned out the starter repo https://github.com/aws-samples/aws-mobile-appsync-events-starter-android.git saved this file app/src/main/res/raw/awsconfiguration.json as a UTF-8 BOM file, probably because it was edited in Windows, causing the json parser to fail. see this node issue for more information: https://github.com/nodejs/node/issues/20649 I will talk to the team tomorrow to figure out the best solution for this.

UnleashedMind avatar Apr 16 '19 01:04 UnleashedMind

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

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

github-actions[bot] avatar May 27 '21 11:05 github-actions[bot]