Google Cloud provider
local-cert manages Cloud DNS as a service account, using its JSON key. One provider corresponds to one Google Cloud project.
Before you start
- The Cloud DNS API is enabled on the project (APIs & Services → Library → Cloud DNS API).
- The zone is public. A private zone is invisible to Let's Encrypt.
1. Create the service account
- Google Cloud console, the project that holds your zones → IAM & Admin → Service Accounts → Create service account.
- Name:
local-cert-dns. Create and continue. - Role: DNS Administrator (
roles/dns.admin). Continue, then Done.
Or from the command line:
gcloud
PROJECT=my-project
gcloud iam service-accounts create local-cert-dns --project "$PROJECT"
gcloud projects add-iam-policy-binding "$PROJECT" \
--member "serviceAccount:local-cert-dns@$PROJECT.iam.gserviceaccount.com" \
--role roles/dns.admin2. Create the JSON key
- Open the service account → Keys tab → Add key → Create new key → JSON.
- A
.jsonfile is downloaded: it is the only copy.
gcloud
gcloud iam service-accounts keys create local-cert-dns.json \
--iam-account "local-cert-dns@$PROJECT.iam.gserviceaccount.com"3. Create the provider
- Providers → + New provider → Google Cloud.
- Give it a name and paste the entire content of the JSON file. The project ID is read from the key; only fill it in if the zones are in a different project.
- Test connection, then Save. Then delete the downloaded file.
4. Add a domain
Domains → + Add a domain → this provider → the zone. The test creates and then deletes a temporary TXT record.
Good to know
- The
roles/dns.adminrole applies to every zone in the project. To isolate a zone, put it in a dedicated project, or grant the role at the zone level rather than the project level (the managed zone's IAM) while keepingroles/dns.readerfor the account on the project, for listing. - The domain must be delegated to the name servers Cloud DNS gives for the zone (
ns-cloud-*.googledomains.com). - Several projects: one provider per project, each with its own service account — or a single service account that each project grants the role to, declared as many providers with different project IDs.
Troubleshooting
| Message | Cause |
|---|---|
invalid_grant | Key deleted or service account disabled; server clock out of sync. |
403 … Cloud DNS API has not been used | The Cloud DNS API isn't enabled on the project. |
403 Forbidden | The service account doesn't have the DNS role on this project. |
The service account key is not valid JSON | The file was only partially pasted. |