https://github.com/nexxus-vi/simple_ec2_management
Simple script to manage existing EC2 instances on AWS
https://github.com/nexxus-vi/simple_ec2_management
aws ec2 ruby
Last synced: 4 months ago
JSON representation
Simple script to manage existing EC2 instances on AWS
- Host: GitHub
- URL: https://github.com/nexxus-vi/simple_ec2_management
- Owner: nexxus-vi
- Created: 2022-11-17T16:52:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-31T10:11:31.000Z (about 2 years ago)
- Last Synced: 2025-01-13T00:33:25.347Z (5 months ago)
- Topics: aws, ec2, ruby
- Language: Ruby
- Homepage:
- Size: 17.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**Simple EC2 Management Script**
This is a simple script to manage existing EC2 instances on AWS.
**Requirements**
`Ruby >= 2.3` & `Bundler 2.2.32`
You have to set up your AWS credentials as described in the [official documentation](https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html)
Alternatively you can initialize `@client` with `access_key_id`, `secret_access_key` and `region`:
`@client = Aws::EC2::Client.new(access_key_id: 'ACCESSKEY', secret_access_key: 'SECRET', region: 'eu-north-1')`
**Install gems**
`gem install bundler:2.2.32`
`bundle install`
**Usage**
```
$ ruby ec2.rb -h
Simple EC2 Management.Usage:
ec2 list [--verbose] [-r | -s]
ec2 describe
ec2 (start | stop | reboot | terminate) [--dry-run]
ec2 -h | --help
ec2 --versionOptions:
-h --help Show this screen.
-r, --running Show only running instances.
-s, --stopped Show only stopped instances.
--dry-run Checks whether you have the required permissions for the action, without actually making the request.
--verbose Verbose output
-v, --version Show version.
```***Example usage:***
```
$ ruby ec2.rb list
Instances: 5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#1
Instance ID: i-123456789
Name: instance_name
State: STOPPED - Reason: Client.UserInitiatedShutdown
Private IP address: 0.0.0.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...$ ruby ec2.rb start i-123456789 --dry-run
Attempting to start instance 'i-123456789' (this might take a few minutes)...
Check permissions to perform this operation: Request would have succeeded, but DryRun flag is set.
```