I did it through app.yml
It now seems to be working. The issue I think was that I had an A record for the subdomain www (as in www.example.com) instead of using a CNAME record. For anyone reading this in future, the right config seems to be:
- An A record pointing to the IP address of your host (e.g. Digital Oceans droplet)
- A CNAME record with * pointing to example.com (and NOT www.example.com)
With this setup the letsencrypt through app.yml works a treat. Thanks all