Amplify-cli: Automate amplify add hosting with bash

Created on 8 Oct 2019  路  3Comments  路  Source: aws-amplify/amplify-cli

* Which Category is your question related to? *
Hosting
* What AWS Services are you utilizing? *
Cloudfront and S3
* Provide additional details e.g. code snippets *
I'm trying to built an automatic deployment pipeline for an application and I have some problems with amplify add hosting. The script is asking to choose between DEV and PROD (using arrow keys) and then asks for the bucket name and endpoints (index.html)

I'm deploying from an Ubuntu 18.04 and I successfully inejcted the DOWN arrow key to select the prod value but after that, the script is not reading anymore :

echo -e "\033[B" | amplify add hosting will select PROD, but will crash immediately since EOF is sent.
I tried adding other stuff after like so :
echo -e "\033[B\nbucketname" and the script just crashes

If I try to input all the values asked and I have the same result :

screen

Are there any options that I missed for sending values as arguments and preventing the console to ask to manually set the values (I tried to use the --yes option but obviously it was not working).

enhancement hosting

Most helpful comment

@Irindul Amplify CLI supoorts headless mode only for certain commands. I am marking this as a feature request and putting this in our backlog for prioritization from our product teams.

We use nexpect to do our integration tests. We have some auth tests which use down arrow in our test and this code snippet might be helpful to achieve what you want to do

https://github.com/aws-amplify/amplify-cli/blob/ecd87ee5b47b5d3e458feaa87b0949f5661a8901/packages/amplify-e2e-tests/src/categories/auth.ts#L35-L69

All 3 comments

@Irindul Amplify CLI supoorts headless mode only for certain commands. I am marking this as a feature request and putting this in our backlog for prioritization from our product teams.

We use nexpect to do our integration tests. We have some auth tests which use down arrow in our test and this code snippet might be helpful to achieve what you want to do

https://github.com/aws-amplify/amplify-cli/blob/ecd87ee5b47b5d3e458feaa87b0949f5661a8901/packages/amplify-e2e-tests/src/categories/auth.ts#L35-L69

Thanks @yuth I will look into this, I'll come back to you with an update once I tested !

Hello. I realize that this is an old post, but figured there would be no harm to adding my two cents. I have successfully been able to run Amp cli commands for which headless modes is not supported using a combination of expect (which I am assuming is very similar to nexpect (mentioned above by yuth) and autoexpect. Autoexpect is a bit of a time saver as it takes the command you want to run "headlessly" as a parameter, records the prompts and responses to the cli command as it runs, and generates the config file that can be used by expect. I can go into more detail if anyone wants, but autoexpect is documented relatively well on the internet.

Take care,

frank

Was this page helpful?
0 / 5 - 0 ratings