From 06e2796237338bca7fa3c65a963fce9ae6614c96 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko <pavlenko.maksym@gmail.com> Date: Tue, 11 Dec 2018 22:49:39 -0800 Subject: [PATCH] Initial CloudWatch integration --- cf/podsync.yaml | 24 +++++++++++++++++++++++- cmd/app/main.go | 2 ++ docker-compose.yml | 6 ++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/cf/podsync.yaml b/cf/podsync.yaml index bb5ef5c..e268d8c 100644 --- a/cf/podsync.yaml +++ b/cf/podsync.yaml @@ -142,6 +142,18 @@ Resources: Resource: - "*" + # CloudWatch + LogGroup: + Type: AWS::Logs::LogGroup + Properties: + LogGroupName: !Ref "AWS::StackName" + RetentionInDays: 30 + BackendLogStream: + Type: AWS::Logs::LogStream + Properties: + LogGroupName: !Ref LogGroup + LogStreamName: "Backend" + # Access from DigitalOcean VM DOUser: Type: AWS::IAM::User @@ -150,7 +162,7 @@ Resources: - PledgesTable Properties: Policies: - - PolicyName: "DynamoAccess" + - PolicyName: "DynamoDB" PolicyDocument: Version: "2012-10-17" Statement: @@ -168,6 +180,16 @@ Resources: - "dynamodb:ListTables" Resource: - "*" + - PolicyName: "CloudWatch" + PolicyDocument: + Version: "2012-10-17" + Statement: + - Effect: Allow + Action: + - "logs:CreateLogStream" + - "logs:PutLogEvents" + Resource: + - "*" DOUserKey: Type: AWS::IAM::AccessKey DependsOn: DOUser diff --git a/cmd/app/main.go b/cmd/app/main.go index 9890e26..df05c67 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -24,6 +24,8 @@ import ( ) func main() { + log.SetFormatter(&log.JSONFormatter{}) + stop := make(chan os.Signal) signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM) diff --git a/docker-compose.yml b/docker-compose.yml index 742b5a8..bfd5177 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,12 @@ services: - DYNAMO_PLEDGES_TABLE_NAME=Prod_Pledges volumes: - {PATH_TO_GOOGLE_CREDENTIALS_FILE_FOR_USE_OUTSIDE_GOOGLE_CLOUD}:/google-credentials.json + logging: + driver: "awslogs" + options: + awslogs-region: "us-east-1" + awslogs-group: "Prod" + awslogs-stream: "Backend" ytdl: image: mxpv/ytdl container_name: ytdl