How to use enable_alarm_actions method in localstack

Best Python code snippet using localstack_python

enable_alarm_actions.py

Source:enable_alarm_actions.py Github

copy

Full Screen

1# Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License"). You4# may not use this file except in compliance with the License. A copy of5# the License is located at6#7# http://aws.amazon.com/apache2.0/8#9# or in the "license" file accompanying this file. This file is10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF11# ANY KIND, either express or implied. See the License for the specific12# language governing permissions and limitations under the License. 13# snippet-start:[cloudwatch.python.enable_alarm_actions.complete]1415import boto3161718# Create CloudWatch client19cloudwatch = boto3.client('cloudwatch')2021# Create alarm with actions enabled22cloudwatch.put_metric_alarm(23 AlarmName='Web_Server_CPU_Utilization',24 ComparisonOperator='GreaterThanThreshold',25 EvaluationPeriods=1,26 MetricName='CPUUtilization',27 Namespace='AWS/EC2',28 Period=60,29 Statistic='Average',30 Threshold=70.0,31 ActionsEnabled=True,32 AlarmActions=[33 'arn:aws:swf:us-west-2:{CUSTOMER_ACCOUNT}:action/actions/AWS_EC2.InstanceId.Reboot/1.0'34 ],35 AlarmDescription='Alarm when server CPU exceeds 70%',36 Dimensions=[37 {38 'Name': 'InstanceId',39 'Value': 'INSTANCE_ID'40 },41 ],42 Unit='Seconds'43)44 45 46# snippet-end:[cloudwatch.python.enable_alarm_actions.complete]47# snippet-comment:[These are tags for the AWS doc team's sample catalog. Do not remove.]48# snippet-sourcedescription:[enable_alarm_actions.py demonstrates how to enable actions for specified alarms.]49# snippet-keyword:[Python]50# snippet-sourcesyntax:[python]51# snippet-sourcesyntax:[python]52# snippet-keyword:[AWS SDK for Python (Boto3)]53# snippet-keyword:[Code Sample]54# snippet-keyword:[Amazon Cloudwatch]55# snippet-service:[cloudwatch]56# snippet-sourcetype:[full-example]57# snippet-sourcedate:[2018-12-26]58# snippet-sourceauthor:[jschwarzwalder (AWS)] ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful