diff --git a/environment/eksdeploymenttype/eks_deployment_type.go b/environment/eksdeploymenttype/eks_deployment_type.go index 856a2db00..5fb0edb9d 100644 --- a/environment/eksdeploymenttype/eks_deployment_type.go +++ b/environment/eksdeploymenttype/eks_deployment_type.go @@ -8,18 +8,20 @@ import "strings" type EKSDeploymentType string const ( - DAEMON EKSDeploymentType = "DAEMON" - REPLICA EKSDeploymentType = "REPLICA" - SIDECAR EKSDeploymentType = "SIDECAR" - STATEFUL EKSDeploymentType = "STATEFUL" + DAEMON EKSDeploymentType = "DAEMON" + REPLICA EKSDeploymentType = "REPLICA" + SIDECAR EKSDeploymentType = "SIDECAR" + STATEFUL EKSDeploymentType = "STATEFUL" + PODIDENTITY EKSDeploymentType = "PODIDENTITY" ) var ( eksDeploymentTypes = map[string]EKSDeploymentType{ - "DAEMON": DAEMON, - "REPLICA": REPLICA, - "SIDECAR": SIDECAR, - "STATEFUL": STATEFUL, + "DAEMON": DAEMON, + "REPLICA": REPLICA, + "SIDECAR": SIDECAR, + "STATEFUL": STATEFUL, + "PODIDENTITY": PODIDENTITY, } ) diff --git a/generator/test_case_generator.go b/generator/test_case_generator.go index 26c245623..7258f362d 100644 --- a/generator/test_case_generator.go +++ b/generator/test_case_generator.go @@ -242,6 +242,10 @@ var testTypeToTestConfig = map[string][]testConfig{ testDir: "./test/efa", terraformDir: "terraform/eks/daemon/efa", targets: map[string]map[string]struct{}{"arc": {"amd64": {}}}, }, + { + testDir: "./test/metric_value_benchmark", terraformDir: "terraform/eks/daemon/credentials/pod_identity", + targets: map[string]map[string]struct{}{"arc": {"amd64": {}}}, + }, }, "eks_deployment": { {testDir: "./test/metric_value_benchmark"}, diff --git a/terraform/eks/daemon/credentials/pod_identity/main.tf b/terraform/eks/daemon/credentials/pod_identity/main.tf new file mode 100644 index 000000000..59b1ca5d0 --- /dev/null +++ b/terraform/eks/daemon/credentials/pod_identity/main.tf @@ -0,0 +1,323 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: MIT + +module "common" { + source = "../../../../common" +} + +module "basic_components" { + source = "../../../../basic_components" + + region = var.region +} + +locals { + aws_eks = "aws eks --region ${var.region}" +} + +data "aws_eks_cluster_auth" "this" { + name = aws_eks_cluster.this.name +} + +resource "aws_eks_cluster" "this" { + name = "cwagent-eks-integ-${module.common.testing_id}" + role_arn = module.basic_components.role_arn + version = var.k8s_version + vpc_config { + subnet_ids = module.basic_components.public_subnet_ids + security_group_ids = [module.basic_components.security_group] + } +} + +# EKS Node Groups +resource "aws_eks_node_group" "this" { + cluster_name = aws_eks_cluster.this.name + node_group_name = "cwagent-eks-integ-node-${module.common.testing_id}" + node_role_arn = aws_iam_role.node_role.arn + subnet_ids = module.basic_components.public_subnet_ids + + scaling_config { + desired_size = 1 + max_size = 1 + min_size = 1 + } + + ami_type = var.ami_type + capacity_type = "ON_DEMAND" + disk_size = 20 + instance_types = [var.instance_type] + + depends_on = [ + aws_iam_role_policy_attachment.node_AmazonEC2ContainerRegistryReadOnly, + aws_iam_role_policy_attachment.node_AmazonEKS_CNI_Policy, + aws_iam_role_policy_attachment.node_AmazonEKSWorkerNodePolicy, + aws_iam_role_policy_attachment.pod_CloudWatchAgentServerPolicy + ] +} + +resource "aws_eks_addon" "pod_identity_addon" { + cluster_name = aws_eks_cluster.this.name + addon_name = "eks-pod-identity-agent" + depends_on = [aws_eks_node_group.this] +} + +# EKS Node IAM Role +resource "aws_iam_role" "node_role" { + name = "cwagent-eks-Worker-Role-${module.common.testing_id}" + + assume_role_policy = <