Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement EKS E2E Terraform Framework #434

Merged
merged 22 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 69 additions & 69 deletions environment/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,84 +23,84 @@ var metaDataStorage *MetaData = nil
var registeredMetaDataStrings = &(MetaDataStrings{})

type MetaData struct {
ComputeType computetype.ComputeType
EcsLaunchType ecslaunchtype.ECSLaunchType
EcsDeploymentStrategy ecsdeploymenttype.ECSDeploymentType
EksDeploymentStrategy eksdeploymenttype.EKSDeploymentType
EcsClusterArn string
EcsClusterName string
CwagentConfigSsmParamName string
EcsServiceName string
EC2PluginTests map[string]struct{} // set of EC2 plugin names
ExcludedTests map[string]struct{} // set of excluded names
Bucket string
S3Key string
CwaCommitSha string
CaCertPath string
EKSClusterName string
ProxyUrl string
AssumeRoleArn string
InstanceId string
InstancePlatform string
AgentStartCommand string
EksGpuType string
AmpWorkspaceId string
Region string
K8sVersion string
HelmChartsBranch string
CloudwatchAgentRepository string
CloudwatchAgentTag string
CloudwatchAgentRepositoryURL string
CloudwatchAgentOperatorRepository string
CloudwatchAgentOperatorTag string
CloudwatchAgentOperatorRepositoryURL string
ComputeType computetype.ComputeType
EcsLaunchType ecslaunchtype.ECSLaunchType
EcsDeploymentStrategy ecsdeploymenttype.ECSDeploymentType
EksDeploymentStrategy eksdeploymenttype.EKSDeploymentType
EcsClusterArn string
EcsClusterName string
CwagentConfigSsmParamName string
EcsServiceName string
EC2PluginTests map[string]struct{} // set of EC2 plugin names
ExcludedTests map[string]struct{} // set of excluded names
Bucket string
S3Key string
CwaCommitSha string
CaCertPath string
EKSClusterName string
ProxyUrl string
AssumeRoleArn string
InstanceId string
InstancePlatform string
AgentStartCommand string
EksGpuType string
AmpWorkspaceId string
Region string
K8sVersion string
HelmChartsBranch string
CloudwatchAgentRepository string
CloudwatchAgentTag string
CloudwatchAgentRepositoryURL string
CloudwatchAgentOperatorRepository string
CloudwatchAgentOperatorTag string
CloudwatchAgentOperatorRepositoryURL string
CloudwatchAgentTargetAllocatorRepository string
musa-asad marked this conversation as resolved.
Show resolved Hide resolved
CloudwatchAgentTargetAllocatorTag string
CloudwatchAgentTargetAllocatorRepositoryURL string
AgentConfig string
PrometheusConfig string
OtelConfig string
SampleApp string
AgentConfig string
PrometheusConfig string
OtelConfig string
SampleApp string
}

type MetaDataStrings struct {
ComputeType string
EcsLaunchType string
EcsDeploymentStrategy string
EksDeploymentStrategy string
EcsClusterArn string
CwagentConfigSsmParamName string
EcsServiceName string
EC2PluginTests string // input comma delimited list of plugin names
ExcludedTests string // Exclude specific tests from OS
Bucket string
S3Key string
CwaCommitSha string
CaCertPath string
EKSClusterName string
ProxyUrl string
AssumeRoleArn string
InstanceId string
InstancePlatform string
AgentStartCommand string
EksGpuType string
AmpWorkspaceId string
Region string
K8sVersion string
HelmChartsBranch string
CloudwatchAgentRepository string
CloudwatchAgentTag string
CloudwatchAgentRepositoryURL string
CloudwatchAgentOperatorRepository string
CloudwatchAgentOperatorTag string
CloudwatchAgentOperatorRepositoryURL string
ComputeType string
EcsLaunchType string
EcsDeploymentStrategy string
EksDeploymentStrategy string
EcsClusterArn string
CwagentConfigSsmParamName string
EcsServiceName string
EC2PluginTests string // input comma delimited list of plugin names
ExcludedTests string // Exclude specific tests from OS
Bucket string
S3Key string
CwaCommitSha string
CaCertPath string
EKSClusterName string
ProxyUrl string
AssumeRoleArn string
InstanceId string
InstancePlatform string
AgentStartCommand string
EksGpuType string
AmpWorkspaceId string
Region string
K8sVersion string
HelmChartsBranch string
CloudwatchAgentRepository string
CloudwatchAgentTag string
CloudwatchAgentRepositoryURL string
CloudwatchAgentOperatorRepository string
CloudwatchAgentOperatorTag string
CloudwatchAgentOperatorRepositoryURL string
CloudwatchAgentTargetAllocatorRepository string
CloudwatchAgentTargetAllocatorTag string
CloudwatchAgentTargetAllocatorRepositoryURL string
AgentConfig string
PrometheusConfig string
OtelConfig string
SampleApp string
AgentConfig string
PrometheusConfig string
OtelConfig string
SampleApp string
}

func registerComputeType(dataString *MetaDataStrings) {
Expand Down
6 changes: 3 additions & 3 deletions terraform/eks/e2e/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ resource "aws_eks_node_group" "this" {
subnet_ids = module.basic_components.public_subnet_ids

scaling_config {
desired_size = 2
max_size = 2
min_size = 2
musa-asad marked this conversation as resolved.
Show resolved Hide resolved
desired_size = 1
max_size = 1
min_size = 1
}

ami_type = "AL2_x86_64"
Expand Down
11 changes: 0 additions & 11 deletions terraform/eks/e2e/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,4 @@

provider "aws" {
region = var.region
}

provider "kubernetes" {
exec {
api_version = "client.authentication.k8s.io/v1beta1"
command = "aws"
args = ["eks", "get-token", "--cluster-name", aws_eks_cluster.this.name]
}
host = aws_eks_cluster.this.endpoint
cluster_ca_certificate = base64decode(aws_eks_cluster.this.certificate_authority.0.data)
token = data.aws_eks_cluster_auth.this.token
}
39 changes: 14 additions & 25 deletions util/awsservice/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,23 @@ var (

func init() {
ctx = context.Background()
var err error
awsCfg, err := config.LoadDefaultConfig(ctx, config.WithRegion("us-west-2"))

err := ConfigureAWSClients("us-west-2")
if err != nil {
fmt.Println("There was an error trying to configure the AWS clients: ", err)
}
}

// ConfigureAWSClients configures the AWS clients using a set region.
func ConfigureAWSClients(region string) error {
mu.Lock()
defer mu.Unlock()
musa-asad marked this conversation as resolved.
Show resolved Hide resolved

awsCfg, err := config.LoadDefaultConfig(ctx, config.WithRegion(region))
if err != nil {
// handle error
fmt.Println("There was an error trying to load default config: ", err)
return
return err
}
fmt.Println("This is the aws region: ", awsCfg.Region)

Expand All @@ -78,28 +89,6 @@ func init() {
S3Client = s3.NewFromConfig(awsCfg)
CloudformationClient = cloudformation.NewFromConfig(awsCfg)
XrayClient = xray.NewFromConfig(awsCfg)
}

// ReconfigureAWSClients reconfigures the AWS clients using a new region.
func ReconfigureAWSClients(region string) error {
mu.Lock()
defer mu.Unlock()

newCfg, err := config.LoadDefaultConfig(ctx, config.WithRegion(region))
if err != nil {
return err
}

Ec2Client = ec2.NewFromConfig(newCfg)
EcsClient = ecs.NewFromConfig(newCfg)
SsmClient = ssm.NewFromConfig(newCfg)
ImdsClient = imds.NewFromConfig(newCfg)
CwmClient = cloudwatch.NewFromConfig(newCfg)
CwlClient = cloudwatchlogs.NewFromConfig(newCfg)
DynamodbClient = dynamodb.NewFromConfig(newCfg)
S3Client = s3.NewFromConfig(newCfg)
CloudformationClient = cloudformation.NewFromConfig(newCfg)
XrayClient = xray.NewFromConfig(newCfg)

return nil
}
Loading