Skip to content

Commit

Permalink
update eks terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
tinhtq committed Oct 26, 2024
1 parent a1c4f25 commit 614c0ad
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
File renamed without changes.
22 changes: 22 additions & 0 deletions eks/terraform/iam.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
data "aws_iam_policy_document" "assume_role" {
statement {
effect = "Allow"

principals {
type = "Service"
identifiers = ["eks.amazonaws.com"]
}

actions = ["sts:AssumeRole"]
}
}

resource "aws_iam_role" "eks" {
name_prefix = "eks-role"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}

resource "aws_iam_role_policy_attachment" "example-AmazonEKSClusterPolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
role = aws_iam_role.eks.name
}
19 changes: 2 additions & 17 deletions eks/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@


resource "aws_eks_cluster" "cluster" {
name = "eks_cluster"
role_arn = aws_iam_role.eks_cluster.arn
name = "eks-cluster"
role_arn = aws_iam_role.eks.arn
version = "1.31"
vpc_config {
subnet_ids = [data.aws_subnet.zone_a.id, data.aws_subnet.zone_b.id]
}
}


resource "aws_autoscaling_policy" "bat" {
name = "eks_dynamic_scaling"
policy_type = "TargetTrackingScaling"
target_tracking_configuration {
predefined_metric_specification {
predefined_metric_type = "ASGAverageCPUUtilization"

}
target_value = 60
}
autoscaling_group_name = module.eks_self_managed_node_group.name
}

0 comments on commit 614c0ad

Please sign in to comment.