boto3_cloudwatch¶
Connection module for Amazon CloudWatch using boto3.¶
Renamed from
boto_cloudwatchtoboto3_cloudwatchand rewritten to use the boto3cloudwatchclient APIs directly viasaltext.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.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.
- Name (str):
The name of the CloudWatch alarm to retrieve.
- region (str, optional):
The AWS region where the CloudWatch alarm is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
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.
- prefix (str, optional):
A prefix to prepend to alarm names in the output. Alarms that already have this prefix will be skipped.
- region (str, optional):
The AWS region where the CloudWatch alarms are located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
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,InsufficientDataActionsandOKActionsmust be lists of strings. If passed as a string, they will be split on,. Each entry may either be an ARN, or the convenience notationscaling_policy:<as_name>:<scaling_policy_name>referencing an ASG scaling policy.- Name (str):
The name of the CloudWatch alarm to create or update.
- MetricName (str, optional):
The name of the metric associated with the alarm.
- Namespace (str, optional):
The namespace of the metric associated with the alarm.
- Statistic (str, optional):
The statistic to apply to the metric associated with the alarm.
- ComparisonOperator (str, optional):
The arithmetic operation to use when comparing the specified statistic and threshold.
- Threshold (float, optional):
The value against which the specified statistic is compared.
- Period (int, optional):
The period, in seconds, over which the specified statistic is applied.
- EvaluationPeriods (int, optional):
The number of periods over which data is compared to the specified threshold.
- Unit (str, optional):
The unit of the metric associated with the alarm.
- AlarmDescription (str, optional):
The description of the alarm.
- Dimensions (list, optional):
The dimensions for the metric associated with the alarm.
- AlarmActions (list, optional):
The actions to execute when the alarm state is triggered.
- InsufficientDataActions (list, optional):
The actions to execute when the alarm state is insufficient data.
- OKActions (list, optional):
The actions to execute when the alarm state is OK.
- region (str, optional):
The AWS region where the CloudWatch alarm is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
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>.- arns (list):
A list of strings representing ARNs or convenience names to be converted to ARNs.
- region (str, optional):
The AWS region where the ARNs are located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
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.
- Name (str):
The name of the CloudWatch alarm to delete.
- region (str, optional):
The AWS region where the CloudWatch alarm is located.
- key (str, optional):
The AWS secret access key.
- keyid (str, optional):
The AWS access key ID.
- profile (str, optional):
The profile to use for AWS credentials.
CLI Example:
salt myminion boto3_cloudwatch.delete_alarm myalarm region=us-east-1