lib/aws_ec2/scripts/cloudwatch/configure.sh in aws-ec2-1.4.1 vs lib/aws_ec2/scripts/cloudwatch/configure.sh in aws-ec2-1.4.2

- old
+ new

@@ -8,14 +8,22 @@ echo " $command ec2" exit 1 fi LOG_GROUP_NAME=$1 +if [ "$OS" == "ubuntu" ]; then + CONFIG_FILE=/var/awslogs/etc/awslogs.conf + STATE_FILE=/var/awslogs/state/agent-state +else # amazonlinux2 + CONFIG_FILE=/etc/awslogs/awslogs.conf + STATE_FILE=/var/lib/awslogs/agent-state +fi + # Inject the CloudWatch Logs configuration file contents -cat > /etc/awslogs/awslogs.conf <<- EOF +cat > $CONFIG_FILE <<- EOF [general] -state_file = /var/lib/awslogs/agent-state +state_file = $STATE_FILE [/var/log/dmesg] file = /var/log/dmesg log_group_name = ${LOG_GROUP_NAME} log_stream_name = {instance_id}/var/log/dmesg @@ -68,7 +76,9 @@ log_stream_name = {instance_id}/var/log/auto-terminate.log datetime_format = EOF -region=$(curl 169.254.169.254/latest/meta-data/placement/availability-zone | sed s'/.$//') -sed -i -e "s/region = us-east-1/region = $region/g" /etc/awslogs/awscli.conf +if [ -f /etc/awslogs/awscli.conf ]; then + region=$(curl 169.254.169.254/latest/meta-data/placement/availability-zone | sed s'/.$//') + sed -i -e "s/region = us-east-1/region = $region/g" /etc/awslogs/awscli.conf +fi