-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Dependencies for cloudinit_post_nodeadm content result in Invalid count argument
error
#3334
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
Comments
Additional additional context:Due to the nature of the error, this really only matters on the initial deploy of the resources. If the I recently started moving over to AL2023, and noticed this issue. When using |
Invalid count argument
errorInvalid count argument
error
this isn't quite valid - |
I'm not sure I am tracking. The output above would indicate that it is trying to use it - no? Can you provide more information on what is not valid about the example? |
https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html#launch-template-user-data you can only specify user data that is added *ahead of what EKS MNG adds. in the case of AL2, the user data supplied is added *before the in the case of AL2023, the user data supplied is merged *before the therefore, what you posted above and what I've modified below, they result in the same outcome in terms of resources/configuration created: module "eks_al2023" {
source = "terraform-aws-modules/eks/aws"
version = "= 20.35.0"
cluster_name = "testing-al2023"
cluster_version = "1.31"
# EKS Addons
cluster_addons = {
coredns = {}
eks-pod-identity-agent = {}
kube-proxy = {}
vpc-cni = {}
}
# vpc_id = module.vpc.vpc_id
# subnet_ids = module.vpc.private_subnets
vpc_id = "vpc-myvpc"
subnet_ids = [
"subnet-mysubnet1",
"subnet-mysubnet2",
"subnet-mysubnet3"
]
eks_managed_node_groups = {
example = {
# Starting on 1.30, AL2023 is the default AMI type for EKS managed node groups
instance_types = ["m6i.large"]
min_size = 1
max_size = 1
# This value is ignored after the initial creation
# https://github.com/bryantbiggs/eks-desired-size-hack
desired_size = 1
# This is not required - demonstrates how to pass additional configuration to nodeadm
# Ref https://awslabs.github.io/amazon-eks-ami/nodeadm/doc/api/
cloudinit_pre_nodeadm = [
{
content_type = "application/node.eks.aws"
content = <<-EOT
---
apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
kubelet:
config:
shutdownGracePeriod: 30s
featureGates:
DisableKubeletCloudCredentialProviders: true
EOT
}
]
}
}
} |
Two things I am noticing:
module "eks_al2023" {
source = "terraform-aws-modules/eks/aws"
version = "= 20.35.0"
cluster_name = "testing-al2023"
cluster_version = "1.31"
# EKS Addons
cluster_addons = {
coredns = {}
eks-pod-identity-agent = {}
kube-proxy = {}
vpc-cni = {}
}
# vpc_id = module.vpc.vpc_id
# subnet_ids = module.vpc.private_subnets
vpc_id = "vpc-myvpc"
subnet_ids = [
"subnet-mysubnet1",
"subnet-mysubnet2",
"subnet-mysubnet3"
]
eks_managed_node_groups = {
example = {
# Starting on 1.30, AL2023 is the default AMI type for EKS managed node groups
instance_types = ["m6i.large"]
min_size = 1
max_size = 1
# This value is ignored after the initial creation
# https://github.com/bryantbiggs/eks-desired-size-hack
desired_size = 1
}
}
eks_managed_node_group_defaults = {
enable_bootstrap_user_data = true
ami_type = "AL2023_x86_64_STANDARD"
cloudinit_pre_nodeadm = [{
content_type = "text/x-shellscript; charset=\"us-ascii\""
content = random_password.my_password
}]
}
}
resource "random_password" "my_password" {
length = 32
} |
Description
It would seem that
cloudinit_post_nodeadm
content can not depend on resources that terraform needs to create. Doing so results in aInvalid count argument
error.Below is an example that adds dummy data to the content. It doesn't make sense but proves the point. If there were a real template that used that data, the result should be the same.
Versions
Module version [Required]: 20.35.0
Terraform version: Terraform v1.5.7
Provider version(s):
Reproduction Code [Required]
Steps to reproduce the behavior:
main.tf
file with the contents abovevpc_id
andsubnet_ids
with ones you have access toExpected behavior
Plan succeeds and can apply the code
Actual behavior
Plan fails with the error below
Terminal Output Screenshot(s)
Text version of error:
Additional context
Removing the dependency on the
random_password
and replacing it's contents with"mypassword"
allows the plan to succeed.The text was updated successfully, but these errors were encountered: