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

[AVM Module Issue]: Getting Error On Terraform Plan #64

Closed
1 task done
nrv-96 opened this issue May 16, 2024 · 3 comments · Fixed by #66
Closed
1 task done

[AVM Module Issue]: Getting Error On Terraform Plan #64

nrv-96 opened this issue May 16, 2024 · 3 comments · Fixed by #66
Labels
Language: Terraform 🌐 This is related to the Terraform IaC language Needs: Triage 🔍 Maintainers need to triage still Type: Bug 🐛 Something isn't working

Comments

@nrv-96
Copy link

nrv-96 commented May 16, 2024

Check for previous/existing GitHub issues

  • I have checked for previous/existing GitHub issues

Issue Type?

Bug

(Optional) Module Version

"0.1.0"

(Optional) Correlation Id

No response

Description

I have below code:
main.tf

module "naming" {
source = "Azure/naming/azurerm"
version = ">= 0.4.1"
}

resource "azurerm_resource_group" "rg" {
location = var.location
name = module.naming.resource_group.name_unique
}

resource "azurerm_user_assigned_identity" "user_identity" {
location = azurerm_resource_group.rg.location
name = var.kubernetes_cluster_name
resource_group_name = azurerm_resource_group.rg.name
}

module "aks" {
source = "Azure/avm-ptn-aks-production/azurerm"
kubernetes_version = var.kubernetes_version
enable_telemetry = var.enable_telemetry
name = module.naming.kubernetes_cluster.name_unique
resource_group_name = azurerm_resource_group.rg.name
managed_identities = {
user_assigned_resource_ids = [
azurerm_user_assigned_identity.user_identity.id
]
}

location = azurerm_resource_group.rg.location
node_pools = {
workload = {
name = var.system_node_pool_name
vm_size = var.vm_size
orchestrator_version = var.kubernetes_version
max_count = 10
min_count = 1
os_sku = var.os_sku
mode = var.mode
}
}
}

Provider.tf

terraform {
required_version = ">= 1.3.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.7.0, < 4.0.0"
}
}
}

provider "azurerm" {
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}

Variable.tf

variable "enable_telemetry" {
type = bool
default = true
description = <<DESCRIPTION
This variable controls whether or not telemetry is enabled for the module.
For more information see https://aka.ms/avm/telemetryinfo.
If it is set to false, then no telemetry will be collected.
DESCRIPTION
}

variable "kubernetes_cluster_name" {
type = string
default = "demoaks"
description = "The name of the Kubernetes cluster."
}
variable "location" {
type = string
default = "eastus"
description = "value of the resource group location"
}
variable "kubernetes_version" {
type = string
default = "1.29.4"
description = "value of the kubernetes version"
}
variable "system_node_pool_name" {
type = string
default = "systemnode"
description = "Define the name of system node pool name"
validation {
condition = can(regex("^([a-z])([a-z0-9]){0,11}$", var.system_node_pool_name))
error_message = "Name must begin with a lowercase letter, contain only lowercase letters and numbers, and be between 1 and 12 characters in length."
}
}
variable "mode" {
type = string
default = "System" #System or User
description = "Define the mode of the cluster's Node"
}
variable "os_sku" {
type = string
default = "Ubuntu" #Ubuntu, CBLMariner, Mariner, Windows2019, Windows2022.
description = "value of the System Node OS Sku"
}
variable "vm_size" {
type = string
default = "Standard_B2s"
description = "value of the System Node VM Size"
}
variable "subscription_id" {
default = ""
type = string
}

variable "tenant_id" {
default = ""
type = string
}

variable "client_id" {
default = ""
type = string
}

variable "client_secret" {
default = ""
type = string
}

Getting Below Error While Terraform Plan:

Error: the "name" must begin with a lowercase letter, contain only lowercase letters and numbers and be between 1 and 12 characters in length, got "npnpsystmnodp1"

│ with module.aks.azurerm_kubernetes_cluster_node_pool.this["npsystmnodp1"],
│ on .terraform\modules\aks\main.tf line 225, in resource "azurerm_kubernetes_cluster_node_pool" "this":
│ 225: name = "np${each.value.name}"



│ Error: the "name" must begin with a lowercase letter, contain only lowercase letters and numbers and be between 1 and 12 characters in length, got "npnpsystmnodp2"

│ with module.aks.azurerm_kubernetes_cluster_node_pool.this["npsystmnodp2"],
│ on .terraform\modules\aks\main.tf line 225, in resource "azurerm_kubernetes_cluster_node_pool" "this":
│ 225: name = "np${each.value.name}"



│ Error: the "name" must begin with a lowercase letter, contain only lowercase letters and numbers and be between 1 and 12 characters in length, got "npnpsystmnodp3"

│ with module.aks.azurerm_kubernetes_cluster_node_pool.this["npsystmnodp3"],
│ on .terraform\modules\aks\main.tf line 225, in resource "azurerm_kubernetes_cluster_node_pool" "this":
│ 225: name = "np${each.value.name}"

@nrv-96 nrv-96 added Language: Terraform 🌐 This is related to the Terraform IaC language Needs: Triage 🔍 Maintainers need to triage still labels May 16, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Type: Bug 🐛 Something isn't working label May 16, 2024
@zioproto
Copy link
Collaborator

hello @nrv-96 . The problem is the nodepool name that is too long

│ Error: the "name" must begin with a lowercase letter, contain only lowercase letters and numbers and be between 1 and 12 characters in length, got "npnpsystmnodp3"

@nrv-96
Copy link
Author

nrv-96 commented May 16, 2024

@zioproto , Can you please add custom option enable and disable for log analytics and ACR registry?

@zioproto
Copy link
Collaborator

@zioproto , Can you please add custom option enable and disable for log analytics and ACR registry?

Sorry, this is a "pattern" module that includes ACR and Log Analytics. If you need more flexibility you should use https://github.com/Azure/terraform-azurerm-aks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language: Terraform 🌐 This is related to the Terraform IaC language Needs: Triage 🔍 Maintainers need to triage still Type: Bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants