Skip to content

Instantly share code, notes, and snippets.

@gerrowadat
gerrowadat / static-website-gcloud-migration.md
Last active December 5, 2023 07:57
Moving an existing static website to gcloud

Steps for moving an existing static website to gcloud (GCS bucket with an LB in front of it)

Some of this is covered in the gcloud docs here - I add in the part about safely migrating your SSL cert.

This assumes you have an SSL cert chain and private key, similar to those issued by letsencrypt. In my case I'm moving from a VM running nginx and letsencrypt certs.

First, set up the bucket as described in the above docs, or do the auto update from hugo thing I describe in this gist

Make sure access is open: gcloud storage buckets add-iam-policy-binding gs://my-static-assets --member=allUsers --role=roles/storage.objectViewer

@gerrowadat
gerrowadat / hugo-gcs-deploy.md
Last active December 5, 2023 04:17
Publishing a hugo webroot to a GCS bucket

The live version of this is in the andvarienterprises/www.strategichopes.co repo.

First, you'll need a gcloud project that has storage enabled. This is pretty easy to do, the free quota should cover you for a while. In my example, I create a bucket based on a domain I own, you'll need to verify ownership of a domain if you do similar, or try your luck with the global(!) bucket namespace otherwise.

Then, the commands to set up your bucket and a service account that has access to it looks something like:

# Set up with bucket-level access control and public reads.
gcloud storage buckets create gs://MYBUCKET/ \
  --uniform-bucket-level-access \

Keybase proof

I hereby claim:

  • I am gerrowadat on github.
  • I am gerrowadat (https://keybase.io/gerrowadat) on keybase.
  • I have a public key ASBzI5A92aSnebpdHsGQNH4gdQtD0c0JGO3oQar07H8ikwo

To claim this, I am signing this object: