Skip to content
This repository has been archived by the owner on Feb 7, 2020. It is now read-only.

run erases imported API configuration retrieved with pull #12

Closed
ghost opened this issue Dec 13, 2017 · 4 comments
Closed

run erases imported API configuration retrieved with pull #12

ghost opened this issue Dec 13, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 13, 2017

Prerequisites

  • Have an existing API in API Gateway. Mine is created with CloudFormation, using C# Lambdas for integration.
  • In awsmobile features, user-signin and hosting are enabled, but notably cloud-api is NOT enabled. (I disabled analytics because it kept clogging the console with errors).

Reproducing

  1. Using the MobileHub console in the CloudLogic service, use the Import existing API feature to import your existing API.
  2. Following the instructions in the MobileHub Integrate wizard, execute the awsmobile pull command.
  3. View the aws-exports.js file and confirm that the aws_cloud_logic value is set to enable and the aws_cloud_logic_custom field contains a list of information about your imported API:
aws_cloud_logic : 'enable',
aws_cloud_logic_custom : '[{"id":"someId","name":"Some API","description":"","endpoint":"https://someId.execute-api.us-east-2.amazonaws.com/Stage","region":"us-east-2","paths":["/123"]}]',
  • At this point there are two forks that I want to cover but lead to the same result.

Fork 1: Follow the instructions

4a. The Integrate wizard next guides you here: https://docs.aws.amazon.com/aws-mobile/latest/developerguide/web-access-apis.html#connect-to-your-backend which, reading from the anchor, suggests you are ready to start coding. So, add some code, if desired.

let apiName = 'Some API';
let path = '/stuff'; 
let myInit = { 
    headers: {}
}
API.get(apiName, path, myInit).then(response => { console.log(response.body); });

5a. Now that you are done coding, execute awsmobile run.
6a. See the following error:

BadRequestException: Your AWS CloudFormation stack is busy being updated. Please retry your request in a few minutes. Current stack state is DELETE_IN_PROGRESS.

7a. Return to the MobileHub/Cloud Logic console, refresh, and confirm that Your API(s) have been deleted. The CloudFormation stack that integrated with your imported API is now gone.
8a. View aws-exports.js and note the aws_cloud_logic* attributes are gone.

Fork 2: Try to be smarter than the instructions

4b. Instead of just coding and then running, let's try running awsmobile cloud-api enable locally first.
5b. Confirm the aws_cloud_logic* variables are unchanged in the aws-exports.js file.
6b. Code as in Fork 1, if necessary, although your code should still be there.
7b. Now execute awsmobile run.
8b. Note the zipping sampleLambda step under building cloud-api.
9b. Note various CloudFormation states pass by on the status check line.
10b. Eventually, the application starts.
11b. Return to the MobileHub/Cloud Logic console, refresh, and confirm that your imported API is now deleted. The sampleCloudAPI provided by awsmobile cloud-api enable should be present.
12b. View aws-exports.js and note the aws_cloud_logic* attributes are gone.

Conclusion

It appears that no matter what I do, it is not possible to execute an awsmobile run with an imported API in Cloud Logic. It is also worth noting that in both cases, the code (similar to what is shown) generates the following error: API no configured

Edit: Environment

I am using a MacOS High Sierra workstation with current Homebrew packages for node/npm etc.

@ghost
Copy link
Author

ghost commented Dec 13, 2017

Somewhat similar to #9, though in that case there is no pull before the silent erasure.

@ghost
Copy link
Author

ghost commented Jan 9, 2018

Do the fixes to #9 or #16 fix this?

@elorzafe
Copy link
Contributor

Hi @domZippilli this issue should be fix on 1.0.7 version. I try to reproduce the same you did and the cli is checking before run (or push) the latest change and showing warning message in case you want to overwrite you project configuration.

When you import an api on your mobilehub project you need to wait for the message "Your API(s) have been deployed." before calling awsmobile pull

@elorzafe
Copy link
Contributor

I am closing the issue now, but feel free to reopen or create a new one in case you have any problems with this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant