terraform-aws-eks
terraform-aws-eks copied to clipboard
Invalid IAM Instance Profile name. Launching EC2 instance failed.
Receiving the below error intermittently (tried 5 times,got error 1 time) when running terraform code
waiting for Auto Scaling Group (blu****-m****--workers20230601115340628700000021) capacity satisfied: 1 error occurred: Scaling activity (a05621db-3a62-56b5-a136-d05fb7b7a8f6): Failed: Value (blu*-ma***20230601115339288600000017) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name. Launching EC2 instance failed.
This is my terraform code
module "key-pair" { source = "terraform-aws-modules/key-pair/aws" version = "2.0.0"
create = true
private_key_algorithm = "ED25519" key_name = "eks-${var.cluster_name}-${var.environment}" create_private_key = true
tags = { Environment = var.environment Description = "Key pair associated with ${var.cluster_name}-${var.environment} cluster" } }
module "eks" { source = "terraform-aws-modules/eks/aws" version = "17.24.0" cluster_name = "${var.cluster_name}-${var.environment}" cluster_version = var.cluster_version subnets = var.private_subnets write_kubeconfig = var.write_kubeconfig manage_aws_auth = var.manage_aws_auth map_users = local.user_map_obj enable_irsa = true vpc_id = var.vpc_id tags = { # "alpha.eksctl.io/cluster-oidc-enabled" = true Environment = var.environment }
workers_group_defaults = { root_volume_type = "gp2" }
workers_additional_policies = [ "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser", ]
worker_groups_launch_template = [ { name = "app-workers" key_name = "eks-${var.cluster_name}-${var.environment}" instance_type = var.worker_group_1_instance_type asg_min_size = 0 asg_desired_capacity = var.worker_group_1_desired asg_max_size = var.worker_group_1_desired autoscaling_enabled = true asg_force_delete = true enable_monitoring = false enabled_metrics = ["GroupMinSize", "GroupMaxSize", "GroupDesiredCapacity"] kubelet_extra_args = "--node-labels=role=apps" additional_userdata = "" suspended_processes = ["AZRebalance"] additional_security_group_ids = [var.additional_security_group_ids]
tags = [
{
"key" = "k8s.io/cluster-autoscaler/enabled"
"propagate_at_launch" = "true"
"value" = "true"
},
{
"key" = "k8s.io/cluster-autoscaler/${var.cluster_name}"
"propagate_at_launch" = "true"
"value" = "true"
}
]
},
{
name = "Loki-workers"
key_name = "eks-${var.cluster_name}-${var.environment}"
instance_type = var.worker_group_4_instance_type
asg_min_size = 0
asg_desired_capacity = var.worker_group_4_desired
asg_max_size = var.worker_group_4_desired
autoscaling_enabled = true
asg_force_delete = true
enable_monitoring = false
enabled_metrics = ["GroupMinSize", "GroupMaxSize", "GroupDesiredCapacity"]
kubelet_extra_args = "--node-labels=role=loki"
additional_userdata = ""
suspended_processes = ["AZRebalance"]
additional_security_group_ids = [var.additional_security_group_ids]
tags = [
{
"key" = "k8s.io/cluster-autoscaler/enabled"
"propagate_at_launch" = "true"
"value" = "true"
},
{
"key" = "k8s.io/cluster-autoscaler/${var.cluster_name}"
"propagate_at_launch" = "true"
"value" = "true"
}
]
}
] }