While trying to run Ubuntu 18.04 LTS (Bionic) on an AWS EC2 instance, my user data initialization script includes the step to do an upgrade (executing apt-get -y upgrade after executing apt-get update). During this upgrade, there is a new kernel which requires that the boot loader (grub2) be reinstalled. The big problem is the grub2 package setup apparently has lost configuration information and is running an interactive dialog using a tool called whiptail. This means everything comes to a stop while this dialog waits for human response, though no human is present at the instance virtual console. I have tried this with AMIs ami-0c55b159cbfafe1f0 (the same as the console uses) and ami-0e04554247365d806 (a more recent build from the Canonical account) in region us-east-2 (Ohio) with instance type t3a.small (2GB RAM).
I would like to know if (and how) there is a way to have package grub2 do the necessary boot-loader setup/install w/o doing any interactive dialog.
My user data script does download a tarball of my add-on files, in advance, so adding large or many files to this is practical. Running similar AMIs for the arm64 architecture (on instance type a1.medium) works just fine (of course, grub is not being used for this architecture). i am submitting this via a Python3 script over the AWS API with botocore, so I can repeat this with changes, easily.