Don't host with Amazon, so the following is an attempt to assist (do run CentOS servers).
Please see:
https://docs.moodle.org/28/en/Installation_Guide_for_Installing_on_Amazon_EC2
on the above page, it has a section that says:
"I used an instance of the Amazon Linux AMI
based on Elastic Block Store. Using an instance based on an Elastic
Block Store gives you more options for backing up your disks later. The "Amazon Linux AMI"
is based on CentOS and is a pared down version of linux with only the
bare essentials included, that should be more secure. You can use the
yum command to install anything extra necessary on your server."
Since it is based on CentOS and IF what the above author says is true ... 'can use yum to install anything extra necessary', that might be the issue. One needs to install not only PHP but the extensions needed to run Moodle.
To see what is available for php using yum try:
sudo yum list php-mysql*
You might have to use other repos to acquire the desired extensions ... versions of the extensions must match that of php itself.
To see what repos currently using:
sudo yum repolist
'spirit of sharing', Ken