If you encounter error updating themes or plugins in wordpress after clicking update, you will be asked for FTP credentials by WordPress running in Amazon lightsail.

You can fix this with this one line in wp-config.php.

define('FS_METHOD', 'direct');

Restart the apache server

sudo /opt/bitnami/ctlscript.sh restart