forked from aws/amazon-cloudwatch-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to make file and added tests
updated the create-eks-cluster to use a configfile add config file for clsuter creation added integration test skeleton
- Loading branch information
1 parent
ce7d039
commit b3d3cc4
Showing
3 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# cluster.yaml | ||
# A cluster with two managed nodegroups | ||
--- | ||
apiVersion: eksctl.io/v1alpha5 | ||
kind: ClusterConfig | ||
|
||
metadata: | ||
name: <namespace> | ||
region: <region> | ||
|
||
managedNodeGroups: | ||
- name: <namespace>-nodegroup-1 | ||
instanceType: t2.large | ||
minSize: 2 | ||
maxSize: 3 | ||
iam: | ||
attachPolicyARNs: | ||
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy | ||
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy | ||
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly | ||
- arn:aws:iam::aws:policy/ElasticLoadBalancingFullAccess | ||
- arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cz_tests | ||
|
||
import ( | ||
"flag" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/cloudwatchlogs" | ||
) | ||
|
||
var ( | ||
logGroupName = flag.String("logGroupName", "", "Name of the CloudWatch log group") | ||
region = flag.String("region", "", "Name of the AWS region") | ||
) | ||
|
||
func getCloudWatchLogGroupName(logGroupName, region string) (string, error) { | ||
sess, err := session.NewSession(&aws.Config{Region: aws.String(region)}) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
client := cloudwatchlogs.New(sess) | ||
|
||
input := &cloudwatchlogs.DescribeLogGroupsInput{ | ||
LogGroupNamePrefix: aws.String(logGroupName), | ||
Limit: aws.Int64(1), | ||
} | ||
|
||
resp, err := client.DescribeLogGroups(input) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if len(resp.LogGroups) == 0 { | ||
return "", nil | ||
} | ||
|
||
return *resp.LogGroups[0].LogGroupName, nil | ||
} | ||
|
||
func TestGetCloudWatchLogGroupName(t *testing.T) { | ||
flag.Parse() | ||
|
||
if *logGroupName == "" { | ||
t.Fatal("Please provide the CloudWatch log group name using the -logGroupName flag") | ||
} | ||
|
||
if *region == "" { | ||
t.Fatal("Please provide the CloudWatch log group name using the -logGroupName flag") | ||
} | ||
logGroupName, err := getCloudWatchLogGroupName(*logGroupName, *region) | ||
|
||
if err != nil { | ||
t.Fatalf("Error getting CloudWatch log group name: %v", err) | ||
} | ||
|
||
t.Logf("CloudWatch Log Group Name: %s", logGroupName) | ||
} |