Skip to content
v2.278.0

Ec2InstanceAction ​

Enum Stable

Types of EC2 actions available.

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))

Members ​

MemberDescription
STOPStop the instance.
TERMINATETerminatethe instance.
RECOVERRecover the instance.
REBOOTReboot the instance.