This repository was archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logging to service's container definition
Log to Cloudwatch Logs to enable future development of `fargate service <service name> logs`. * Don't segfault if there are no tasks yet in service ps and service info * If ECR repository already exists, use it rather than returning an error * Favor AWS SDK constants over local constants
- Loading branch information
Showing
12 changed files
with
131 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cloudwatchlogs | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/awserr" | ||
awscwl "github.com/aws/aws-sdk-go/service/cloudwatchlogs" | ||
"github.com/jpignata/fargate/console" | ||
) | ||
|
||
func (cwl *CloudWatchLogs) CreateLogGroup(logGroupName string, a ...interface{}) string { | ||
formattedLogGroupName := fmt.Sprintf(logGroupName, a...) | ||
_, err := cwl.svc.CreateLogGroup( | ||
&awscwl.CreateLogGroupInput{ | ||
LogGroupName: aws.String(formattedLogGroupName), | ||
}, | ||
) | ||
|
||
if err != nil { | ||
if awsErr, ok := err.(awserr.Error); ok { | ||
switch awsErr.Code() { | ||
case awscwl.ErrCodeResourceAlreadyExistsException: | ||
return formattedLogGroupName | ||
default: | ||
console.ErrorExit(awsErr, "Could not create Cloudwatch Logs log group") | ||
} | ||
} | ||
} | ||
|
||
return formattedLogGroupName | ||
} |
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,23 @@ | ||
package cloudwatchlogs | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/cloudwatchlogs" | ||
"github.com/jpignata/fargate/console" | ||
) | ||
|
||
type CloudWatchLogs struct { | ||
svc *cloudwatchlogs.CloudWatchLogs | ||
} | ||
|
||
func New() CloudWatchLogs { | ||
sess, err := session.NewSession() | ||
|
||
if err != nil { | ||
console.ErrorExit(err, "Error creating CloudWatch Logs session") | ||
} | ||
|
||
return CloudWatchLogs{ | ||
svc: cloudwatchlogs.New(sess), | ||
} | ||
} |
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
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
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
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
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