Ec2Action Class
Use an EC2 action as an Alarm action.
| Source | aws-cloudwatch-actions/lib/ec2.ts |
|---|---|
| Type last changed |
Example
ts
// Alarm must be configured with an EC2 per-instance metric
declare const alarm: cloudwatch.Alarm;
// Attach a reboot when alarm triggers
alarm.addAlarmAction(
new actions.Ec2Action(actions.Ec2InstanceAction.REBOOT),
);
python
# Alarm must be configured with an EC2 per-instance metric
# alarm: cloudwatch.Alarm
# Attach a reboot when alarm triggers
alarm.add_alarm_action(
actions.Ec2Action(actions.Ec2InstanceAction.REBOOT))
java
// Alarm must be configured with an EC2 per-instance metric
Alarm alarm;
// Attach a reboot when alarm triggers
alarm.addAlarmAction(
new Ec2Action(Ec2InstanceAction.REBOOT));
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Alarm must be configured with an EC2 per-instance metric
Alarm alarm;
// Attach a reboot when alarm triggers
alarm.AddAlarmAction(
new Ec2Action(Ec2InstanceAction.REBOOT));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Alarm must be configured with an EC2 per-instance metric
var alarm Alarm
// Attach a reboot when alarm triggers
alarm.AddAlarmAction(
actions.NewEc2Action(actions.Ec2InstanceAction_REBOOT))
Initializer
ts
new Ec2Action(instanceAction: Ec2InstanceAction)
python
Ec2Action(instance_action: Ec2InstanceAction)
java
new Ec2Action(Ec2InstanceAction instanceAction)
csharp
new Ec2Action(Ec2InstanceAction instanceAction)
go
NewEc2Action(InstanceAction Ec2InstanceAction)
Methods
bind(_scope: Construct, _alarm: IAlarm): AlarmActionConfigdef bind(self, _scope: Construct, _alarm: IAlarm) -> AlarmActionConfigpublic AlarmActionConfig bind(Construct _scope, IAlarm _alarm)public AlarmActionConfig Bind(Construct _scope, IAlarm _alarm)func Bind(_scope Construct, _alarm IAlarm) AlarmActionConfig #Returns an alarm action configuration to use an EC2 action as an alarm action.