import boto3 # Create CloudWatch client cloudwatch = boto3.client('cloudwatch') # Create alarm with actions enabled cloudwatch.put_metric_alarm( AlarmName='Web_Server_CPU_Utilization', ComparisonOperator='GreaterThanThreshold', EvaluationPeriods=1, MetricName='CPUUtilization', Namespace='AWS/EC2', Period=60, Statistic='Average', Threshold=70.0, ActionsEnabled=True, AlarmActions=[ 'arn:aws:swf:us-west-2:{CUSTOMER_ACCOUNT}:action/actions/AWS_EC2.InstanceId.Reboot/1.0' ], AlarmDescription='Alarm when server CPU exceeds 70%', Dimensions=[ { 'Name': 'InstanceId', 'Value': 'INSTANCE_ID' }, ], Unit='Seconds' ) 

ncG1vNJzZmian6m8dHrAppizp56WxLR6wqikaK5hZLGwr9SmnKeskam2sLqOmqeiZ5yWwaa%2F02ierqGUmnykw4yer5qloKGybsHSoqWgZZGhrrO50mefraWc