Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

feat: add initial aws infra config #7

Merged
merged 2 commits into from
Jul 25, 2024
Merged

feat: add initial aws infra config #7

merged 2 commits into from
Jul 25, 2024

Conversation

Mystere98
Copy link
Contributor

Description

Linked Issues

Additional context

@Mystere98 Mystere98 requested a review from a team as a code owner July 25, 2024 21:14
Copy link

github-actions bot commented Jul 25, 2024

Terraform plan in terraform

Plan: 95 to add, 0 to change, 0 to destroy.
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+   create
 <= read (data resources)

Terraform will perform the following actions:

  # module.iam.aws_iam_user.user["Christophe"] will be created
+   resource "aws_iam_user" "user" {
+       arn           = (known after apply)
+       force_destroy = false
+       id            = (known after apply)
+       name          = "Christophe"
+       path          = "/"
+       tags          = {
+           "tag-key" = "*********"
        }
+       tags_all      = {
+           "tag-key" = "*********"
        }
+       unique_id     = (known after apply)
    }

  # module.iam.aws_iam_user.user["Lea"] will be created
+   resource "aws_iam_user" "user" {
+       arn           = (known after apply)
+       force_destroy = false
+       id            = (known after apply)
+       name          = "Lea"
+       path          = "/"
+       tags          = {
+           "tag-key" = "*********"
        }
+       tags_all      = {
+           "tag-key" = "*********"
        }
+       unique_id     = (known after apply)
    }

  # module.iam.aws_iam_user.user["Loic"] will be created
+   resource "aws_iam_user" "user" {
+       arn           = (known after apply)
+       force_destroy = false
+       id            = (known after apply)
+       name          = "Loic"
+       path          = "/"
+       tags          = {
+           "tag-key" = "*********"
        }
+       tags_all      = {
+           "tag-key" = "*********"
        }
+       unique_id     = (known after apply)
    }

  # module.iam.aws_iam_user.user["Massimo"] will be created
+   resource "aws_iam_user" "user" {
+       arn           = (known after apply)
+       force_destroy = false
+       id            = (known after apply)
+       name          = "Massimo"
+       path          = "/"
+       tags          = {
+           "tag-key" = "*********"
        }
+       tags_all      = {
+           "tag-key" = "*********"
        }
+       unique_id     = (known after apply)
    }

  # module.iam.aws_iam_user.user["Sacha"] will be created
+   resource "aws_iam_user" "user" {
+       arn           = (known after apply)
+       force_destroy = false
+       id            = (known after apply)
+       name          = "Sacha"
+       path          = "/"
+       tags          = {
+           "tag-key" = "*********"
        }
+       tags_all      = {
+           "tag-key" = "*********"
        }
+       unique_id     = (known after apply)
    }

  # module.iam.aws_iam_user_login_profile.login["Christophe"] will be created
+   resource "aws_iam_user_login_profile" "login" {
+       encrypted_password      = (known after apply)
+       id                      = (known after apply)
+       key_fingerprint         = (known after apply)
+       password                = (known after apply)
+       password_length         = 20
+       password_reset_required = (known after apply)
+       pgp_key                 = "************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************"
+       user                    = "Christophe"
    }

  # module.iam.aws_iam_user_login_profile.login["Lea"] will be created
+   resource "aws_iam_user_login_profile" "login" {
+       encrypted_password      = (known after apply)
+       id                      = (known after apply)
+       key_fingerprint         = (known after apply)
+       password                = (known after apply)
+       password_length         = 20
+       password_reset_required = (known after apply)
+       pgp_key                 = "************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************"
+       user                    = "Lea"
    }

  # module.iam.aws_iam_user_login_profile.login["Loic"] will be created
+   resource "aws_iam_user_login_profile" "login" {
+       encrypted_password      = (known after apply)
+       id                      = (known after apply)
+       key_fingerprint         = (known after apply)
+       password                = (known after apply)
+       password_length         = 20
+       password_reset_required = (known after apply)
+       pgp_key                 = "************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************"
+       user                    = "Loic"
    }

  # module.iam.aws_iam_user_login_profile.login["Massimo"] will be created
+   resource "aws_iam_user_login_profile" "login" {
+       encrypted_password      = (known after apply)
+       id                      = (known after apply)
+       key_fingerprint         = (known after apply)
+       password                = (known after apply)
+       password_length         = 20
+       password_reset_required = (known after apply)
+       pgp_key                 = "************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************"
+       user                    = "Massimo"
    }

  # module.iam.aws_iam_user_login_profile.login["Sacha"] will be created
+   resource "aws_iam_user_login_profile" "login" {
+       encrypted_password      = (known after apply)
+       id                      = (known after apply)
+       key_fingerprint         = (known after apply)
+       password                = (known after apply)
+       password_length         = 20
+       password_reset_required = (known after apply)
+       pgp_key                 = "************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************"
+       user                    = "Sacha"
    }

  # module.iam.aws_iam_user_policy_attachment.test-attach["Christophe"] will be created
+   resource "aws_iam_user_policy_attachment" "test-attach" {
+       id         = (known after apply)
+       policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
+       user       = "Christophe"
    }

  # module.iam.aws_iam_user_policy_attachment.test-attach["Lea"] will be created
+   resource "aws_iam_user_policy_attachment" "test-attach" {
+       id         = (known after apply)
+       policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
+       user       = "Lea"
    }

  # module.iam.aws_iam_user_policy_attachment.test-attach["Loic"] will be created
+   resource "aws_iam_user_policy_attachment" "test-attach" {
+       id         = (known after apply)
+       policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
+       user       = "Loic"
    }

  # module.iam.aws_iam_user_policy_attachment.test-attach["Massimo"] will be created
+   resource "aws_iam_user_policy_attachment" "test-attach" {
+       id         = (known after apply)
+       policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
+       user       = "Massimo"
    }

  # module.iam.aws_iam_user_policy_attachment.test-attach["Sacha"] will be created
+   resource "aws_iam_user_policy_attachment" "test-attach" {
+       id         = (known after apply)
+       policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
+       user       = "Sacha"
    }

  # module.vpc.data.aws_subnets.private_subnets_primary_cidr will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "aws_subnets" "private_subnets_primary_cidr" {
+       id   = (known after apply)
+       ids  = (known after apply)
+       tags = (known after apply)

+       filter {
+           name   = "cidr-block"
+           values = [
+               "10.0.4.0/24",
+               "10.0.5.0/24",
+               "10.0.6.0/24",
            ]
        }
    }

  # module.vpc.data.aws_subnets.private_subnets_secondary_cidr will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "aws_subnets" "private_subnets_secondary_cidr" {
+       id   = (known after apply)
+       ids  = (known after apply)
+       tags = (known after apply)

+       filter {
+           name   = "cidr-block"
+           values = [
+               "100.64.0.0/20",
+               "100.64.16.0/20",
+               "100.64.32.0/20",
            ]
        }
    }

  # module.eks.module.eks.data.aws_eks_addon_version.this["coredns"] will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "aws_eks_addon_version" "this" {
+       addon_name         = "coredns"
+       id                 = (known after apply)
+       kubernetes_version = "1.30"
+       version            = (known after apply)
    }

  # module.eks.module.eks.data.aws_eks_addon_version.this["kube-proxy"] will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "aws_eks_addon_version" "this" {
+       addon_name         = "kube-proxy"
+       id                 = (known after apply)
+       kubernetes_version = "1.30"
+       version            = (known after apply)
    }

  # module.eks.module.eks.data.aws_eks_addon_version.this["vpc-cni"] will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "aws_eks_addon_version" "this" {
+       addon_name         = "vpc-cni"
+       id                 = (known after apply)
+       kubernetes_version = "1.30"
+       version            = (known after apply)
    }

  # module.eks.module.eks.data.tls_certificate.this[0] will be read during apply
  # (config refers to values not yet known)
 <= data "tls_certificate" "this" {
+       certificates = (known after apply)
+       id           = (known after apply)
+       url          = (known after apply)
    }

  # module.eks.module.eks.aws_cloudwatch_log_group.this[0] will be created
+   resource "aws_cloudwatch_log_group" "this" {
+       arn               = (known after apply)
+       id                = (known after apply)
+       log_group_class   = (known after apply)
+       name              = "/aws/eks/presentium/cluster"
+       name_prefix       = (known after apply)
+       retention_in_days = 90
+       skip_destroy      = false
+       tags              = {
+           "Name"                   = "/aws/eks/presentium/cluster"
+           "karpenter.sh/discovery" = "presentium"
        }
+       tags_all          = {
+           "Name"                   = "/aws/eks/presentium/cluster"
+           "karpenter.sh/discovery" = "presentium"
        }
    }

  # module.eks.module.eks.aws_ec2_tag.cluster_primary_security_group["karpenter.sh/discovery"] will be created
+   resource "aws_ec2_tag" "cluster_primary_security_group" {
+       id          = (known after apply)
+       key         = "karpenter.sh/discovery"
+       resource_id = (known after apply)
+       value       = "presentium"
    }

  # module.eks.module.eks.aws_eks_addon.this["coredns"] will be created
+   resource "aws_eks_addon" "this" {
+       addon_name                  = "coredns"
+       addon_version               = "v1.11.1-eksbuild.9"
+       arn                         = (known after apply)
+       cluster_name                = "presentium"
+       configuration_values        = jsonencode(
            {
+               computeType = "Fargate"
            }
        )
+       created_at                  = (known after apply)
+       id                          = (known after apply)
+       modified_at                 = (known after apply)
+       preserve                    = true
+       resolve_conflicts_on_create = "OVERWRITE"
+       resolve_conflicts_on_update = "OVERWRITE"
+       tags                        = {
+           "karpenter.sh/discovery" = "presentium"
        }
+       tags_all                    = {
+           "karpenter.sh/discovery" = "presentium"
        }

+       timeouts {}
    }

  # module.eks.module.eks.aws_eks_addon.this["kube-proxy"] will be created
+   resource "aws_eks_addon" "this" {
+       addon_name                  = "kube-proxy"
+       addon_version               = "v1.30.0-eksbuild.3"
+       arn                         = (known after apply)
+       cluster_name                = "presentium"
+       configuration_values        = (known after apply)
+       created_at                  = (known after apply)
+       id                          = (known after apply)
+       modified_at                 = (known after apply)
+       preserve                    = true
+       resolve_conflicts_on_create = "OVERWRITE"
+       resolve_conflicts_on_update = "OVERWRITE"
+       tags                        = {
+           "karpenter.sh/discovery" = "presentium"
        }
+       tags_all                    = {
+           "karpenter.sh/discovery" = "presentium"
        }

+       timeouts {}
    }

  # module.eks.module.eks.aws_eks_addon.this["vpc-cni"] will be created
+   resource "aws_eks_addon" "this" {
+       addon_name                  = "vpc-cni"
+       addon_version               = "v1.18.1-eksbuild.3"
+       arn                         = (known after apply)
+       cluster_name                = "presentium"
+       configuration_values        = jsonencode(
            {
+               env = {
+                   ENABLE_PREFIX_DELEGATION = "true"
+                   WARM_PREFIX_TARGET       = "1"
                }
            }
        )
+       created_at                  = (known after apply)
+       id                          = (known after apply)
+       modified_at                 = (known after apply)
+       preserve                    = true
+       resolve_conflicts_on_create = "OVERWRITE"
+       resolve_conflicts_on_update = "OVERWRITE"
+       service_account_role_arn    = (known after apply)
+       tags                        = {
+           "karpenter.sh/discovery" = "presentium"
        }
+       tags_all                    = {
+           "karpenter.sh/discovery" = "presentium"
        }

+       timeouts {}
    }

  # module.eks.module.eks.aws_eks_cluster.this[0] will be created
+   resource "aws_eks_cluster" "this" {
+       arn                           = (known after apply)
+       bootstrap_self_managed_addons = true
+       certificate_authority         = (known after apply)
+       cluster_id                    = (known after apply)
+       created_at                    = (known after apply)
+       endpoint                      = (known after apply)
+       id                            = (known after apply)
+       identity                      = (known after apply)
+       name                          = "presentium"
+       platform_version              = (known after apply)
+       role_arn                      = (known after apply)
+       status                        = (known after apply)
+       tags                          = {
+           "karpenter.sh/discovery" = "presentium"
+           "terraform-aws-modules"  = "eks"
        }
+       tags_all                      = {
+           "karpenter.sh/discovery" = "presentium"
+           "terraform-aws-modules"  = "eks"
        }
+       version                       = "1.30"

+       access_config {
+           authentication_mode                         = "API_AND_CONFIG_MAP"
+           bootstrap_cluster_creator_admin_permissions = false
        }

+       encryption_config {
+           resources = [
+               "secrets",
            ]

+           provider {
+               key_arn = (known after apply)
            }
        }

+       kubernetes_network_config {
+           ip_family         = "ipv4"
+           service_ipv4_cidr = (known after apply)
+           service_ipv6_cidr = (known after apply)
        }

+       timeouts {}

+       vpc_config {
+           cluster_security_group_id = (known after apply)
+           endpoint_private_access   = true
+           endpoint_public_access    = true
+           public_access_cidrs       = [
+               "0.0.0.0/0",
            ]
+           subnet_ids                = (known after apply)
+           vpc_id                    = (known after apply)
        }
    }

  # module.eks.module.eks.aws_iam_openid_connect_provider.oidc_provider[0] will be created
+   resource "aws_iam_openid_connect_provider" "oidc_provider" {
+       arn             = (known after apply)
+       client_id_list  = [
+           "sts.amazonaws.com",
        ]
+       id              = (known after apply)
+       tags            = {
+           "Name"                   = "presentium-eks-irsa"
+           "karpenter.sh/discovery" = "presentium"
        }
+       tags_all        = {
+           "Name"                   = "presentium-eks-irsa"
+           "karpenter.sh/discovery" = "presentium"
        }
+       thumbprint_list = (known after apply)
+       url             = (known after apply)
    }

  # module.eks.module.eks.aws_iam_policy.cluster_encryption[0] will be created
+   resource "aws_iam_policy" "cluster_encryption" {
+       arn              = (known after apply)
+       attachment_count = (known after apply)
+       description      = "Cluster encryption policy to allow cluster role to utilize CMK provided"
+       id               = (known after apply)
+       name             = (known after apply)
+       name_prefix      = "presentium-cluster-ClusterEncryption"
+       path             = "/"
+       policy           = (known after apply)
+       policy_id        = (known after apply)
+       tags             = {
+           "karpenter.sh/discovery" = "presentium"
        }
+       tags_all         = {
+           "karpenter.sh/discovery" = "presentium"
        }
    }

  # module.eks.module.eks.aws_iam_role.this[0] will be created
+   resource "aws_iam_role" "this" {
+       arn                   = (known after apply)
+       assume_role_policy    = jsonencode(
            {
+               Statement = [
+                   {
+                       Action    = "sts:AssumeRole"
+                       Effect    = "Allow"
+                       Principal = {
+                           Service = "eks.amazonaws.com"
                        }
+                       Sid       = "EKSClusterAssumeRole"
                    },
                ]
+               Version   = "2012-10-17"
            }
        )
+       create_date           = (known after apply)
+       force_detach_policies = true
+       id                    = (known after apply)
+       managed_policy_arns   = (known after apply)
+       max_session_duration  = 3600
+       name                  = (known after apply)
+       name_prefix           = "presentium-cluster-"
+       path                  = "/"
+       tags                  = {
+           "karpenter.sh/discovery" = "presentium"
        }
+       tags_all              = {
+           "karpenter.sh/discovery" = "presentium"
        }
+       unique_id             = (known after apply)

+       inline_policy {
+           name   = "presentium-cluster"
+           policy = jsonencode(
                {
+                   Statement = [
+                       {
+                           Action   = [
+                               "logs:CreateLogGroup",
                            ]
+                           Effect   = "Deny"
+                           Resource = "*"
                        },
                    ]
+                   Version   = "2012-10-17"
                }
            )
        }
    }

  # module.eks.module.eks.aws_iam_role_policy_attachment.cluster_encryption[0] will be created
+   resource "aws_iam_role_policy_attachment" "cluster_encryption" {
+       id         = (known after apply)
+       policy_arn = (known after apply)
+       role       = (known after apply)
    }

  # module.eks.module.eks.aws_iam_role_policy_attachment.this["AmazonEKSClusterPolicy"] will be created
+   resource "aws_iam_role_policy_attachment" "this" {
+       id         = (known after apply)
+       policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
+       role       = (known after apply)
    }

  # module.eks.module.eks.aws_iam_role_policy_attachment.this["AmazonEKSVPCResourceController"] will be created
+   resource "aws_iam_role_policy_attachment" "this" {
+       id         = (known after apply)
+       policy_arn = "arn:aws:iam::aws:policy/AmazonEKSVPCResourceController"
+       role       = (known after apply)
    }

  # module.eks.module.eks.time_sleep.this[0] will be created
+   resource "time_sleep" "this" {
+       create_duration = "30s"
+       id              = (known after apply)
+       triggers        = {
+           "cluster_certificate_authority_data" = (known after apply)
+           "cluster_endpoint"                   = (known after apply)
+           "cluster_name"                       = "presentium"
+           "cluster_service_cidr"               = (known after apply)
+           "cluster_version"                    = "1.30"
        }
    }

  # module.eks.module.karpenter.data.aws_iam_policy_document.controller[0] will be read during apply
  # (config refers to values not yet known)
 <= data "aws_iam_policy_document" "controller" {
+       id            = (known after apply)
+       json          = (known after apply)
+       minified_json = (known after apply)

+       statement {
+           actions   = [
+               "ec2:CreateFleet",
+               "ec2:RunInstances",
            ]
+           resources = [
+               "arn:aws:ec2:*:*:launch-template/*",
+               "arn:aws:ec2:*:*:security-group/*",
+               "arn:aws:ec2:*:*:spot-instances-request/*",
+               "arn:aws:ec2:*:*:subnet/*",
+               "arn:aws:ec2:*::image/*",
+               "arn:aws:ec2:*::snapshot/*",
            ]
+           sid       = "AllowScopedEC2InstanceActions"
        }
+       statement {
+           actions   = [
+               "ec2:CreateFleet",
+               "ec2:CreateLaunchTemplate",
+               "ec2:RunInstances",
            ]
+           resources = [
+               "arn:aws:ec2:*:*:fleet/*",
+               "arn:aws:ec2:*:*:instance/*",
+               "arn:aws:ec2:*:*:launch-template/*",
+               "arn:aws:ec2:*:*:network-interface/*",
+               "arn:aws:ec2:*:*:spot-instances-request/*",
+               "arn:aws:ec2:*:*:volume/*",
            ]
+           sid       = "AllowScopedEC2InstanceActionsWithTags"

+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "owned",
                ]
+               variable = "aws:RequestTag/kubernetes.io/cluster/presentium"
            }
+           condition {
+               test     = "StringLike"
+               values   = [
+                   "*",
                ]
+               variable = "aws:RequestTag/karpenter.sh/nodepool"
            }
        }
+       statement {
+           actions   = [
+               "ec2:CreateTags",
            ]
+           resources = [
+               "arn:aws:ec2:*:*:fleet/*",
+               "arn:aws:ec2:*:*:instance/*",
+               "arn:aws:ec2:*:*:launch-template/*",
+               "arn:aws:ec2:*:*:network-interface/*",
+               "arn:aws:ec2:*:*:spot-instances-request/*",
+               "arn:aws:ec2:*:*:volume/*",
            ]
+           sid       = "AllowScopedResourceCreationTagging"

+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "RunInstances",
+                   "CreateFleet",
+                   "CreateLaunchTemplate",
                ]
+               variable = "ec2:CreateAction"
            }
+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "owned",
                ]
+               variable = "aws:RequestTag/kubernetes.io/cluster/presentium"
            }
+           condition {
+               test     = "StringLike"
+               values   = [
+                   "*",
                ]
+               variable = "aws:RequestTag/karpenter.sh/nodepool"
            }
        }
+       statement {
+           actions   = [
+               "ec2:CreateTags",
            ]
+           resources = [
+               "arn:aws:ec2:*:*:instance/*",
            ]
+           sid       = "AllowScopedResourceTagging"

+           condition {
+               test     = "ForAllValues:StringEquals"
+               values   = [
+                   "karpenter.sh/nodeclaim",
+                   "Name",
                ]
+               variable = "aws:TagKeys"
            }
+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "owned",
                ]
+               variable = "aws:ResourceTag/kubernetes.io/cluster/presentium"
            }
+           condition {
+               test     = "StringLike"
+               values   = [
+                   "*",
                ]
+               variable = "aws:ResourceTag/karpenter.sh/nodepool"
            }
        }
+       statement {
+           actions   = [
+               "ec2:DeleteLaunchTemplate",
+               "ec2:TerminateInstances",
            ]
+           resources = [
+               "arn:aws:ec2:*:*:instance/*",
+               "arn:aws:ec2:*:*:launch-template/*",
            ]
+           sid       = "AllowScopedDeletion"

+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "owned",
                ]
+               variable = "aws:ResourceTag/kubernetes.io/cluster/presentium"
            }
+           condition {
+               test     = "StringLike"
+               values   = [
+                   "*",
                ]
+               variable = "aws:ResourceTag/karpenter.sh/nodepool"
            }
        }
+       statement {
+           actions   = [
+               "ec2:DescribeAvailabilityZones",
+               "ec2:DescribeImages",
+               "ec2:DescribeInstanceTypeOfferings",
+               "ec2:DescribeInstanceTypes",
+               "ec2:DescribeInstances",
+               "ec2:DescribeLaunchTemplates",
+               "ec2:DescribeSecurityGroups",
+               "ec2:DescribeSpotPriceHistory",
+               "ec2:DescribeSubnets",
            ]
+           resources = [
+               "*",
            ]
+           sid       = "AllowRegionalReadActions"

+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "eu-west-1",
                ]
+               variable = "aws:RequestedRegion"
            }
        }
+       statement {
+           actions   = [
+               "ssm:GetParameter",
            ]
+           resources = [
+               "arn:aws:ssm:eu-west-1::parameter/aws/service/*",
            ]
+           sid       = "AllowSSMReadActions"
        }
+       statement {
+           actions   = [
+               "pricing:GetProducts",
            ]
+           resources = [
+               "*",
            ]
+           sid       = "AllowPricingReadActions"
        }
+       statement {
+           actions   = [
+               "sqs:DeleteMessage",
+               "sqs:GetQueueAttributes",
+               "sqs:GetQueueUrl",
+               "sqs:ReceiveMessage",
            ]
+           resources = [
+               (known after apply),
            ]
+           sid       = "AllowInterruptionQueueActions"
        }
+       statement {
+           actions   = [
+               "iam:PassRole",
            ]
+           resources = [
+               (known after apply),
            ]
+           sid       = "AllowPassingInstanceRole"

+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "ec2.amazonaws.com",
                ]
+               variable = "iam:PassedToService"
            }
        }
+       statement {
+           actions   = [
+               "iam:CreateInstanceProfile",
            ]
+           resources = [
+               "*",
            ]
+           sid       = "AllowScopedInstanceProfileCreationActions"

+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "eu-west-1",
                ]
+               variable = "aws:RequestTag/topology.kubernetes.io/region"
            }
+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "owned",
                ]
+               variable = "aws:RequestTag/kubernetes.io/cluster/presentium"
            }
+           condition {
+               test     = "StringLike"
+               values   = [
+                   "*",
                ]
+               variable = "aws:RequestTag/karpenter.k8s.aws/ec2nodeclass"
            }
        }
+       statement {
+           actions   = [
+               "iam:TagInstanceProfile",
            ]
+           resources = [
+               "*",
            ]
+           sid       = "AllowScopedInstanceProfileTagActions"

+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "eu-west-1",
                ]
+               variable = "aws:ResourceTag/topology.kubernetes.io/region"
            }
+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "owned",
                ]
+               variable = "aws:RequestTag/kubernetes.io/cluster/presentium"
            }
+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "owned",
                ]
+               variable = "aws:ResourceTag/kubernetes.io/cluster/presentium"
            }
+           condition {
+               test     = "StringLike"
+               values   = [
+                   "*",
                ]
+               variable = "aws:RequestTag/karpenter.k8s.aws/ec2nodeclass"
            }
+           condition {
+               test     = "StringLike"
+               values   = [
+                   "*",
                ]
+               variable = "aws:ResourceTag/karpenter.k8s.aws/ec2nodeclass"
            }
        }
+       statement {
+           actions   = [
+               "iam:AddRoleToInstanceProfile",
+               "iam:DeleteInstanceProfile",
+               "iam:RemoveRoleFromInstanceProfile",
            ]
+           resources = [
+               "*",
            ]
+           sid       = "AllowScopedInstanceProfileActions"

+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "eu-west-1",
                ]
+               variable = "aws:ResourceTag/topology.kubernetes.io/region"
            }
+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "owned",
                ]
+               variable = "aws:ResourceTag/kubernetes.io/cluster/presentium"
            }
+           condition {
+               test     = "StringLike"
+               values   = [
+                   "*",
                ]
+               variable = "aws:ResourceTag/karpenter.k8s.aws/ec2nodeclass"
            }
        }
+       statement {
+           actions   = [
+               "iam:GetInstanceProfile",
            ]
+           resources = [
+               "*",
            ]
+           sid       = "AllowInstanceProfileReadActions"
        }
+       statement {
+           actions   = [
+               "eks:DescribeCluster",
            ]
+           resources = [
+               "arn:aws:eks:eu-west-1:123247571664:cluster/presentium",
            ]
+           sid       = "AllowAPIServerEndpointDiscovery"
        }
    }

  # module.eks.module.karpenter.data.aws_iam_policy_document.controller_assume_role[0] will be read during apply
  # (config refers to values not yet known)
 <= data "aws_iam_policy_document" "controller_assume_role" {
+       id            = (known after apply)
+       json          = (known after apply)
+       minified_json = (known after apply)

+       statement {
+           actions = [
+               "sts:AssumeRole",
+               "sts:TagSession",
            ]

+           principals {
+               identifiers = [
+                   "pods.eks.amazonaws.com",
                ]
+               type        = "Service"
            }
        }
+       statement {
+           actions = [
+               "sts:AssumeRoleWithWebIdentity",
            ]

+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "sts.amazonaws.com",
                ]
+               variable = (known after apply)
            }
+           condition {
+               test     = "StringEquals"
+               values   = [
+                   "system:serviceaccount:karpenter:karpenter",
                ]
+               variable = (known after apply)
            }

+           principals {
+               identifiers = [
+                   (known after apply),
                ]
+               type        = "Federated"
            }
        }
    }

  # module.eks.module.karpenter.data.aws_iam_policy_document.queue[0] will be read during apply
  # (config refers to values not yet known)
 <= data "aws_iam_policy_document" "queue" {
+       id            = (known after apply)
+       json          = (known after apply)
+       minified_json = (known after apply)

+       statement {
+           actions   = [
+               "sqs:SendMessage",
            ]
+           resources = [
+               (known after apply),
            ]
+           sid       = "SqsWrite"

+           principals {
+               identifiers = [
+                   "events.amazonaws.com",
+                   "sqs.amazonaws.com",
                ]
+               type        = "Service"
            }
        }
    }

  # module.eks.module.karpenter.aws_cloudwatch_event_rule.this["health_event"] will be created
+   resource "aws_cloudwatch_event_rule" "this" {
+       arn            = (known after apply)
+       description    = "Karpenter interrupt - AWS health event"
+       event_bus_name = "default"
+       event_pattern  = jsonencode(
            {
+               detail-type = [
+                   "AWS Health Event",
                ]
+               source      = [
+                   "aws.health",
                ]
            }
        )
+       force_destroy  = false
+       id             = (known after apply)
+       name           = (known after apply)
+       name_prefix    = "KarpenterHealthEvent-"
+       tags           = {
+           "ClusterName" = "presentium"
        }
+       tags_all       = {
+           "ClusterName" = "presentium"
        }
    }

  # module.eks.module.karpenter.aws_cloudwatch_event_rule.this["instance_rebalance"] will be created
+   resource "aws_cloudwatch_event_rule" "this" {
+       arn            = (known after apply)
+       description    = "Karpenter interrupt - EC2 instance rebalance recommendation"
+       event_bus_name = "default"
+       event_pattern  = jsonencode(
            {
+               detail-type = [
+                   "EC2 Instance Rebalance Recommendation",
                ]
+               source      = [
+                   "aws.ec2",
                ]
            }
        )
+       force_destroy  = false
+       id             = (known after apply)
+       name           = (known after apply)
Plan is too large to fit in a PR comment. See the full plan in the workflow log.

✅ Plan applied in Apply terraform plan #3

@Mystere98 Mystere98 merged commit 953a233 into production Jul 25, 2024
4 checks passed
@Lutonite Lutonite deleted the dev branch July 31, 2024 19:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant