dcy2003 / cloudformation-cloudwatch-example

CloudFormation example to demonstrate automating the process of sending logs and system metrics to CloudWatch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example: CloudFormation + CloudWatch Logs + CloudWatch Custom metrics

Spins up an EC2 instance via CloudFormation and demonstrates how to do the following during the bootstrap process:

  • Configure Python daemon that automatically pushes various log files to CloudWatch
  • Configure cron script to push custom metrics (memory, swap, etc.) to CloudWatch

Prerequisites:

  • AWS account
  • AWS CLI
  • IAM user with sufficient privileges + access key
  • Run aws configure to set the desired region, access key, secret access key
  • An existing VPC, public subnet, key pair, and security group that allows SSH access in the desired AWS region

To Run:

  • Edit create-stack.sh as necessary:
  • KeyName the name of the key pair in the desired AWS region
  • ExistingSecurityGroupId is the ID of an existing security group (e.g. sg-xxxxxxxx)
  • See cloudformation.template for complete list of parameters
  • Run ./create-stack.sh to provison and configure all resources.

Cleanup:

  • When finished, run ./delete-stack.sh to tear down all resources.

Notes:

  • The current region-to-AMI-mapping defined in cloudformation.template only specifies an AMI for us-west-2 (Oregon region)
  • The default AMI is CentOS7
  • It should be trivial to modify this mapping to add support for additional regions if necessary

Helpful Links / References:

About

CloudFormation example to demonstrate automating the process of sending logs and system metrics to CloudWatch


Languages

Language:Shell 100.0%