Forge Home


A module to and manage the AWS Cloudwatch log agent.


153,769 latest version

4.6 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.1.1 (latest)
  • 0.1.0
released Dec 9th 2015
This version is compatible with:
  • , , , , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'pcfens-cloudwatch_agent', '0.1.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add pcfens-cloudwatch_agent
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install pcfens-cloudwatch_agent --version 0.1.1

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.



pcfens/cloudwatch_agent — version 0.1.1 Dec 9th 2015


Table of Contents

  1. Module Description - What the module does and why it is useful
  2. Setup - The basics of getting started with cloudwatch_agent
  3. Usage - Configuration options and additional functionality
  4. Reference - An under-the-hood peek at what the module is doing and how
  5. Limitations - OS compatibility, etc.

Module Description

The cloudwatch_agent module installs configures and manages the AWS Cloudwatch Logs Agent.


Setup requirements

Cloudwatch is an AWS service for collecting metrics and log data from AWS Instances. This module is only usable inside of AWS, and not on instances that run outside of AWS.

EC2 instances need to have an IAM role to be able to send logs to AWS. Setting up IAM oles is outside the scope of this document, but there's a nice tutorial that starts in step 2 in the (Cloudwatch Logs Agent docs)[] (step 19 is different if you're using puppet).

Beginning with cloudwatch_agent

If you want to install the logs agent, and are in the us-east-1 region, you can run include ::cloudwatch_agent. By default, the agent is installed using the python installer but it can be overridden (to use a package), though the default install doesn't monitor any logs.

Non us-east-1 regions can be used via the region parameter:

class { 'cloudwatch_agent':
  region => 'us-west-1',


Cloudwatch needs a little bit of information about each log file (like date format) so that it can be parsed out and grouped in a meaningful way by AWS.

After setting up the logs agent, logs can be specified using the cloudwatch_agent::log defined type. Sending /var/log/syslog would look like (all parameters are defaults):

cloudwatch_agent::log { '/var/log/syslog':
  datetime_format  => '%b %d %H:%M:%S',
  log_stream_name  => '{instance_id}',
  buffer_duration  => '5000',
  initial_position => 'start_of_file',



Public Classes

  • cloudwatch_agent: Installs the cloudwatch log agent

Private Classes

  • cloudwatch_agent::config: Sets the awslogs service configuration
  • cloudwatch_agent::package: Install the agent package
  • cloudwatch_agent::service: Manage the awslogs service




Specify whether the awslogs package should be used or not, Valid values are 'true', 'false'. Defaults to 'false'.


The ensure parameter that is passed to the awslogs package resource. Defaults to present.


The URL where the installer should be fetched from. Defaults to


The ensure parameter that is passed to the awslogs service resource. Defaults to running.


The enable parameter that is passed to the awslogs service resource. Defaults to true.


The AWS region that the you're running in. Defaults to 'us-east-1'.


Where the agent should store its state. Defaults to /var/awslogs/state/agent-state


A hash of ::cloudwatch_agent::log resources that should be created.



Full details on what the cloudwatch agent does with these parameters is available in the agent reference (not all parameters are supported by this module yet).


Ensure whether or not the log file should be managed or not. Valid values are present and absent. Defaults to present.


The file that should be managed. This defaults to the resource name.


The format of the datetime stamp in the file. Defaults to '%b %d %H:%M:%S'.


The log group that this file should be grouped with. Defaults to the resource name.


The name of the log stream. Defaults to '{instance_id}'.


How long log files should be buffered before sending, in milliseconds. Defaults to '5000'.


Where the file should be read to start with, when there's no state file to reference. Defaults to 'start_of_file'.


This module is only useful in AWS, on Linux instances.