Terminating, starting, or stopping an EC2 instance


The Terminate, start, or stop an instance in EC2 action enables you to terminate, start, or stop an Amazon Elastic Compute Cloud (AWS EC2) instance for remediating an event. You specify this action while creating a policy. 

While creating an action, you can use an event stored in the BMC Helix Intelligent Automation database or provide an event in a JSON format. 

To add the Terminate, start, or stop an instance in EC2 action to a policy

  1. In the BMC Helix Intelligent Automation console, click Policies and the click Create Policy.
  2. In the Policy Information section, enter a unique name and an optional description for the policy. 
  3. Select Manual or Automatic to execute the policy manually or automatically.
  4. In the Trigger section, click Browse and to select an event do one of the following steps:
    • From the Select Event Type tab, select an existing event type, and click Done.
    • On the Paste Event JSON tab, enter event in the JSON format, and click Done.

      Sample event for stopping an EC2 intance
      {
      "event_type": "aws_ec2_stop",
      "region_code": "us-west-2",
      "resource_id": "i-02c64c42016f0ad89"
      }
  5. In the Trigger Condition text box, use the expression builder to build the following conditional expression to match the trigger condition to the event:

    Sample trigger condition
    "$ ? ($.event.event_type == \"aws_ec2_stop\")"

    For more information about how to define the conditions, see the Creating-automation-policies.

  6. Click Add Action and perform the following steps by using the action wizard:
    1. From the Pick an automation tool section, click the connector name.
      Only configured connectors are displayed here. The wizard takes you to the next step to select an action. 
    2. Click Select against the Terminate, start, or stop an instance in EC2 action.
      The wizard takes you to the next step to configure an action.
    3. Provide the following information: 
      1. Enter a unique action name.
        For example, Stop EC2 instance.
      2. In Request body, enter the following values:

        Field

        Description

        ID

        Enter one or more instance IDs that you want to stop.

        Zone

        Enter the AWS zone in which you want to start, stop, or terminate this instance.

        Image

        Enter the I(ami) ID to use for the instance.

        State

        Select the state for the instance.

        Region

        Enter the AWS region name where this instance is available.

        Ec2 Url

        Enter the URL to connect to EC2.

        Group ID

        Enter one or more security group IDs to use with the instance.

        Exact Count

        Enter a value, in integer, to indicate the number of instances on which the action should be taken.

        Instance Ids

        Enter one or more instance IDs to be used for this action. Instance IDs are used for the Absent, Running, or Stopped states.

        Instance Profile Name

        Enter the name of the IAM instance profile.

        Instance Initiated Shutdown Behavior

        Select whether AWS should stop or terminate an instance after shutdown. This option is ignored if using instance store.

        Note

        Based on the selected event, the event slots with the values specified in the event appear under the Parameters section on the UI. You can click any of the parameters and its value gets copied. You can paste it while defining the action in the policy. 

    4. Click Done.
      The added action appears in the Action Configuration section on the Create Automation Policies page.
  7. In the Estimated Savings section, enter an approximate time (in minutes) and money (in USD) that you may save by automating this action.
  8. Select Publish Policy and click Save to publish the policy.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*