Created
March 2, 2023 21:23
-
-
Save niski84/82d5277743216176369e4891099f1426 to your computer and use it in GitHub Desktop.
get EB app logs
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
package main | |
import ( | |
"errors" | |
"fmt" | |
"os" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/elasticbeanstalk" | |
) | |
func getEBAppLogs(sess *session.Session, envName string, outputFile string) error { | |
// Create Elastic Beanstalk client | |
svc := elasticbeanstalk.New(sess) | |
// Retrieve logs for Elastic Beanstalk environment | |
params := &elasticbeanstalk.RequestEnvironmentInfoInput{ | |
EnvironmentName: aws.String(envName), | |
InfoType: aws.String("tail"), | |
} | |
resp, err := svc.RequestEnvironmentInfo(params) | |
if err != nil { | |
return err | |
} | |
// Write logs to output file | |
file, err := os.Create(outputFile) | |
if err != nil { | |
return err | |
} | |
defer file.Close() | |
_, err = file.WriteString(*resp.Message) | |
if err != nil { | |
return err | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment