我已经使用terraform eks模块创建了以下eks集群。
module "myeks" {
source = "terraform-aws-modules/eks/aws"
cluster_name = var.project
version = "7.0.1"
cluster_version = var.eks_version
subnets = data.aws_subnet_ids.subnet_ids.ids
vpc_id = var.vpc_id
worker_groups = [
{
name = "worker-group-1"
instance_type = "m5.large"
asg_max_size = 2
}
]
}
但是问题是,当我在gitlabci中运行该代码时,遇到了以下错误消息。
Error: Invalid function argument
on .terraform/modules/myeks/data.tf line 6, in locals:
6: var.worker_ami_name_filter_windows : "Windows_Server-2019-English-Core-EKS_Optimized-${tonumber(var.cluster_version) >= 1.14 ? var.cluster_version : 1.14}-*"
|----------------
| var.cluster_version is ""
Invalid value for "v" parameter: cannot convert "" to number; given string
must be a decimal representation of a number.
Error: Your query returned no results. Please change your search criteria and try again.
on .terraform/modules/myeks/data.tf line 25, in data "aws_ami" "eks_worker":
25: data "aws_ami" "eks_worker" {
但是当我在本地计算机上执行terraform plan
时,它工作正常。
那是我的tfvars。
vpc_id = "vpc-xxxxx"
environment = "dev"
eks_version = "1.17"
project = "mypro"
答案 0 :(得分:2)
基于评论。
该问题是由于var.eks_version
为空。这是由于.tfvars
中的未映射 gitlabci
。
解决方案是在gitlabci
中添加缺少的映射。