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

missing google_compute_network_endpoint_group data source #4096

Closed
one1zero1one opened this issue Jul 24, 2019 · 2 comments
Closed

missing google_compute_network_endpoint_group data source #4096

one1zero1one opened this issue Jul 24, 2019 · 2 comments

Comments

@one1zero1one
Copy link

one1zero1one commented Jul 24, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Data source for google_compute_network_endpoint_group would be useful to safer/better automate gke resources with traffic manager. Currently using

  annotations:
    cloud.google.com/neg: '{"exposed_ports":{"XXXX":{}}}'

GKE creates a convenient NEG that can be used outside the cluster, e.g with traffic manager etc. Terraform can express pretty much all the bits needed to setup lb's, but can't easily include objects created by GKE.

New or Affected Resource(s)

  • google_compute_network_endpoint_group

Potential Terraform Configuration

The way I work around it now, is by data external.

data "external" "negs" {
  program = ["bash", "${var.path}/data-external-scripts/get-negs.sh"]
  query = {
    service = var.service
  }
}

where the get-negs.sh is a flatten map with NEGs links.
I use the service name as a filter, not completely happy with it, but did not find another way.

#!/bin/bash

# Exit if any of the intermediate steps fail
set -e

# Extract "foo" and "baz" arguments from the input into
# FOO and BAZ shell variables.
# jq will ensure that the values are properly quoted
# and escaped for consumption by the shell.
eval "$(jq -r '@sh "SERVICE=\(.service)"')"

# Placeholder for whatever data-fetching logic your script implements
SERVICE="$SERVICE"

gcloud beta compute network-endpoint-groups list --format json |  jq --arg target "$SERVICE" '[.[] | select( .name | contains($target))] | [.[] | { (.selfLink): .selfLink }] | add'

Then, in a google_compute_backend_service resource, I create as many backends my service has for_each

  dynamic "backend" {
    for_each = keys(data.external.negs.result)
    content {
      group                 = backend.value
      balancing_mode        = "RATE"
      max_rate_per_endpoint = var.max_rate_per_endpoint
    }
  }

References

@ghost ghost added the enhancement label Jul 24, 2019
@emilymye emilymye self-assigned this Jul 24, 2019
@paddycarver paddycarver added this to the Goals milestone Dec 6, 2019
@emilymye
Copy link
Contributor

emilymye commented Dec 13, 2019

Whoops, forgot to close this - done by community contributor @bpineau in GoogleCloudPlatform/magic-modules#2112

@ghost
Copy link

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants