The previous error is gone. Now I am getting this error:
Blocks of type “tolerations” are not expected here. Did you mean “toleration”?
resource “aws_iam_role” “eks_vpc_cni_role” {
name = “eks-vpc-cni-role”
assume_role_policy = jsonencode({
Version = “2012-10-17”
Statement = [
{
Action = “sts:AssumeRole”
Effect = “Allow”
Principal = {
Service = “eks.amazonaws.com”
}
},
]
})
}
resource “aws_iam_policy” “eks_vpc_cni_policy” {
name = “eks-vpc-cni-policy”
description = “EKS VPC CNI policy allowing IPAM and ENI management”
policy = jsonencode(
{
Version = "2012-10-17"
Statement = [
{
Action = [
"ec2:DescribeNetworkInterfaces",
"ec2:CreateNetworkInterface",
"ec2:DeleteNetworkInterface",
"ec2:AssignPrivateIpAddresses",
"ec2:UnassignPrivateIpAddresses"
]
Effect = "Allow"
Resource = "*"
},
{
Action = [
"ec2:DescribeInstances",
"ec2:DescribeVpcs",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:DescribeRouteTables"
]
Effect = "Allow"
Resource = "*"
}
]
})
}
resource “aws_iam_role_policy_attachment” “eks_vpc_cni_attachment” {
policy_arn = aws_iam_policy.eks_vpc_cni_policy.arn
role = aws_iam_role.eks_vpc_cni_role.name
}
resource “kubernetes_daemonset” “aws_node” {
metadata {
name = “aws-node”
namespace = “kube-system”
labels = {
“k8s-app” = “aws-node”
}
}
spec {
selector {
match_labels = {
“k8s-app” = “aws-node”
}
}
template {
metadata {
labels = {
“k8s-app” = “aws-node”
}
}
spec {
container {
name = “aws-vpc-cni”
image = “amazon-k8s-ani:v1.19.0”
env {
name = "AWS_VPC_K8S_CNI_CUSTOM_NETWORK_CFG"
value = "true"
}
env {
name = "AWS_VPC_CNI_IPV4_PREFIX"
value = var.secondary_cidr
}
env {
name = "AWS_VPC_CNI_ENI_CONFIG"
value = "true"
}
}
service_account_name = "aws-node"
tolerations {
effect = "NoSchedule"
key = "node.kubernetes.io/not-ready"
operator = "Exists"
}
tolerations {
effect = "NoExecute"
key = "node.kubernetes.io/unreachable"
operator = "Exists"
}
}
}
}
}
resource “aws_eks_node_group” “example” {
cluster_name = var.cluster_name
node_group_name = var.use_name_prefix ? null : var.name
node_role_arn = var.create_iam_role ? aws_iam_role.this[0].arn : var.iam_role_arn
subnet_ids = var.subnet_ids
instance_types = [“t3.medium”]
scaling_config {
min_size = var.min_size
max_size = var.max_size
desired_size = var.desired_size
}
}