Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-topK-parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexsJones authored May 16, 2024
2 parents 45bec75 + 882c6f5 commit 8e524ad
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions pkg/integration/aws/aws.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package aws

import (
"os"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
"github.com/spf13/viper"
"os"
)

type AWS struct {
Expand All @@ -23,16 +24,28 @@ func (a *AWS) UnDeploy(namespace string) error {
}

func (a *AWS) AddAnalyzer(mergedMap *map[string]common.IAnalyzer) {
// Check for AWS credentials in the environment
// https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html
if os.Getenv("AWS_ACCESS_KEY_ID") == "" || os.Getenv("AWS_SECRET_ACCESS_KEY") == "" {
panic("AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be set in the environment")
// Retrieve AWS credentials from the environment
accessKeyID := os.Getenv("AWS_ACCESS_KEY_ID")
secretAccessKey := os.Getenv("AWS_SECRET_ACCESS_KEY")
awsProfile := os.Getenv("AWS_PROFILE")

var sess *session.Session
if accessKeyID != "" && secretAccessKey != "" {
// Use access keys if both are provided
sess = session.Must(session.NewSessionWithOptions(session.Options{
Config: aws.Config{},
}))
} else {
// Use AWS profile, default to "default" if not set
if awsProfile == "" {
awsProfile = "default"
}
sess = session.Must(session.NewSessionWithOptions(session.Options{
Profile: awsProfile,
SharedConfigState: session.SharedConfigEnable,
}))
}

sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
Config: aws.Config{},
}))
a.sess = sess
(*mergedMap)["EKS"] = &EKSAnalyzer{
session: a.sess,
Expand Down

0 comments on commit 8e524ad

Please sign in to comment.