An Image Server

Because Hugo is fine, but I’m having problems.

I don’t like the hugo image processing. It has trouble finding assets when using themes. Is there an easier way? I’m sure. But I’m not sure I care so much. I don’t mind requesting images from somewhere else. And I think I’d like a easy peezy GCP project. Why not?

Unfortunately, I don’t understand enough Terraform to just ask ChatGPT for all the answers. Funny how you need to know enough to ask the right questions and check the response in ordre to get the most out of it.

No worries. A little GCP knowledge and some searching of registry.terraform.io gave me what I need. A list of resources, configurations, and variables, to setup everything except the load balancer:

data "google_client_config" "default" {}

resource "random_id" "default" {
  byte_length = 2
}

locals {
  project_id          = var.project_id == "" ? data.google_client_config.default.project : var.project_id
  bucket_name         = var.name == "" ? format("%s-%s", local.project_id, random_id.default.dec) : var.name
  has_cors            = length(var.cors_origins) > 0 || length(var.cors_methods) > 0 || length(var.cors_response_headers) > 0
  has_predefined_acl  = var.predefined_acl != "" && ! var.bucket_policy_only
  has_role_entity_acl = length(var.role_entity) > 0 && ! var.bucket_policy_only
}


resource "google_compute_backend_bucket" "image_backend" {
  name        = local.bucket_name
  bucket_name = google_storage_bucket.image_backend.name
  enable_cdn  = var.enable_cdn
}


resource "google_storage_bucket" "image_backend" {
  name          = "vincebrand-images-v1"
  location      = var.location
  force_destroy = true

  uniform_bucket_level_access = true

  website {
    main_page_suffix = "index.html"
    not_found_page   = "404.html"
  }
  

and on and on it goes with vpc’s, subnets, and the whole like. With my cloud shell SSH added to github, I was able to clone the repository over and work through some apply/plan issues.

It freaking worked. I have a bucket. And I went through the load balancer wizard, the backend bucket was there, it attached, made an https certificate..holy crap moment of truth - can i pull images from my backend service at images.vincebrand.com…

Me!