Coder Social home page Coder Social logo

gcp-certbot's Introduction

GCP Certbot

Github action that creates/renews a Letsencrypt certificate and, optionally, links it to an existing GCP Load Balancer.

The action will try to obtain a wildcard certificate for the whole domain, *.my.domain , including the domain apex, my.domain.

It will store the certificate in an existing GCP Storage bucket for future reference when renewing the certificate.

Requirements

  • 1. Create a new HTTPS Load-balancer here

    • 1.1. If you have no HTTPS Front End you'll need a temporary certificate in order to create one. You can use a self signed, or Google managed certificate - The action will update it afterwards.
  • 2. Create a Cloud DNS Zone here

    • 2.1. Name it accordingly, if your domain is example.com then your DNS Zone's DNS Name should be example.com
    • 2.2. Setup your registrar to point to the new Google Cloud DNS zone. There is a link in the top right of the console, 'Registrar Setup', that has the values you'll need.
  • 3. Make sure that your service account has, at least, the following roles:

    • resourcemanager.projects.get
    • resourcemanager.projects.list
    • storage.objects.*
    • dns.changes.create
    • dns.changes.get
    • dns.managedZones.list
    • dns.resourceRecordSets.create
    • dns.resourceRecordSets.delete
    • dns.resourceRecordSets.list
    • dns.resourceRecordSets.update
  • 3.1. If updating a Load Balancer it also needs:

    • compute.forwardingRules.list
    • compute.globalOperations.get
    • compute.sslCertificates.create
    • compute.sslCertificates.get
    • compute.sslCertificates.list
    • compute.targetHttpsProxies.get
    • compute.targetHttpsProxies.list
    • compute.targetHttpsProxies.setSslCertificates

The certificates follow the naming pattern ZONE-TLD-CERTIFICATE-SERIAL where any dots in the domain will be replaced with dashes. Certificates will never be deleted, just removed from the load-balancer. You can see all certificates in the console here.

Inputs

gcp-project

Required Your google cloud project.

gcp-sa

Required The service account that will be used the action.

gcs-bucket

Required Google Cloud Storage bucket where the certificate will be stored.

email

Required The email that will be used when generating your letsencrypt certificates.

domain

Required The plain domain name for which certificates will be generated. The configured zone must match this. The request will be for a certificate that is valid for example.com and *.example.com.

front-end

Optional Load Balancer Front End where the certificate will be attached, leave blank if you don't want this. Default "".

tar-password

Optional (Recommended) Password that will be used to protect the tar file uploaded to GCS. Default "".

Outputs

certificate-name

The name of the created/renewed certificate.

Example usage

Creating/Renewing a certificate

name: GCP LetsEncrypt certificate
on:
  workflow_dispatch:
  schedule:
    - cron: '0 1 * * 0' # every week

jobs:
  lets-encrypt:
    runs-on: ubuntu-latest
    steps:
      - uses: danielguedesb/gcp-certbot@v1
      with:
        gcp-project: 'my-project'
        gcp-sa: '${{ secrets.my-project-sa }}'
        gcs-bucket: 'my-project-bucket'
        email: '[email protected]'
        domain: 'my-domain.com'

Creating/Renewing a certificate and attaching it to an HTTPS Load Balancer

name: GCP LetsEncrypt certificate
on:
  workflow_dispatch:
  schedule:
    - cron: '0 1 * * 0' # every week

jobs:
  lets-encrypt:
    runs-on: ubuntu-latest
    steps:
      - uses: danielguedesb/gcp-certbot@v1
        with:
          gcp-project: 'my-project'
          gcp-sa: '${{ secrets.my-project-sa }}'
          gcs-bucket: 'my-project-bucket'
          email: '[email protected]'
          domain: 'my-domain.com'
          front-end: 'lb-https-frontend-name'
          tar-password: 'my-cert-tar-password'

gcp-certbot's People

Contributors

danielguedesb avatar

Stargazers

Andrea Tvilling avatar Kevin Holmes avatar Simon Tardell avatar Martin Haintz avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.