# Ec2InstanceAction

Enum · Stable

Types of EC2 actions available.

Used as argument in: [Ec2Action (initializer)](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch_actions.Ec2Action.html#initializer)

- Source: [`aws-cloudwatch-actions/lib/ec2.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudwatch-actions/lib/ec2.ts#L8)

## Example

TypeScript:

```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:

```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:

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

C#:

```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:

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

| Member | Description |
| --- | --- |
| `STOP` | Stop the instance. |
| `TERMINATE` | Terminatethe instance. |
| `RECOVER` | Recover the instance. |
| `REBOOT` | Reboot the instance. |
