Actions for Amazon EC2 using Amazon SDKs
The following code examples demonstrate how to perform individual Amazon EC2 actions with Amazon SDKs. These excerpts call the Amazon EC2 API and are code excerpts from larger programs that must be run in context. Each example includes a link to GitHub, where you can find instructions for setting up and running the code.
The following examples include only the most commonly used actions. For a complete list, see the Amazon Elastic Compute Cloud (Amazon EC2) API Reference.
Examples
- Add tags to resources
- Allocate an Elastic IP address
- Associate an Elastic IP address with an instance
- Create a Amazon Virtual Private Cloud (Amazon VPC)
- Create a launch template
- Create a route table
- Create a security group
- Create a security key pair
- Create a subnet
- Create and run an instance
- Delete a launch template
- Delete a security group
- Delete a security key pair
- Delete a snapshot
- Describe Availability Zones
- Describe Regions
- Describe instance status
- Describe instances
- Describe snapshots
- Disable detailed monitoring
- Disassociate an Elastic IP address from an instance
- Enable monitoring
- Get data about Amazon Machine Images
- Get data about a security group
- Get data about instance types
- Get data about the instance profile associated with an instance
- Get details about Elastic IP addresses
- Get the default VPC
- Get the default subnets for a VPC
- List security key pairs
- Reboot an instance
- Release an Elastic IP address
- Replace the instance profile associated with an instance
- Set inbound rules for a security group
- Start an instance
- Stop an instance
- Terminate an instance