Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 16 additions & 2 deletions test/e2e/shared/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/aws/aws-sdk-go/service/elb"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/aws/aws-sdk-go/service/servicequotas"
"github.com/aws/aws-sdk-go/service/sts"
cfn_iam "github.com/awslabs/goformation/v4/cloudformation/iam"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -635,6 +636,19 @@ func GetPolicyArn(prov client.ConfigProvider, name string) string {
return ""
}

func logAccountDetails(prov client.ConfigProvider) {
By("Getting AWS account details")
stsSvc := sts.New(prov)

output, err := stsSvc.GetCallerIdentity(&sts.GetCallerIdentityInput{})
if err != nil {
fmt.Fprintf(GinkgoWriter, "couldn't get sts caller identity: err=%s", err)
return
}

fmt.Fprintf(GinkgoWriter, "Using AWS account: %s", *output.Account)
}

// deleteCloudFormationStack removes the provisioned clusterawsadm stack.
func deleteCloudFormationStack(prov client.ConfigProvider, t *cfn_bootstrap.Template) {
By(fmt.Sprintf("Deleting %s CloudFormation stack", t.Spec.StackName))
Expand Down Expand Up @@ -837,7 +851,7 @@ func DumpCloudTrailEvents(e2eCtx *E2EContext) {
if err != nil {
fmt.Fprintf(GinkgoWriter, "Failed to marshal AWS CloudTrail events: err=%v", err)
}
if err := os.WriteFile(logPath, dat, 0600); err != nil {
if err := os.WriteFile(logPath, dat, 0o600); err != nil {
fmt.Fprintf(GinkgoWriter, "couldn't write cloudtrail events to file: file=%s err=%s", logPath, err)
return
}
Expand Down Expand Up @@ -1008,7 +1022,7 @@ func dumpEKSCluster(cluster *eks.Cluster, logPath string) {
}
defer f.Close()

if err := os.WriteFile(f.Name(), clusterYAML, 0600); err != nil {
if err := os.WriteFile(f.Name(), clusterYAML, 0o600); err != nil {
fmt.Fprintf(GinkgoWriter, "couldn't write cluster yaml to file: name=%s file=%s err=%s", *cluster.Name, f.Name(), err)
return
}
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/shared/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func Node1BeforeSuite(e2eCtx *E2EContext) []byte {

Expect(err).NotTo(HaveOccurred())
e2eCtx.AWSSession = NewAWSSession()

logAccountDetails(e2eCtx.AWSSession)

bootstrapTemplate := getBootstrapTemplate(e2eCtx)
bootstrapTags := map[string]string{"capa-e2e-test": "true"}
e2eCtx.CloudFormationTemplate = renderCustomCloudFormation(bootstrapTemplate)
Expand Down
Loading