Use this docker image to generate Let's Encrypt SSL Certificates via ACME DNS-01 challenge for DNS zones in Google Cloud, based on the wonderful ACME Client "Lego" (v4.5).
After moving my domains over to Google Cloud, I was looking for a convenient way to automate certificate retrieval. Previously, I was using the DNS-01 challenge in combination with a PowerDNS on my own servers.
You will need to create a Google Cloud Service Account, so that Lego may add TXT records for ACME Challenge verification to your zones.
- Open the Service accounts page. If prompted, select a project.
- Click Create service account.
- In the Create service account window, type a name for the service account, and select Furnish a new private key. The key's type should be JSON.
- Select DNS > DNS-Administrator in the Role dropdown.
- Confirm creation. Your new public/private key pair is generated and downloaded to your machine; it serves as the only copy of this key. You are responsible for storing it securely, as this key grants full access to your DNS zones in the cloud.
docker run \
-e GCE_PROJECT=example-project \
-e GCE_DOMAIN="example.com" \
-e EMAIL=certmaster@example.com \
-e DOMAINS=example.com,test.example.com \
-v `pwd`/my-project-34efa2.json:/gcloud-service-account.json:ro \
-v `pwd`/certstore:/certstore \
alexdo/letsencrypt-gcloud-dnsNOTE: Multi-domain certificates are not supported. You need to request certificates for, eg., example.com and example.org seperately.
Environment Variables:
GCE_PROJECT– This is the name of your Google Cloud projectGCE_DOMAIN– This is the name of a domain within theGCE_PROJECTprojectEMAIL– Your email address. This will be sent to letsencrypt and acts as a contact address. It won't be made public.DOMAINS– A list of (sub)domains to be included in the certificate, seperated by comma (,).RENEW_DAYS– Threshold for certificate renewal in days. Default: 30 (= renew when cert expires in less than 30 days).
Volumes:
/gcloud-service-account.json– You need to mount the JSON key of your Google Cloud service account here/certstore– This should be an empty folder initially. Lego will store your letsencrypt account information and, more importantly, your domain's certificates here.
docker build -t some-name:1.2.3 .Copyright 2017-2021 Alexander Dormann
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.