Terminating, starting, or stopping an EC2 instance
To add the Terminate, start, or stop an instance in EC2 action to a policy
- In the BMC Helix Intelligent Automation console, click Policies and the click Create Policy.
- In the Policy Information section, enter a unique name and an optional description for the policy.
- Select Manual or Automatic to execute the policy manually or automatically.
- 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"
}
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.
- Click Add Action and perform the following steps by using the action wizard:
- 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. - 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. - Provide the following information:
- Enter a unique action name.
For example, Stop EC2 instance. 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.
- Enter a unique action name.
- Click Done.
The added action appears in the Action Configuration section on the Create Automation Policies page.
- From the Pick an automation tool section, click the connector name.
- In the Estimated Savings section, enter an approximate time (in minutes) and money (in USD) that you may save by automating this action.
- Select Publish Policy and click Save to publish the policy.