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

Add multiple GCP HA instance to Unmanaged Instance Group by Terraform #12285

Closed
ss39881 opened this issue Aug 9, 2022 · 3 comments
Closed

Add multiple GCP HA instance to Unmanaged Instance Group by Terraform #12285

ss39881 opened this issue Aug 9, 2022 · 3 comments
Assignees

Comments

@ss39881
Copy link

ss39881 commented Aug 9, 2022

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

I need to add multiple cross zonal GCP instances to UIG. But, below code is attaching only few instances to UIG.

It is working as expected (creating UIG and attaching instances to terraform created UIG) if var.num_instances count is greater than or equal to length(data.google_compute_zones.available.names).

But , It does not attach instance in case length(data.google_compute_zones.available.names) is less than var.num_instances.

main.tf

data "google_compute_zones" "available" {
  project = var.project
  region  = var.region
}

module "google_uig" {
  source = "C:/Users/xxxx/OneDrive/Desktop/New folder/terraform-google-core/modules/compute_engine_uig"
  depends_on = [
    module.google_vm
  ]
  project = var.project
  # count   = var.num_instances
  count   = length(data.google_compute_zones.available.names) < var.num_instances ? length(data.google_compute_zones.available.names) : var.num_instances
  zone    = var.zone == null ? data.google_compute_zones.available.names[count.index % length(data.google_compute_zones.available.names)] : var.zone
  name         = "use1${[for zone in (data.google_compute_zones.available.names): substr(zone,-1,-1)][count.index]}-oss94-mta99-app-ig01"
  instances = element((module.google_vm[*].google_instance_id), count.index)
}

terraform.tfvars

project            = "gcp-test01"
region             = "us-central1"
num_instances      = "6"
image_project      = "gcp-kcfn01"
image_name         = "centos7-kent-v20220105"
instance_name      = "kcfn01-cfn01-apoc01-app"
tags               = ["oss01-mta-app", "usc1-sss-oss-snet01-local"]
machine_type       = "n1-standard-4"
disk_size          = "50"
disk_type          = "pd-standard"
boot_disk_size     = "50"
boot_disk_type     = "pd-standard"
network            = "cfn01-sss-net"
subnetwork         = "cfn01-usc1-sss-oss-snet01"
subnetwork_project = "gcp-kcfn01"

Potential Terraform Configuration

# Propose what you think the configuration to take advantage of this feature should look like.
# We may not use it verbatim, but it's helpful in understanding your intent.
@c2thorn c2thorn self-assigned this Aug 15, 2022
@ss39881
Copy link
Author

ss39881 commented Aug 18, 2022

@c2thorn Did you get a chance to look into it ?

@c2thorn
Copy link
Collaborator

c2thorn commented Aug 29, 2022

Hi @ss39881, this repository is not meant for debugging modules, but individual Google provider resources. From the information provided, I cannot tell if there is an issue with a specific resource, or some misconfiguration in the module you are using. If there is an issue with a specific resource, please help us replicate the issue by reducing your configuration down to a single file with the minimum resources to replicate, provide a debug log, and open the issue as a bug.

@c2thorn c2thorn closed this as completed Aug 29, 2022
@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2022
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

2 participants