awscli 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +8 -8
  2. data/README.rdoc +5 -0
  3. data/Rakefile +44 -0
  4. data/bin/awscli +32 -0
  5. data/features/awscli.feature +8 -0
  6. data/features/step_definitions/awscli_steps.rb +6 -0
  7. data/features/support/env.rb +15 -0
  8. data/lib/awscli.rb +51 -0
  9. data/lib/awscli/as.rb +289 -0
  10. data/lib/awscli/cli.rb +21 -0
  11. data/lib/awscli/cli/as.rb +12 -0
  12. data/lib/awscli/cli/as/activities.rb +28 -0
  13. data/lib/awscli/cli/as/configurations.rb +50 -0
  14. data/lib/awscli/cli/as/groups.rb +97 -0
  15. data/lib/awscli/cli/as/instances.rb +34 -0
  16. data/lib/awscli/cli/as/policies.rb +45 -0
  17. data/lib/awscli/cli/ec2.rb +23 -0
  18. data/lib/awscli/cli/ec2/ami.rb +46 -0
  19. data/lib/awscli/cli/ec2/ebs.rb +85 -0
  20. data/lib/awscli/cli/ec2/eip.rb +56 -0
  21. data/lib/awscli/cli/ec2/instances.rb +216 -0
  22. data/lib/awscli/cli/ec2/keypairs.rb +60 -0
  23. data/lib/awscli/cli/ec2/monitoring.rb +35 -0
  24. data/lib/awscli/cli/ec2/placement.rb +42 -0
  25. data/lib/awscli/cli/ec2/reservedinstmng.rb +45 -0
  26. data/lib/awscli/cli/ec2/secgroups.rb +66 -0
  27. data/lib/awscli/cli/ec2/spot.rb +81 -0
  28. data/lib/awscli/cli/ec2/subnet.rb +43 -0
  29. data/lib/awscli/cli/ec2/tags.rb +45 -0
  30. data/lib/awscli/cli/ec2/vmmng.rb +17 -0
  31. data/lib/awscli/cli/ec2/vpc.rb +42 -0
  32. data/lib/awscli/cli/ec2/vpc/connections.rb +0 -0
  33. data/lib/awscli/cli/ec2/vpc/cust_gateways.rb +0 -0
  34. data/lib/awscli/cli/ec2/vpc/dhcp.rb +51 -0
  35. data/lib/awscli/cli/ec2/vpc/internet_gateways.rb +58 -0
  36. data/lib/awscli/cli/ec2/vpc/net_interfaces.rb +75 -0
  37. data/lib/awscli/cli/ec2/vpc/network_acls.rb +29 -0
  38. data/lib/awscli/cli/ec2/vpc/priv_gatewats.rb +0 -0
  39. data/lib/awscli/cli/ec2/vpc/route_tables.rb +0 -0
  40. data/lib/awscli/cli/s3.rb +12 -0
  41. data/lib/awscli/cli/s3/directories.rb +82 -0
  42. data/lib/awscli/cli/s3/files.rb +77 -0
  43. data/lib/awscli/connection.rb +55 -0
  44. data/lib/awscli/ec2.rb +821 -0
  45. data/lib/awscli/errors.rb +64 -0
  46. data/lib/awscli/helper.rb +8 -0
  47. data/lib/awscli/s3.rb +108 -0
  48. data/lib/awscli/version.rb +3 -0
  49. data/test/default_test.rb +14 -0
  50. data/test/test_helper.rb +9 -0
  51. metadata +59 -4
@@ -0,0 +1,21 @@
1
+ module AwsCli
2
+ #This it the main cli runner class
3
+ #All class_methods should be defined here except for Thor::Groups
4
+ class Cli < ::Thor
5
+
6
+ default_task :help_banner #if no option is passed call help_banner task
7
+ # class_option :config, :banner => "PATH", :type => :string,
8
+ # :desc => 'Configuration file, accepts ENV $AWSCLI_CONFIG_FILE',
9
+ # :default => ENV['AWSCLI_CONFIG_FILE'] || "~/.awscli.yml"
10
+
11
+ desc "help", "help banner"
12
+ def help_banner
13
+ puts <<-HELP.gsub(/^ {8}/, '')
14
+ Amazon Web Services Command Line Interface, Version - #{Awscli::VERSION}
15
+
16
+ HELP
17
+ help #call help
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ module AwsCli
2
+ module CLI
3
+ require 'awscli/cli'
4
+ require 'awscli/connection'
5
+ require 'awscli/as'
6
+ class As < Thor
7
+ class_option :region, :type => :string, :desc => "region to connect to"
8
+
9
+ AwsCli::Cli.register AwsCli::CLI::As, :as, 'as [COMMAND]', 'Auto Scaling Interface'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,28 @@
1
+ module AwsCli
2
+ module CLI
3
+ module AS
4
+ require 'awscli/cli/as'
5
+ class Activities < Thor
6
+
7
+ desc "list", "list activities in auto scaling api as a yaml dump"
8
+ method_option :group_name, :aliases => "-g", :banner => "NAME", :desc => "optionally pass in group name to narrow down results"
9
+ def list
10
+ create_as_object
11
+ @as.list options
12
+ end
13
+
14
+ private
15
+
16
+ def create_as_object
17
+ puts "AS Establishing Connetion..."
18
+ $as_conn = Awscli::Connection.new.request_as
19
+ puts "AS Establishing Connetion... OK"
20
+ @as = Awscli::As::Activities.new($as_conn)
21
+ end
22
+
23
+ AwsCli::CLI::As.register AwsCli::CLI::AS::Activities, :activities, 'activities [COMMAND]', 'Auto Scaling Activities Management'
24
+
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,50 @@
1
+ module AwsCli
2
+ module CLI
3
+ module AS
4
+ require 'awscli/cli/as'
5
+ class Configurations < Thor
6
+
7
+ desc "list", "list launch configurations"
8
+ method_option :table, :aliases => "-t", :type => :boolean, :desc => "simple format listing in a table"
9
+ def list
10
+ create_as_object
11
+ @as.list options
12
+ end
13
+
14
+ desc "create", "create a new launch configuraiton"
15
+ method_option :id, :aliases => "-n", :banner => "NAME", :required => true, :desc => "name of the launch configuraiton to create"
16
+ method_option :image_id, :aliases => "-i", :banner => "ID", :required => true, :desc => "ami id to use for launch configuration"
17
+ method_option :instance_type, :aliases => "-t", :banner => "TYPE", :default => "m1.small", :desc => "instance type to use for launch configuration (e.g. m1.small)"
18
+ method_option :block_device_mappings, :aliases => "-b", :type => :array , :desc => "<devicename>=<blockdeveice>, see help for how to pass values"
19
+ method_option :key_name, :aliases => "-k", :banner => "KEY", :required => true, :desc => "key_pair to use for launch configuration"
20
+ method_option :security_groups, :aliases => "-s", :type => :array, :required => true, :desc => "security group(s) to use for launch configuration"
21
+ method_option :spot_price, :banner => "PRICE", :desc => "if specified will initialize spot intsances"
22
+ method_option :user_data, :banner => "DATA", :desc => "userdata available to the launched instances"
23
+ method_option :instance_monitoring, :type => :boolean, :default => false, :desc => "whether to enable isntance monitoring, defaults to disabled"
24
+ def create
25
+ create_as_object
26
+ @as.create options
27
+ end
28
+
29
+ desc "delete", "delete existing launch configuration"
30
+ method_option :id, :aliases => "-n", :banner => "NAME", :required => true, :desc => "name of the launch configuration to delete"
31
+ def delete
32
+ create_as_object
33
+ @as.delete options[:id]
34
+ end
35
+
36
+ private
37
+
38
+ def create_as_object
39
+ puts "AS Establishing Connetion..."
40
+ $as_conn = Awscli::Connection.new.request_as
41
+ puts "AS Establishing Connetion... OK"
42
+ @as = Awscli::As::Configurations.new($as_conn)
43
+ end
44
+
45
+ AwsCli::CLI::As.register AwsCli::CLI::AS::Configurations, :cfgs, 'cfgs [COMMAND]', 'Auto Scaling Configurations Management'
46
+
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,97 @@
1
+ module AwsCli
2
+ module CLI
3
+ module AS
4
+ require 'awscli/cli/as'
5
+ class Groups < Thor
6
+
7
+ desc "list [OPTIONS]", "list auto scaling groups"
8
+ method_option :table, :aliases => "-t", :type => :boolean, :desc => "simple format listing in a table"
9
+ def list
10
+ create_as_object
11
+ @as.list options
12
+ end
13
+
14
+ desc "create", "create a new auto scaling group"
15
+ method_option :id, :aliases => "-n", :banner => "NAME", :required => true, :desc => "name of the auto scaling group to create"
16
+ method_option :availability_zones, :aliases => "-z", :type => :array, :required => true, :desc => "A list of availability zones for the Auto Scaling group"
17
+ method_option :launch_configuration_name, :aliases => "-c", :required => true, :banner => "CFG_NAME", :desc => "The name of the launch configuration to use with the Auto Scaling group"
18
+ method_option :min_size, :aliases => "-l", :type => :numeric, :required => :true, :desc => "The minimum size of the Auto Scaling group"
19
+ method_option :max_size, :aliases => "-h", :type => :numeric, :required => :true, :desc => "The maximum size of the Auto Scaling group"
20
+ method_option :desired_capacity, :aliases => "-r", :type => :numeric, :desc => "The number of Amazon EC2 instances that should be running in the group"
21
+ method_option :default_cooldown, :aliases => "-t", :type => :numeric, :desc => "The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start"
22
+ method_option :health_check_grace_period, :type => :numeric, :desc => "Length of time in seconds after a new Amazon EC2 instance comes into service that Auto Scaling starts checking its health"
23
+ method_option :health_check_type, :desc => "The service you want the health status from, Amazon EC2 or Elastic Load Balancer. Valid values are 'EC2' or 'ELB'"
24
+ method_option :load_balancer_names, :type => :array, :desc => "A list of LoadBalancers to use"
25
+ method_option :placement_group, :desc => "Physical location of your cluster placement group created in Amazon EC2"
26
+ method_option :tags, :type => :array, :desc => "list of key=value pairs used for tags"
27
+ method_option :termination_policies, :type => :array, :desc => "A standalone termination policy or a list of termination policies used to select the instance to terminate. The policies are executed in the order that they are listed"
28
+ method_option :vpc_zone_identifiers, :type => :array, :desc => "A list of subnet identifiers of Amazon Virtual Private Clouds (Amazon VPCs)"
29
+ def create
30
+ create_as_object
31
+ @as.create options
32
+ end
33
+
34
+ desc "delete", "delete an existing auto scaling group"
35
+ method_option :id, :aliases => "-n", :banner => "NAME", :required => true, :desc => "name of the auto sacling group to delete"
36
+ method_option :force, :aliases => "-f", :type => :boolean, :desc => "force deletes instances of the specified auto scaling group"
37
+ def delete
38
+ create_as_object
39
+ @as.delete options
40
+ end
41
+
42
+ desc "scale", "change the desired capacity of a auto sacling group"
43
+ method_option :id, :aliases => "-n", :banner => "NAME", :required => true, :desc => "name of the auto sacling group to scale"
44
+ method_option :desired_capacity, :aliases => "-c", :type => :numeric, :banner => "SIZE", :required => true, :desc => "Desired capacity of a auto scaling group"
45
+ def scale
46
+ create_as_object
47
+ @as.set_desired_capacity options
48
+ end
49
+
50
+ # desc "update", "update auto scaling group attributes"
51
+ # method_option :id, :aliases => "-n", :banner => "NAME", :required => true, :desc => "name of the auto sacling group to scale"
52
+ # method_option :availability_zones, :aliases => "-z", :type => :array, :desc => "A list of availability zones for the Auto Scaling group"
53
+ # method_option :desired_capacity, :aliases => "-r", :type => :numeric, :desc => "The number of Amazon EC2 instances that should be running in the group"
54
+ # method_option :default_cooldown, :aliases => "-t", :type => :numeric, :desc => "The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start"
55
+ # method_option :health_check_grace_period, :type => :numeric, :desc => "Length of time in seconds after a new Amazon EC2 instance comes into service that Auto Scaling starts checking its health"
56
+ # method_option :health_check_type, :desc => "The service you want the health status from, Amazon EC2 or Elastic Load Balancer. Valid values are 'EC2' or 'ELB'"
57
+ # method_option :launch_configuration_name, :aliases => "-c", :banner => "CFG_NAME", :desc => "The name of the launch configuration to use with the Auto Scaling group"
58
+ # method_option :min_size, :aliases => "-l", :type => :numeric, :desc => "The minimum size of the Auto Scaling group"
59
+ # method_option :max_size, :aliases => "-h", :type => :numeric, :desc => "The maximum size of the Auto Scaling group"
60
+ # method_option :termination_policies, :type => :array, :desc => "A standalone termination policy or a list of termination policies used to select the instance to terminate. The policies are executed in the order that they are listed"
61
+ # method_option :vpc_zone_identifiers, :type => :array, :desc => "A list of subnet identifiers of Amazon Virtual Private Clouds (Amazon VPCs)"
62
+ # def update
63
+ # create_as_object
64
+ # @as.update options
65
+ # end
66
+
67
+ desc "suspend", "Suspends Auto Scaling processes for an Auto Scaling group. To suspend specific process types, specify them by name with the ScalingProcesses parameter. To suspend all process types, omit the ScalingProcesses"
68
+ method_option :id, :aliases => "-n", :banner => "NAME", :required => true, :desc => "name of the auto sacling group to suspend processes"
69
+ method_option :scaling_processes, :aliases => "-p", :type => :array, :desc => "The processes that you want to suspend. To suspend all process types, omit this parameter"
70
+ def suspend
71
+ create_as_object
72
+ @as.suspend_processes options
73
+ end
74
+
75
+ desc "resume", "Resumes Auto Scaling processes for an Auto Scaling group"
76
+ method_option :id, :aliases => "-n", :banner => "NAME", :required => true, :desc => "name of the auto sacling group to resume processes"
77
+ method_option :scaling_processes, :aliases => "-p", :type => :array, :desc => "The processes that you want to resume. To resume all process types, omit this parameter"
78
+ def resume
79
+ create_as_object
80
+ @as.resume_processes options
81
+ end
82
+
83
+
84
+ private
85
+ def create_as_object
86
+ puts "AS Establishing Connetion..."
87
+ $as_conn = Awscli::Connection.new.request_as
88
+ puts "AS Establishing Connetion... OK"
89
+ @as = Awscli::As::Groups.new($as_conn)
90
+ end
91
+
92
+ AwsCli::CLI::As.register AwsCli::CLI::AS::Groups, :groups, 'groups [COMMAND]', 'Auto Scaling Groups Management'
93
+
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,34 @@
1
+ module AwsCli
2
+ module CLI
3
+ module AS
4
+ require 'awscli/cli/as'
5
+ class Instances < Thor
6
+
7
+ desc "list [OPTIONS]", "list instances in auto scaling groups"
8
+ def list
9
+ create_as_object
10
+ @as.list
11
+ end
12
+
13
+ desc "terminate", "termiante a particular instance from auto scaling group"
14
+ method_option :id, :aliases => "-i", :required => true, :desc => "instance id to terminate"
15
+ method_option :should_decrement_desired_capacity, :aliases => "-d", :type => :boolean, :default => false, :desc => " Specifies whether (true) or not (false) terminating this instance should also decrement the size of the AutoScalingGroup."
16
+ def terminate
17
+ create_as_object
18
+ @as.terminate options[:id], options[:should_decrement_desired_capacity]
19
+ end
20
+
21
+ private
22
+ def create_as_object
23
+ puts "AS Establishing Connetion..."
24
+ $as_conn = Awscli::Connection.new.request_as
25
+ puts "AS Establishing Connetion... OK"
26
+ @as = Awscli::As::Instances.new($as_conn)
27
+ end
28
+
29
+ AwsCli::CLI::As.register AwsCli::CLI::AS::Instances, :instances, 'instances [COMMAND]', 'Auto Scaling Instances Management'
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,45 @@
1
+ module AwsCli
2
+ module CLI
3
+ module AS
4
+ require 'awscli/cli/as'
5
+ class Policies < Thor
6
+
7
+ desc "list [OPTIONS]", "list auto scaling policies"
8
+ def list
9
+ create_as_object
10
+ @as.list
11
+ end
12
+
13
+ desc "create", "create a policy for auto scaling group"
14
+ method_option :id, :aliases => "-n", :banner => "NAME", :required => true, :desc => "The name of the policy you want to create"
15
+ method_option :adjustment_type, :aliases => "-a", :required => true, :desc => "Specifies whether the scaling_adjustment is an absolute number or a percentage of the current capacity, Valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity."
16
+ method_option :auto_scaling_group_name, :aliases => "-g", :required => true, :desc => "name of the auto scaling group"
17
+ method_option :scaling_adjustment, :aliases => "-s", :type => :numeric, :required => true, :desc => "The number of instances by which to scale. AdjustmentType determines the interpretation of this number (e.g., as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity, The number of instances by which to scale. AdjustmentType determines the interpretation of this number (e.g., as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity"
18
+ method_option :cooldown, :type => :numeric, :desc => "The amount of time, in seconds, after a scaling activity completes before any further trigger-related scaling activities can start"
19
+ def create
20
+ create_as_object
21
+ @as.create options
22
+ end
23
+
24
+ desc "delete", "Deletes a policy created by put_scaling_policy"
25
+ method_option :id, :aliases => "-n", :banner => "NAME", :required => true, :desc => "The name of the policy you want to delete"
26
+ method_option :auto_scaling_group_name, :banner => "NAME", :aliases => "-g", :required => true, :desc => "name of the auto scaling group"
27
+ def delete
28
+ create_as_object
29
+ @as.destroy options[:id], options[:auto_scaling_group_name]
30
+ end
31
+
32
+ private
33
+ def create_as_object
34
+ puts "AS Establishing Connetion..."
35
+ $as_conn = Awscli::Connection.new.request_as
36
+ puts "AS Establishing Connetion... OK"
37
+ @as = Awscli::As::Policies.new($as_conn)
38
+ end
39
+
40
+ AwsCli::CLI::As.register AwsCli::CLI::AS::Policies, :policies, 'policies [COMMAND]', 'Auto Scaling Policies Management'
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,23 @@
1
+ module AwsCli
2
+ module CLI
3
+ require 'awscli/cli'
4
+ require 'awscli/connection'
5
+ require 'awscli/ec2'
6
+ class Ec2 < Thor
7
+
8
+ class_option :region, :type => :string, :desc => "region to connect to", :default => 'us-west-1'
9
+
10
+ private
11
+
12
+ def create_ec2_object
13
+ puts "ec2 Establishing Connetion..."
14
+ $ec2_conn = Awscli::Connection.new.request_ec2
15
+ puts $ec2_conn
16
+ puts "ec2 Establishing Connetion... OK"
17
+ @ec2 = Awscli::EC2::EC2.new($ec2_conn)
18
+ end
19
+
20
+ AwsCli::Cli.register AwsCli::CLI::Ec2, :ec2, 'ec2 [COMMAND]', 'Elastic Cloud Compute Interface'
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,46 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ require 'awscli/cli/ec2'
5
+ class Ami < Thor
6
+
7
+ desc "list", "List Images"
8
+ method_option :filter, :aliases => "-f", :type => :hash, :desc => "filter the images based on filters"
9
+ method_option :amazon_owned, :aliases => "-a", :type => :boolean, :default => false, :desc => "lists amazon owned images"
10
+ method_option :show_filters, :aliases => "-s", :type => :boolean, :default => false, :desc => "filters available"
11
+ def list
12
+ create_ec2_object
13
+ if options[:amazon_owned]
14
+ @ec2.list_amazon
15
+ elsif options[:show_filters]
16
+ @ec2.show_filters
17
+ else
18
+ @ec2.list options[:filter]
19
+ end
20
+ end
21
+
22
+ desc "create", "Create a bootable EBS volume AMI, from instance specified"
23
+ method_option :instance_id, :aliases => "-i", :type => :string, :required => true, :desc => "Instance used to create image"
24
+ method_option :name, :aliases => "-n", :type => :string, :default => "awscli_image_#{Time.now.to_i}", :desc => "Name to give image"
25
+ method_option :desc, :aliases => "-d", :type => :string, :default => "awscli_image-created_at-#{Time.now.to_i}", :desc => "Description of image"
26
+ method_option :no_reboot, :aliases => "-r", :type => :boolean, :default => false, :desc => "Optional, whether or not to reboot the image when making the snapshot"
27
+ def create
28
+ create_ec2_object
29
+ @ec2.create_image_from_instance options
30
+ end
31
+
32
+ private
33
+
34
+ def create_ec2_object
35
+ puts "ec2 Establishing Connetion..."
36
+ $ec2_conn = Awscli::Connection.new.request_ec2
37
+ puts "ec2 Establishing Connetion... OK"
38
+ @ec2 = Awscli::EC2::Ami.new($ec2_conn)
39
+ end
40
+
41
+ AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Ami, :ami, 'ami [COMMAND]', 'EC2 AMI Management'
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,85 @@
1
+ module AwsCli
2
+ module CLI
3
+ module EC2
4
+ require 'awscli/cli/ec2'
5
+ class Ebs < Thor
6
+
7
+ desc "list", "List ELastic Block Storages"
8
+ method_option :snapshots, :aliases => "-s", :type => :boolean, :default => false, :desc => "list snapshots"
9
+ def list
10
+ create_ec2_object
11
+ @ec2.list options
12
+ end
13
+
14
+ desc "create", "Create a EBS Volume"
15
+ method_option :availability_zone, :aliases => "-z", :required => true, :banner => "ZONE", :type => :string, :desc => "Name of the availability zone to create the voulume in"
16
+ method_option :size, :aliases => "-s", :required => true, :type => :numeric, :desc => "Size of the volume to create (in GB)"
17
+ method_option :snapshot_id, :aliases => "-i", :banner => "ID", :type => :string, :desc => "Snapshot ID from which to create volume from"
18
+ method_option :device, :aliases => "-d", :type => :string, :desc => "how the volume is exposed(in unix '/dev/sdx', in windows 'xvdf')"
19
+ def create
20
+ create_ec2_object
21
+ @ec2.create options
22
+ end
23
+
24
+ desc "attach_volume", "Attach a volume to instance"
25
+ method_option :instance_id, :aliases => "-i", :banner => "ID", :type => :string, :desc => "instance id to attach the volume to"
26
+ method_option :volume_id, :aliases => "-v", :banner => "VID", :type => :string, :desc => "volume id to attach"
27
+ method_option :device, :aliases => "-d", :type => :string, :desc => "how the volume is exposed(in unix '/dev/sdx', in windows 'xvdf')"
28
+ def attach_volume
29
+ create_ec2_object
30
+ @ec2.attach_volume options
31
+ end
32
+
33
+ desc "detach_voulme", "Detach a volume from instance"
34
+ method_option :volume_id, :aliases => "-v", :banner => "VID", :type => :string, :desc => "volume id to attach"
35
+ method_option :force, :aliase => "-f", :type => :boolean, :default => false, :desc => "force detaches the volume"
36
+ def detach_volume
37
+ create_ec2_object
38
+ @ec2.detach_volume options
39
+ end
40
+
41
+ desc "delete", "Delete Volume"
42
+ method_option :volume_id, :aliases => "-v", :banner => "VID", :required => true, :type => :string, :desc => "volume id to delete"
43
+ def delete
44
+ #ask if the user is sure about deleting the volume which leads to data loss or can make a snapshot before deleting it
45
+ create_ec2_object
46
+ @ec2.delete_volume options
47
+ end
48
+
49
+ desc "create_snapshot", "Create a snapshot from volume"
50
+ method_option :volume_id, :aliases => "-v", :banner => "VID", :required => true, :type => :string, :desc => "volume to make a snapshot from"
51
+ def create_snapshot
52
+ create_ec2_object
53
+ @ec2.create_snapshot
54
+ end
55
+
56
+ desc "copy_snapshot", "Copy a snapshot to a different region"
57
+ method_option :source_region, :aliases => "-s", :banner => "REGION", :required => true, :type => :string, :desc => "Region to move it from"
58
+ method_option :snapshot_id, :aliases => "-i", :banner => "ID", :required => true, :type => :string, :desc => "Id of the snapshot"
59
+ def copy_snapshot
60
+ create_ec2_object
61
+ @ec2.copy_snapshot
62
+ end
63
+
64
+ desc "delete_snapshot", "Delete SnapShot"
65
+ method_option :snapshot_id, :aliases => "-i", :banner => "ID", :required => true, :type => :string, :desc => "Snapshot Id to delete"
66
+ def delete_snapshot
67
+ create_ec2_object
68
+ @ec2.delete_snapshot options
69
+ end
70
+
71
+ private
72
+
73
+ def create_ec2_object
74
+ puts "ec2 Establishing Connetion..."
75
+ $ec2_conn = Awscli::Connection.new.request_ec2
76
+ puts "ec2 Establishing Connetion... OK"
77
+ @ec2 = Awscli::EC2::Ebs.new($ec2_conn)
78
+ end
79
+
80
+ AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Ebs, :ebs, 'ebs [COMMAND]', 'EC2 EBS Management'
81
+
82
+ end
83
+ end
84
+ end
85
+ end