Last active
August 29, 2015 14:27
-
-
Save mvanholsteijn/1399ccd934fdc4fc91ac to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# | |
# Installs and Configures the AWS cloudwatch agent, and sets the default log group name and region | |
# | |
# | |
# You need to add the following policy statement to the machine's IAM role. | |
# | |
# { | |
# "Effect": "Allow", | |
# "Action": [ | |
# "logs:CreateLogGroup", | |
# "logs:CreateLogStream", | |
# "logs:PutLogEvents", | |
# "logs:DescribeLogStreams" | |
# ], | |
# "Resource": [ | |
# "arn:aws:logs:*:*:*" | |
# ] | |
# } | |
# | |
LOG_GROUP=ecs-syslog-default | |
REGION=eu-west-1 | |
function usage() { | |
echo "USAGE: $(basename $0) [-g log-group-name] [-r region]" >&2 | |
echo " $@" >&2 | |
} | |
while getopts ":g:r:" OPT; do | |
case $OPT in | |
g) | |
LOG_GROUP=$OPTARG;; | |
r) | |
REGION=$OPTARG;; | |
\?) | |
usage "Invalid option: -$OPTARG" | |
exit 1 ;; | |
esac | |
done | |
sudo yum install -y awslogs | |
sudo sed -i "s/^region[ \t]*=.*/region = $REGION/" /etc/awslogs/awscli.conf | |
sudo sed -i "s/^log_group_name[ \t]*=.*/log_group_name = $LOG_GROUP/" /etc/awslogs/awslogs.conf | |
sudo chkconfig awslogs on | |
sudo service awslogs start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment