just run the command with -E to force preservation of environment variables.
-E
sudo -E certbot certonly --dns-route53 --dns-route53-propagation-seconds 30 -d mydomain.com -d *.mydomain.com -i apache