Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a load balancer for a storage bucket #198

Open
chubibest opened this issue Aug 11, 2021 · 8 comments
Open

Creating a load balancer for a storage bucket #198

chubibest opened this issue Aug 11, 2021 · 8 comments
Labels
enhancement New feature or request P2 high priority issues triaged Scoped and ready for work

Comments

@chubibest
Copy link

I want to spin up a load balancer with an ip for a storage bucket, but I run into this error whenever I run 'terraform apply'
Screenshot 2021-08-11 at 16 08 24
This is my config file

resource "google_compute_backend_bucket" "storage_bucket_backend" {
  name        = "storage-bucket-backend"
  description = "${var.project} storage bucket"
  bucket_name = google_storage_bucket.storage_bucket.name
  enable_cdn  = true
  project       = var.project
}

resource "google_storage_bucket" "storage_bucket" {
  name     = "storage-bucket"
}

resource "google_storage_bucket_access_control" "public_rule" {
  bucket = google_storage_bucket.storage_bucket.name
  role   = "READER"
  entity = "allUsers"
}

module "cdn-lb-http" {
  source            = "GoogleCloudPlatform/lb-http/google"
  version = "~> 4.4"
  project           = var.project
  name              = "storage-bucket-backend-load-balancer"
  backends = {
    default = {

      affinity_cookie_ttl_sec         = null
      connection_draining_timeout_sec = null
      custom_request_headers          = null
      custom_response_headers         = null
      description                     = null
      enable_cdn                      = true

            protocol                        = "HTTP"
      port                            = 80
      port_name                       = "http"
      timeout_sec                     = 10
      connection_draining_timeout_sec = null
      enable_cdn                      = false
      security_policy                 = null
      session_affinity                = null
        health_check = {
        check_interval_sec  = null
        timeout_sec         = null
        healthy_threshold   = null
        unhealthy_threshold = null
        request_path        = "/"
        port                = null
        host                = null
        logging             = null
      }
      log_config = {
        enable = true
        sample_rate = 1.0
      }

      groups = [
        {
          # Each node pool instance group should be added to the backend.
          group = google_compute_backend_bucket.storage_bucket_backend.id
          balancing_mode               = null
          capacity_scaler              = null
          description                  = null
          max_connections              = null
          max_connections_per_instance = null
          max_connections_per_endpoint = null
          max_rate                     = null
          max_rate_per_instance        = null
          max_rate_per_endpoint        = null
          max_utilization              = null
        },
      ]

      iap_config = {
        enable               = false
        oauth2_client_id     = null
        oauth2_client_secret = null
      }
    }
  }

  cdn = true
  create_address = true
  https_redirect = true
  managed_ssl_certificate_domains = tolist(["cdn.${var.domain}"])
  ssl = true
  use_ssl_certificates = false
}

output "ip" {
  value = module.cdn-lb-http.external_ip
}

Little help please.

@chubibest chubibest changed the title Creating a Creating a load balancer with an ip for a storage bucket Aug 11, 2021
@chubibest chubibest changed the title Creating a load balancer with an ip for a storage bucket Creating a load balancer for a storage bucket Aug 11, 2021
@craigafinch
Copy link

@chubibest The immediate cause of the error message is that you haven't specified a port for the load balancer health check, so the module can't create a firewall rule to allow the health check. However, once you get past that hurdle, you'll find that it won't accept a google_compute_backend_bucket as a group. I don't think it's possible to use this module to create load balancers with backend buckets. If you look at Google's own module examples, they actually don't use the module to create the load balancer that uses the backend bucket:

resource "google_compute_url_map" "ml-bkd-ml-mig-bckt-s-lb" {

I think supporting a static backend bucket would be a great feature to add to this module-perhaps as a submodule.

@chubibest
Copy link
Author

Thank you, @craigafinch

@tguvdamm
Copy link

An example of just a LoadBalancer with a static backend bucket would indeed be greatly appreciated.

@craigafinch
Copy link

@chubibest @tguvdamm I posted an example of using a Cloud Storage bucket as a backend hosting for static files behind an HTTP/S load balancer.

@tguvdamm
Copy link

tguvdamm commented Oct 1, 2021

Thanks!

@chubibest
Copy link
Author

Bookmarking that!

@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Nov 30, 2021
@github-actions github-actions bot closed this as completed Dec 7, 2021
@morgante morgante reopened this Dec 9, 2021
@morgante morgante added enhancement New feature or request P2 high priority issues triaged Scoped and ready for work and removed Stale labels Dec 9, 2021
custodianbot pushed a commit to bycustodian/terraform-google-lb-http that referenced this issue Jul 22, 2022
terraform-google-modules#198)

* Support Query Insights

* Create insights_config when enabled only

* Set default as null

* Simplify logic

* Update

* Update modules/postgresql/variables.tf

* Regenerate doc

Co-authored-by: Morgante Pell <morgante.pell@morgante.net>
@red8888
Copy link

red8888 commented Jul 5, 2023

This is kinda weird right? I came here because I found no example on this page: https://registry.terraform.io/modules/GoogleCloudPlatform/lb-http/google/latest

Its like the simplest thing to do. Maybe thats why the module doesn't support it? Like its so simple that using a module would be overkill?

Just curious if this was deliberate because that reasoning kind of makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P2 high priority issues triaged Scoped and ready for work
Projects
None yet
Development

No branches or pull requests

5 participants