# Unexpected attribute: An attribute named "max\_node\_count" is not expected here

**URL:** <https://discuss.hashicorp.com/t/unexpected-attribute-an-attribute-named-max-node-count-is-not-expected-here/66292>\
**Category:** Google\
**Created:** [April 23, 2024, 9:51am UTC](https://discuss.hashicorp.com/t/unexpected-attribute-an-attribute-named-max-node-count-is-not-expected-here/66292 "2024-04-23T09:51:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Killpit](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/killpit/32/41406_2.png) [@Killpit](https://discuss.hashicorp.com/u/Killpit)\
**Post date:** [April 23, 2024, 9:51am UTC](https://discuss.hashicorp.com/t/unexpected-attribute-an-attribute-named-max-node-count-is-not-expected-here/66292/1 "2024-04-23T09:51:55Z")

</div>

Hi there,

Even though it’s possible to define maximum node count through variables, I get the error outlined above and when I remove them, it works perfectly.

main.tf file

```auto
# Define variables for cluster configuration (unchanged)

# Define the main GKE cluster (unchanged)
resource "google_container_cluster" "gke_cluster" {
  name = var.cluster_name
  location = var.location
  initial_node_count = var.initial_node_count
}

# Define a separate node pool with desired machine type and maximum count
resource "google_container_node_pool" "high_mem_pool" {
  name = "high-mem-pool"
  cluster = google_container_cluster.gke_cluster.name
  node_count = var.initial_node_count # Initial node count (can be adjusted)
  max_node_count = var.maximum_node_count # Use the defined variable

  # Set machine type with more memory for memory-intensive workloads
  node_config {
    machine_type = "e2-standard-8"
  }
}

```

variables.tf

```auto
# Define variables for cluster configuration (variable block)
variable "cluster_name" {
 default = "gke-terraform"
}

variable "location" {
 default = "us-central1"
}

variable "initial_node_count" {
 default = 1
}

variable "maximum_node_count" {
  default = 3
}

```

providers.tf

```auto
provider "google" {
  project = "project-id" #change project id to suit your project
  region = "us-central1"
}

```

I don’t know why I get the error and when I extensively looked at the problem, I looked at documentation and other resources extensively but couldn’t find an answer.

---

<div class="post-metadata">

**Author:** ![ExtelligenceIT](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/extelligenceit/32/41411_2.png) [@ExtelligenceIT](https://discuss.hashicorp.com/u/ExtelligenceIT)\
**Post date:** [April 23, 2024, 1:24pm UTC](https://discuss.hashicorp.com/t/unexpected-attribute-an-attribute-named-max-node-count-is-not-expected-here/66292/2 "2024-04-23T13:24:12Z")

</div>

Hi @Killpit,

You may get some further answers from those familiar with the GCP provider if you post this to the Terraform Providers category.

However - The documentation [google\_container\_node\_pool | Resources | hashicorp/google | Terraform | Terraform Registry](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_node_pool) does confirm that there is not a `max_node_count` argument at the top level of a `google_container_node_pool` as you have it here. Which is why you are getting the error, as that attribute is not expected.

Perhaps what you need is the `autoscaling` block within the resource which does have a `max_node_count`

So your resource block would look more like this:

```auto
resource "google_container_node_pool" "high_mem_pool" {
  name = "high-mem-pool"
  cluster = google_container_cluster.gke_cluster.name
  node_count = var.initial_node_count # Initial node count (can be adjusted)
  
  autoscaling {
     max_node_count = var.maximum_node_count # Use the defined variable
  }
  # Set machine type with more memory for memory-intensive workloads
  node_config {
    machine_type = "e2-standard-8"
  }
}

```

I am not familiar with the GCP provider, so, while the above is based upon the documentation, you may need some further attributes in that block depending upon the combination that the provider is expecting.

Hope that helps

Happy Terraforming

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/hashicorp/original/1X/79bf76adfd92a75631996933098f9ce29d37abf3.svg) [@system](https://discuss.hashicorp.com/u/system)\
**Post date:** [October 20, 2024, 1:24pm UTC](https://discuss.hashicorp.com/t/unexpected-attribute-an-attribute-named-max-node-count-is-not-expected-here/66292/3 "2024-10-20T13:24:51Z")

</div>

Closed on October 20, 2024, 1:24pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
