AWS EC2: Start, Stop, and Terminate Instances
Disclaimer
Your use of this download is governed by Stonebranch's Terms of Use.
Overview
This Universal Task allows users to start, stop, terminate, and manage AWS EC2 instances on demand, simply by providing one or more instance IDs as input.
- This task uses python boto3 to interact with the AWS platform using the credentials supplied within the task.
- It supports multiple EC2 instances at once.
- In Universal Controller, this task goes to the success state until the EC2 instance is completely Started, Stopped, or terminated.
- Scheduling this task using a Universal Controller workflow spins up and tears down EC2 instances based on the business needs, complete with correct set up and dependencies.
- It dynamically manages EC2 operations, offering the potential to reduce EC2 operations costs in the cloud.
Version Information
Template Name | Version |
|---|---|
CS AWS EC2 Start Stop Terminate Instance | 2.0.1 |
Refer to changelog for version history information.
Software Requirements
This integration requires a Universal Agent and a Python runtime to execute the Universal Task against AWS EC2 Instance.
Software Requirements for Universal Template and Universal Task
- Requires Python 3.11 or higher. Tested with the Universal Agent bundled Python distribution.
- Python modules required:
- requests
- Boto3
Software Requirements for Universal Agent
- Universal Agent for Windows x64 Version 7.5.X and later with python options installed.
- Universal Agent for Linux Version 7.5.X and later with python options installed.
Software Requirements for Universal Controller
- Universal Controller Version 7.5.X and later..
Technical Considerations
-
Consider using this Universal Task either with Universal Agent bundled with python (uapy) and the boto3 module within this environment, or a python environment (py) in a host where Universal Agent is installed with the boto3 module in it.
-
AWS credentials must have appropriate IAM permissions for EC2 instance management:
- Required permissions:
ec2:StartInstances,ec2:StopInstances,ec2:TerminateInstances,ec2:DescribeInstanceStatus,ec2:DescribeInstances - For Assume Role: Additionally requires
sts:AssumeRolepermission on the source credentials - Recommended: Use IAM policies that restrict access to specific resources via conditions (e.g., specific instance IDs or tags)
- Required permissions:
AWS Credential Environment Variables (Optional)
AWS_ACCESS_KEY_ID
- AWS IAM Access Key ID
- Used for authentication to AWS services
- Priority: Checked if not provided via task form
AWS_SECRET_ACCESS_KEY
- AWS IAM Secret Access Key
- Used for authentication to AWS services
- Must be provided together with AWS_ACCESS_KEY_ID
- Priority: Checked if not provided via task form
AWS_SESSION_TOKEN (Optional)
- Temporary session token for assumed roles or temporary credentials
- Only needed when using AWS STS temporary credentials
- Priority: Checked if not provided via task form
AWS Region Environment Variables (Optional)
AWS_REGION
- Specifies the AWS region (e.g., us-east-1, eu-west-1)
- Priority: First choice in auto-detection (after explicit task field)
AWS_DEFAULT_REGION
- Fallback for specifying AWS region
- Priority: Second choice in auto-detection (after AWS_REGION)
Key Features
Feature | Description |
|---|---|
Start EC2 Instance | Start one or Multiple EC2 instance. |
Stop EC2 Instance | Stops one or Multiple EC2 instance. |
Terminate EC2 Instance | Terminate one or Multiple EC2 instance. |
EC2 status | Provides one or Multiple EC2 instance status. |
Import Universal Template
To use this downloadable Universal Template, perform the following steps.
- This Universal Task requires the Resolvable Credentials feature. Check that the Resolvable Credentials Permitted system property has been set to true.
- To import the Universal Template into your Controller, follow the instructions here.
- When the files have been imported successfully, refresh the Universal Templates list; the Universal Template will appear on the list.
Configure Universal Task
For the new Universal Task type, create a new task, and enter the task-specific details that were created in the Universal Template.
Field Descriptions
Field | Description |
|---|---|
LOGLEVEL | Log level of the task (set to "Info" by default). |
EC2 Instance Function | Select either Start, Stop, Terminate, or Check EC2 Instance. |
EC2 Region Location | Optional Field for the AWS default Region value. Region will get automatically retrieved if this field is left empty. |
AWS Access Key Credentials | AWS IAM user credentials (Access Key ID, Secret Access Key, optional Session Token). Leave empty to use EC2 instance IAM role or environment variables. |
Instance IDs | Provide the Instance ID that you need to start, stop, or terminate. |
Assume a specific Role | Check this box to assume a role. |
ARN Role | ARN of the role you want to assume. |
Role Session Name | Name applied to the Role ARN Session. |
Task Examples
Start EC2 Instances (Using Credentials from UAC)

Stop EC2 Instances (Using ARN Role)

Get EC2 Instance Status (Using Environment Variables / EC2 Instance Role from AWS)

Document References
This document references the following documents:
Name | Description |
|---|---|
User documentation for creating Universal Templates in the Universal Controller user interface. | |
User documentation for creating Universal Tasks in the Universal Controller user interface. |
Changelog
ut-cs-aws-start-stop-terminate-ec2-instance-2.0.1 (2026-03-12)
Fixes
- Fixed: Fix template name issue causing Job As Code error on Windows
ut-cs-aws-start-stop-terminate-ec2-instance-2.0.0 (2025-12-11)
Enhancements
- Added: Assume Role functionality with "ARN Role" and "Role Session Name" fields for cross-account access
- Added: New "AWS Access Key Credentials" field to replace individual aws_access_key_id/aws_secret_access_key/aws_session_token fields
- Added: Built-in AWS Region Detection mechanism that automatically discovers region from:
- Explicit field input (EC2 Region Location)
- AWS_REGION environment variable
- AWS_DEFAULT_REGION environment variable
- Added: Multi-source credential retrieval mechanism with priority order:
- Explicit credentials via "AWS Access Key Credentials" field
- Implicit credentials from environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN)
- EC2 instance IAM role (when running on EC2 instance)
Fixes
- Fixed: More structured and detailed logging throughout execution
- Fixed: Better error messages for credential and region detection failures
ut-cs-aws-start-stop-terminate-ec2-instance-1.2.0 (2025-10-27)
Enhancements
- Added: inclusion IAM Roles based auth
ut-cs-aws-start-stop-terminate-ec2-instance-1.1.2 (2022-03-25)
Enhancements
- Added: Display the EC2 Instance JSON payload in STDOUT
ut-cs-aws-start-stop-terminate-ec2-instance-1.0.0
Initial Release