From 9ece6e39c3bda03dd5daf73b4de0344ce8f0f7d9 Mon Sep 17 00:00:00 2001 From: Sai Vennam Date: Wed, 18 Oct 2023 16:05:14 -0500 Subject: [PATCH] move node role creation to terraform --- .../mng/.workshop/terraform/addon.tf | 28 +++++++++++++++++++ .../managed-node-groups/spot/index.md | 16 +++++++---- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/manifests/modules/fundamentals/mng/.workshop/terraform/addon.tf b/manifests/modules/fundamentals/mng/.workshop/terraform/addon.tf index 759f04aa9..475b2b1b3 100644 --- a/manifests/modules/fundamentals/mng/.workshop/terraform/addon.tf +++ b/manifests/modules/fundamentals/mng/.workshop/terraform/addon.tf @@ -17,8 +17,36 @@ data "aws_subnets" "private" { } } +resource "aws_iam_role" "spot_node" { + name = "${local.addon_context.eks_cluster_id}-spot-node" + + assume_role_policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Action = "sts:AssumeRole" + Effect = "Allow" + Sid = "" + Principal = { + Service = "ec2.amazonaws.com" + } + }, + ] + }) + + managed_policy_arns = [ + "arn:${local.addon_context.aws_partition_id}:iam::aws:policy/AmazonEKS_CNI_Policy", + "arn:${local.addon_context.aws_partition_id}:iam::aws:policy/AmazonEKSWorkerNodePolicy", + "arn:${local.addon_context.aws_partition_id}:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly", + "arn:${local.addon_context.aws_partition_id}:iam::aws:policy/AmazonSSMManagedInstanceCore" + ] + + tags = local.tags +} + output "environment" { value = <