boto3_cloudwatch

Connection module for Amazon CloudWatch using boto3.

Renamed from boto_cloudwatch to boto3_cloudwatch and rewritten to use the boto3 cloudwatch client APIs directly via saltext.boto3.utils.boto3mod. The legacy boto2 code path (object-style access, retry loops) has been removed.

depends:
  • boto3 >= 1.28.0

  • botocore >= 1.31.0

configuration:

This module accepts explicit CloudWatch credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More Information available at:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html

If IAM roles are not used you need to specify them either in the minion’s config file or as a profile. For example, to specify them in the minion’s config file:

cloudwatch.keyid: GKTADJGHEIQSXMKKRBJ08H
cloudwatch.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

A region may also be specified in the configuration:

cloudwatch.region: us-east-1

It’s also possible to specify key, keyid and region via a profile, either as a passed in dict, or as a string to pull from pillars or minion config:

myprofile:
    keyid: GKTADJGHEIQSXMKKRBJ08H
    key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
    region: us-east-1

Added in version 1.0.0.

saltext.boto3.modules.boto3_cloudwatch.__virtual__()[source]

Only load if boto3 is available.

saltext.boto3.modules.boto3_cloudwatch.get_alarm(Name, region=None, key=None, keyid=None, profile=None)[source]

Get alarm details. Also can be used to check to see if an alarm exists.

CLI Example:

salt myminion boto3_cloudwatch.get_alarm myalarm region=us-east-1
saltext.boto3.modules.boto3_cloudwatch.get_all_alarms(prefix=None, region=None, key=None, keyid=None, profile=None)[source]

Get all alarm details. Produces results that can be used to create an sls file.

If prefix parameter is given, alarm names in the output will be prepended with the prefix; alarms that have the prefix will be skipped.

CLI Example:

salt myminion boto3_cloudwatch.get_all_alarms region=us-east-1 --out=txt
saltext.boto3.modules.boto3_cloudwatch.create_or_update_alarm(Name, MetricName=None, Namespace=None, Statistic=None, ComparisonOperator=None, Threshold=None, Period=None, EvaluationPeriods=None, Unit=None, AlarmDescription='', Dimensions=None, AlarmActions=None, InsufficientDataActions=None, OKActions=None, region=None, key=None, keyid=None, profile=None)[source]

Create or update a cloudwatch alarm.

Dimensions must be a list of {"Name": ..., "Value": ...} dicts. If the value of Dimensions is a string, it will be json decoded first. Legacy {Name: [Value]} or {Name: Value} dicts are also accepted and converted.

AlarmActions, InsufficientDataActions and OKActions must be lists of strings. If passed as a string, they will be split on ,. Each entry may either be an ARN, or the convenience notation scaling_policy:<as_name>:<scaling_policy_name> referencing an ASG scaling policy.

CLI Example:

salt myminion boto3_cloudwatch.create_or_update_alarm Name=myalarm ...
saltext.boto3.modules.boto3_cloudwatch.convert_to_arn(arns, region=None, key=None, keyid=None, profile=None)[source]

Convert a list of strings into actual arns. Converts convenience names such as scaling_policy:<as_name>:<scaling_policy_name>.

CLI Example:

salt '*' boto3_cloudwatch.convert_to_arn 'scaling_policy:my-asg:ScaleDown'
saltext.boto3.modules.boto3_cloudwatch.delete_alarm(Name, region=None, key=None, keyid=None, profile=None)[source]

Delete a cloudwatch alarm.

CLI Example:

salt myminion boto3_cloudwatch.delete_alarm myalarm region=us-east-1