amplify-cli: User setup fails with "Root stack creation failed: IncompleteSignature"

Describe the bug

When running amplify init, if you fail to provide the access key and secret key when choosing the set up a new user (for example, accidentally hitting “enter” without pasting the secret key first), then the next time you run amplify init and choose to not set up a new user, init fails as soon as you provide the secret key and does not ever prompt for the profile name.

To Reproduce Steps to reproduce the behavior: See above

Expected behavior Should prompt for the profile name if the create user flow failed to reach that step the first time around

Screenshots

Using default provider awscloudformation
AWS access credentials can not be detected.
? Setup new user No

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

? accessKeyId:   REDACTED**********
? secretAccessKey:  REDACTED********************
? region:  us-west-2
⠋ Initializing project in the cloud...An error occurred when creating the CloudFormation stack
✖ Root stack creation failed

There’s a big IncompleteSignature error after this but I’m not sure what’s sensitive or not so I don’t want to paste it.

Desktop (please complete the following information):

  • OS: [e.g. iOS] OS X

Amplify cli version: 0.1.19

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 22 (7 by maintainers)

Most upvoted comments

@kaustavghosh06 I have configured amplify configure and amplify init. It has created IAM user on the console but still when I choose profile configured with AccessID and SecretKey It gives me this error. Please help me out.

Initializing project in the cloud...An error occurred when creating the CloudFormation stack
× Root stack creation failed
init failed
{ OptInRequired: The AWS Access Key Id needs a subscription for the service
    at Request.extractError (C:\Users\Admin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\node_modules\aws-sdk\lib\protocol\query.js:50:29)
    at Request.callListeners (C:\Users\Admin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
    at Request.emit (C:\Users\Admin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
    at Request.emit (C:\Users\Admin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\node_modules\aws-sdk\lib\request.js:683:14)
    at Request.transition (C:\Users\Admin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\node_modules\aws-sdk\lib\request.js:22:10)
    at AcceptorStateMachine.runTo (C:\Users\Admin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\node_modules\aws-sdk\lib\state_machine.js:14:12)
    at C:\Users\Admin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\node_modules\aws-sdk\lib\state_machine.js:26:10
    at Request.<anonymous> (C:\Users\Admin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\node_modules\aws-sdk\lib\request.js:38:9)
    at Request.<anonymous> (C:\Users\Admin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\node_modules\aws-sdk\lib\request.js:685:12)
    at Request.callListeners (C:\Users\Admin\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation\node_modules\aws-sdk\lib\sequential_executor.js:116:18)
  message: 'The AWS Access Key Id needs a subscription for the service',
  code: 'OptInRequired',
  time: 2019-03-05T13:35:57.743Z,
  requestId: '9b332cdd-3f4b-11e9-bcbc-9791fd214f40',
  statusCode: 403,
  retryable: false,
  retryDelay: 13.349160804712067 }

Solved the issue by Verifying Account through call. I tried & failed before posting question here. Hope this will help any other person.

I think Amplify expects you to have had an existing user with AdministrationFullAccess. This should be confirmed before running amplify init or perhaps when you run the amplify init you will be prompted if you would be using the default AWS Profile or not. In this case you might have to create the user yourself and attach a policy to the user and paste both the access and secret keys to the respective section on the console. But when you follow the steps to create a user with amplify configure it is so easy.

So when that is successful without displaying any error messages then you can proceed with the amplify init to create a valid amplify project.

amplify status : to check the validity of your Amplify project.

Well that is the solution to the CloudFormation stack creation issue…

Ah, I see it now. I was able to reproduce it. I’ll mark this as a bug and we’ll work on fixing it. Thanks for pointing this out.

@mlynch It seems like you don’t have any AWS profiles set in your system and because of which its directly asking you to enter your access key and secret key. If it detected any existing profiles, it would have given you a list to choose from. Also, it looks like the accesskey and secret key provided doesn’t have the permissions/policies to execute Cloudformation operations and that might have caused the cloudformation create execution to error out.

As recommended in our documentation out here -> https://aws-amplify.github.io/media/get_started , the correct flow would be to run the amplify configure command to start with, which would create an IAM user with the appropriate policies/permissions for the CLI to work with and then run amplify init. You would be able to select the newly created AWS profile (which has the appropriate policies required by the CLI) in this flow.