我已经用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"
基于注释。
问题是由于var.eks_version
为空。这是由于未在gitlabci
中映射.tfvars
造成的。
解决方案是在gitlabci
中添加丢失的映射。