awscli 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +8 -8
  2. metadata +5 -53
  3. data/README.rdoc +0 -5
  4. data/Rakefile +0 -44
  5. data/bin/awscli +0 -32
  6. data/features/awscli.feature +0 -8
  7. data/features/step_definitions/awscli_steps.rb +0 -6
  8. data/features/support/env.rb +0 -15
  9. data/lib/awscli.rb +0 -44
  10. data/lib/awscli/cli.rb +0 -21
  11. data/lib/awscli/cli/ec2.rb +0 -23
  12. data/lib/awscli/cli/ec2/ami.rb +0 -46
  13. data/lib/awscli/cli/ec2/ebs.rb +0 -85
  14. data/lib/awscli/cli/ec2/eip.rb +0 -56
  15. data/lib/awscli/cli/ec2/instances.rb +0 -195
  16. data/lib/awscli/cli/ec2/keypairs.rb +0 -60
  17. data/lib/awscli/cli/ec2/monitoring.rb +0 -35
  18. data/lib/awscli/cli/ec2/placement.rb +0 -42
  19. data/lib/awscli/cli/ec2/reservedinstmng.rb +0 -45
  20. data/lib/awscli/cli/ec2/secgroups.rb +0 -66
  21. data/lib/awscli/cli/ec2/spot.rb +0 -81
  22. data/lib/awscli/cli/ec2/subnet.rb +0 -43
  23. data/lib/awscli/cli/ec2/tags.rb +0 -45
  24. data/lib/awscli/cli/ec2/vmmng.rb +0 -17
  25. data/lib/awscli/cli/ec2/vpc.rb +0 -42
  26. data/lib/awscli/cli/ec2/vpc/connections.rb +0 -0
  27. data/lib/awscli/cli/ec2/vpc/cust_gateways.rb +0 -0
  28. data/lib/awscli/cli/ec2/vpc/dhcp.rb +0 -51
  29. data/lib/awscli/cli/ec2/vpc/internet_gateways.rb +0 -58
  30. data/lib/awscli/cli/ec2/vpc/net_interfaces.rb +0 -75
  31. data/lib/awscli/cli/ec2/vpc/network_acls.rb +0 -29
  32. data/lib/awscli/cli/ec2/vpc/priv_gatewats.rb +0 -0
  33. data/lib/awscli/cli/ec2/vpc/route_tables.rb +0 -0
  34. data/lib/awscli/cli/s3.rb +0 -12
  35. data/lib/awscli/cli/s3/directories.rb +0 -82
  36. data/lib/awscli/cli/s3/files.rb +0 -77
  37. data/lib/awscli/connection.rb +0 -55
  38. data/lib/awscli/ec2.rb +0 -790
  39. data/lib/awscli/errors.rb +0 -64
  40. data/lib/awscli/helper.rb +0 -8
  41. data/lib/awscli/s3.rb +0 -108
  42. data/lib/awscli/version.rb +0 -3
  43. data/test/default_test.rb +0 -14
  44. data/test/test_helper.rb +0 -9
@@ -1,56 +0,0 @@
1
- module AwsCli
2
- module CLI
3
- module EC2
4
- require 'awscli/cli/ec2'
5
- class Eip < Thor
6
-
7
- desc "list", "List Elastic IPs"
8
- def list
9
- puts "Listing EIPs"
10
- create_ec2_object
11
- @ec2.list
12
- end
13
-
14
- desc "create", "Create Elastic IP"
15
- def create
16
- create_ec2_object
17
- @ec2.create
18
- end
19
-
20
- desc "delete", "Delete Elastic IP"
21
- method_option :eip, :aliases => "-e", :required => true, :banner => "IP", :type => :string, :desc => "Elastic IP to delete"
22
- def delete
23
- create_ec2_object
24
- @ec2.delete options
25
- end
26
-
27
- desc "associate", "Associate EIP with an Instance"
28
- method_option :eip, :aliases => "-e", :required => true, :banner => "IP", :type => :string, :desc => "Elastic IP to associate"
29
- method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :type => :string, :desc => "Instance ID to which to associate EIP"
30
- def associate
31
- create_ec2_object
32
- @ec2.associate options
33
- end
34
-
35
- desc "disassociate", "Disassociate EIP from an instance"
36
- method_option :eip, :aliases => "-e", :required => true, :banner => "IP", :type => :string, :desc => "Elastic IP to disassociate"
37
- def disassociate
38
- create_ec2_object
39
- @ec2.disassociate options
40
- end
41
-
42
- private
43
-
44
- def create_ec2_object
45
- puts "ec2 Establishing Connetion..."
46
- $ec2_conn = Awscli::Connection.new.request_ec2
47
- puts "ec2 Establishing Connetion... OK"
48
- @ec2 = Awscli::EC2::Eip.new($ec2_conn)
49
- end
50
-
51
- AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Eip, :eip, 'eip [COMMAND]', 'EC2 EIP Management'
52
-
53
- end
54
- end
55
- end
56
- end
@@ -1,195 +0,0 @@
1
- module AwsCli
2
- module CLI
3
- module EC2
4
- require 'awscli/cli/ec2'
5
- class Instances < Thor
6
-
7
- # default_task :list
8
-
9
- desc "list", "ec2_describe_instances"
10
- long_desc <<-LONGDESC
11
- List and describe your instances
12
- The INSTANCE parameter is the instance ID(s) to describe.
13
- If unspecified all your instances will be returned.
14
- LONGDESC
15
- def list
16
- puts "Listing Instances"
17
- create_ec2_object
18
- # puts parent_options #access awscli/cli/ec2.rb class options
19
- @ec2.list_instances
20
- end
21
-
22
- desc "diatt", "ec2_describe_instance_attribute"
23
- long_desc <<-LONGDESC
24
- Describes the specified attribute of the specified instance. You can specify only one attribute at a time.
25
- \x5
26
- Available Attributes to Request:
27
- architecture ami_launch_index availability_zone block_device_mapping network_interfaces client_token
28
- dns_name ebs_optimized groups flavor_id iam_instance_profile image_id instance_initiated_shutdown_behavior
29
- kernel_id key_name created_at monitoring placement_group platform private_dns_name private_ip_address
30
- public_ip_address ramdisk_id root_device_name root_device_type security_group_ids state state_reason subnet_id
31
- tenancy tags user_data vpc_id volumes username
32
- LONGDESC
33
- method_option :id, :aliases => "-i", :banner => "INSTANCEID", :type => :string, :desc => "Id of an instance to modify attribute", :required => true
34
- method_option :attr, :aliases => "-a", :banner => "ATTR", :type => :string, :desc => "Attribute to modify", :required => true
35
- def diatt
36
- create_ec2_object
37
- @ec2.describe_instance_attribute(options[:id], options[:attr])
38
- end
39
-
40
-
41
- desc "miatt", "ec2_modify_instance_attribute"
42
- long_desc <<-LONGDESC
43
- Modifies an instance attribute. Only one attribute can be specified per call.
44
- LONGDESC
45
- method_option :id, :aliases => "-i", :banner => "INSTANCEID", :type => :string, :desc => "Id of an instance to modify attribute", :required => true
46
- method_option :isize, :aliases => "-t", :banner => "VALUE", :type => :string, :desc => "Changes the instance type to the specified value."
47
- method_option :kernel, :aliases => "-k", :banner => "VALUE", :type => :string, :desc => "Changes the instance's kernel to the specified value"
48
- method_option :ramdisk, :aliases => "-r", :banner => "VALUE", :type => :string, :desc => "Changes the instance's RAM disk to the specified value"
49
- method_option :userdata, :aliases => "-u", :banner => "VALUE", :type => :string, :desc => "Changes the instance's user data to the specified value"
50
- method_option :disable_api_term, :aliases => "-d", :banner => "true|false" , :type => :string, :desc => "Changes the instance's DisableApiTermination flag to the specified value. Setting this flag means you can't terminate the instance using the API"
51
- method_option :inst_shutdown_beh, :aliases => "-s", :banner => "stop|terminate", :type => :string, :desc => "Changes the instance's InstanceInitiatedShutdownBehavior flag to the specified value."
52
- method_option :source_dest_check, :aliases => "-c", :banner => "true|false" , :type => :string, :desc => "This attribute exists to enable a Network Address Translation (NAT) instance in a VPC to perform NAT. The attribute controls whether source/destination checking is enabled on the instance. A value of true means checking is enabled, and false means checking is disabled"
53
- method_option :group_id, :aliases => "-g", :banner => "G1, G2, ..", :type => :array, :desc => "This attribute is applicable only to instances running in a VPC. Use this parameter when you want to change the security groups that an instance is in."
54
- def miatt
55
- create_ec2_object
56
- opts = Marshal.load(Marshal.dump(options)) #create a copy of options, as original options hash cannot be modified
57
- opts.reject!{ |k| k == 'id' } #remove id from opts
58
- abort "Please pass an attribute by setting respective option" unless opts
59
- abort "You can only pass one attribute at a time" if opts.size != 1
60
- opts.each do |k,v|
61
- puts "calling modify_instance_attribute with: #{options[:id]}, #{k}, #{opts[k]}"
62
- @ec2.modify_instance_attribute(options[:id], k, opts[k])
63
- end
64
-
65
- end
66
-
67
- desc "riatt", "ec2_reset_instance_attribute"
68
- long_desc <<-LONGDESC
69
- Resets an instance attribute to its initial value. Only one attribute can be specified per call.
70
- LONGDESC
71
- def riatt
72
- puts "Not yet Implemented"
73
- end
74
-
75
- desc "dins", "ec2_describe_instance_status"
76
- long_desc <<-LONGDESC
77
- Describe the status for one or more instances.
78
- Checks are performed on your instances to determine if they are
79
- in running order or not. Use this command to see the result of these
80
- instance checks so that you can take remedial action if possible.
81
-
82
- There are two types of checks performed: INSTANCE and SYSTEM.
83
- INSTANCE checks examine the health and reachability of the
84
- application environment. SYSTEM checks examine the health of
85
- the infrastructure surrounding your instance.
86
- LONGDESC
87
- method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id that needs to be stopped"
88
- def dins
89
- create_ec2_object
90
- @ec2.describe_instance_status options[:instance_id]
91
- end
92
-
93
- desc "import", "ec2_import_instance"
94
- long_desc <<-LONGDESC
95
- Create an import instance task to import a virtual machine into EC2
96
- using meta_data from the given disk image. The volume size for the
97
- imported disk_image will be calculated automatically, unless specified.
98
- LONGDESC
99
- def import
100
- puts "Cannot find it in the *FOG*"
101
- end
102
-
103
- desc "reboot", "ec2_reboot_instances"
104
- long_desc <<-LONGDESC
105
- Reboot selected running instances.
106
- The INSTANCE parameter is an instance ID to reboot.
107
- LONGDESC
108
- method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id that needs to be stopped"
109
- def reboot
110
- create_ec2_object
111
- @ec2.reboot_instance options[:instance_id]
112
- end
113
-
114
- desc "create", "ec2_run_instances"
115
- long_desc <<-LONGDESC
116
- Launch an instance of a specified AMI.\x5
117
- Usage Examples:\x5
118
- awscli ec2 instances create -i 'ami-xxxxxxx' -b '{:DeviceName => '/dev/sdg', :VirtualName => 'ephemeral0'}' -g 'default' -t 'm1.small' -k 'default' --tags=name:testserver
119
- LONGDESC
120
- method_option :image_id, :aliases => "-i", :required => true, :banner => "AMIID", :type => :string, :desc => "Id of machine image to load on instances"
121
- method_option :availability_zone, :banner => "ZONE", :type => :string, :desc => "Placement constraint for instances"
122
- method_option :placement_group, :banner => "GROUP", :type => :string, :desc => "Name of existing placement group to launch instance into"
123
- method_option :tenancy, :banner => "TENANCY", :type => :string, :desc => "Tenancy option in ['dedicated', 'default'], defaults to 'default'"
124
- method_option :block_device_mapping, :aliases => "-b", :type => :array , :desc => "hashes of device mappings, see help for how to pass values"
125
- method_option :client_token, :type => :string, :desc => "unique case-sensitive token for ensuring idempotency"
126
- method_option :groups, :aliases => "-g", :banner => "SG1 SG2 SG3",:type => :array, :default => ["default"], :desc => "Name of security group(s) for instances (not supported for VPC). Default: 'default'"
127
- method_option :flavor_id, :aliases => "-t",:type => :string, :default => "m1.small", :desc => "Type of instance to boot."
128
- method_option :kernel_id, :type => :string, :desc => "Id of kernel with which to launch"
129
- method_option :key_name, :aliases => "-k", :required => true, :type => :string, :desc => "Name of a keypair to add to booting instances"
130
- method_option :monitoring, :type => :boolean, :default => false, :desc => "Enables monitoring, defaults to false"
131
- method_option :ramdisk_id, :type => :string, :desc => "Id of ramdisk with which to launch"
132
- method_option :subnet_id, :type => :string, :desc => "VPC option to specify subnet to launch instance into"
133
- method_option :user_data, :type => :string, :desc => "Additional data to provide to booting instances"
134
- method_option :ebs_optimized, :type => :boolean, :default => false, :desc => "Whether the instance is optimized for EBS I/O"
135
- method_option :vpc_id, :type => :string, :desc => "VPC to connect to"
136
- method_option :tags, :type => :hash, :default => {'Name' => "awscli-#{Time.now.to_i}"}, :desc => "Tags to identify server"
137
- method_option :private_ip_address, :banner => "IP",:type => :string, :desc => "VPC option to specify ip address within subnet"
138
- method_option :wait_for, :aliases => "-w", :type => :boolean, :default => false, :desc => "wait for the server to get created and return public_dns"
139
- def create
140
- create_ec2_object
141
- @ec2.create_instance options
142
- end
143
-
144
- desc "start", "ec2_start_instances"
145
- long_desc <<-LONGDESC
146
- Start selected running instances.
147
- LONGDESC
148
- method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id that needs to be stopped"
149
- def start
150
- create_ec2_object
151
- @ec2.start_instance options[:instance_id]
152
- end
153
-
154
- desc "stop", "ec2_stop_instances"
155
- long_desc <<-LONGDESC
156
- Stop selected running instances.
157
- LONGDESC
158
- method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id that needs to be stopped"
159
- def stop
160
- create_ec2_object
161
- @ec2.stop_instance options[:instance_id]
162
- end
163
-
164
- desc "kill", "ec2_terminate_instances"
165
- long_desc <<-LONGDESC
166
- Terminate selected running instances
167
- LONGDESC
168
- method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id that needs to be stopped"
169
- def terminate
170
- create_ec2_object
171
- @ec2.terminate_instance options[:instance_id]
172
- end
173
-
174
- desc "console_output", "Retrieve console output for specified instance"
175
- method_option :instance_id, :aliases => "-i", :required => true, :banner => "ID", :desc => "instance id to get console output from"
176
- def console_output
177
- create_ec2_object
178
- @ec2.get_console_output options[:instance_id]
179
- end
180
-
181
- private
182
-
183
- def create_ec2_object
184
- puts "ec2 Establishing Connetion..."
185
- $ec2_conn = Awscli::Connection.new.request_ec2
186
- puts "ec2 Establishing Connetion... OK"
187
- @ec2 = Awscli::EC2::EC2.new($ec2_conn)
188
- end
189
-
190
- AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Instances, :instances, 'instances [COMMAND]', 'EC2 Instance Management'
191
-
192
- end
193
- end
194
- end
195
- end
@@ -1,60 +0,0 @@
1
- module AwsCli
2
- module CLI
3
- module EC2
4
- require 'awscli/cli/ec2'
5
- class KeyPairs < Thor
6
-
7
- desc "list", "List Key Pairs"
8
- def list
9
- puts "Listing Key Pairs"
10
- create_ec2_object
11
- @ec2.list_keypairs
12
- end
13
-
14
- desc "create", "Create Key Pair"
15
- method_option :name, :aliases => "-n", :required => true, :banner => "NAME", :type => :string, :desc => "Name of the key pair to create"
16
- method_option :fingerprint, :type => :string, :desc => "Fingerprint for the key(optional)"
17
- method_option :private_key, :type => :string, :desc => "Private Key for the key(optional)"
18
- def create
19
- create_ec2_object
20
- @ec2.create_keypair options
21
- end
22
-
23
- desc "delete", "Delete Key Pair"
24
- method_option :name, :aliases => "-n", :required => true, :banner => "NAME", :type => :string, :desc => "Name of the key pair to delete"
25
- def delete
26
- create_ec2_object
27
- @ec2.delete_keypair options[:name]
28
- end
29
-
30
- desc "fingerprint", "Describe Key Fingerprint"
31
- method_option :name, :aliases => "-n", :required => true, :banner => "NAME", :type => :string, :desc => "Name of the key pair to delete"
32
- def fingerprint
33
- create_ec2_object
34
- @ec2.fingerprint options[:name]
35
- end
36
-
37
- desc "import", "Imports an Key Pair"
38
- method_option :name, :aliases => "-n", :required => true, :banner => "NAME", :type => :string, :desc => "Name of the key pair to import"
39
- method_option :private_key_path, :aliases => "-p", :banner => "PATH", :type => :string, :desc => "Optionally pass private key path, by default tries to retrieve from user ~/.ssh dir"
40
- method_option :public_key_path, :aliases => "-k", :banner => "PATH", :type => :string, :desc => "Optionally pass public key path, by default tries to retrieve from user ~/.ssh dir"
41
- def import
42
- create_ec2_object
43
- @ec2.import_keypair options
44
- end
45
-
46
- private
47
-
48
- def create_ec2_object
49
- puts "ec2 Establishing Connetion..."
50
- $ec2_conn = Awscli::Connection.new.request_ec2
51
- puts "ec2 Establishing Connetion... OK"
52
- @ec2 = Awscli::EC2::KeyPairs.new($ec2_conn)
53
- end
54
-
55
- AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::KeyPairs, :kp, 'kp [COMMAND]', 'EC2 Key Pair Management'
56
-
57
- end
58
- end
59
- end
60
- end
@@ -1,35 +0,0 @@
1
- module AwsCli
2
- module CLI
3
- module EC2
4
- require 'awscli/cli/ec2'
5
- class MonitoringInstances < Thor
6
-
7
- desc "monitor", "Monitor specified instance(s)"
8
- method_option :instance_ids, :aliases => "-i", :type => :array, :required => true, :desc => "Instances Ids to monitor"
9
- def monitor
10
- create_ec2_object
11
- @ec2.monitor options
12
- end
13
-
14
- desc "unmonitor", "UnMonitor specified instance(s)"
15
- method_option :instance_ids, :aliases => "-i", :type => :array, :required => true, :desc => "Instances Ids to monitor"
16
- def unmonitor
17
- create_ec2_object
18
- @ec2.unmonitor options
19
- end
20
-
21
- private
22
-
23
- def create_ec2_object
24
- puts "ec2 Establishing Connetion..."
25
- $ec2_conn = Awscli::Connection.new.request_ec2
26
- puts "ec2 Establishing Connetion... OK"
27
- @ec2 = Awscli::EC2::Monitoring.new($ec2_conn)
28
- end
29
-
30
- AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::MonitoringInstances, :mont, 'mont [COMMAND]', 'EC2 Instances Monitoring Management'
31
-
32
- end
33
- end
34
- end
35
- end
@@ -1,42 +0,0 @@
1
- module AwsCli
2
- module CLI
3
- module EC2
4
- require 'awscli/cli/ec2'
5
- class Placement < Thor
6
-
7
- desc "list", "List Placement Groups"
8
- def list
9
- create_ec2_object
10
- @ec2.list
11
- end
12
-
13
- desc "create", "Create a new placement group"
14
- method_option :name, :aliases => "-n", :required => true, :type => :string, :desc => "Name of the placement group"
15
- method_option :strategy, :aliases => "-s", :type => :string, :default => "cluster", :desc => "Placement group strategy. Valid options in ['cluster']"
16
- def create
17
- create_ec2_object
18
- @ec2.create options
19
- end
20
-
21
- desc "delete", "Delete a placement group that you own"
22
- method_option :name, :aliases => "-n", :required => true, :type => :string, :desc => "Name of the placement group"
23
- def delete
24
- create_ec2_object
25
- @ec2.delete options
26
- end
27
-
28
- private
29
-
30
- def create_ec2_object
31
- puts "ec2 Establishing Connetion..."
32
- $ec2_conn = Awscli::Connection.new.request_ec2
33
- puts "ec2 Establishing Connetion... OK"
34
- @ec2 = Awscli::EC2::Placement.new($ec2_conn)
35
- end
36
-
37
- AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Placement, :place, 'place [COMMAND]', 'EC2 Placement Management'
38
-
39
- end
40
- end
41
- end
42
- end
@@ -1,45 +0,0 @@
1
- module AwsCli
2
- module CLI
3
- module EC2
4
- require 'awscli/cli/ec2'
5
- class ReservedInstances < Thor
6
-
7
- desc "list", "List ReservedInstances"
8
- #TODO add filters
9
- method_option :filters, :aliases => "-f", :type => :hash, :desc => "List of filters to limit results with"
10
- method_option :offerings, :aliases => "-o", :type => :boolean, :default => false, :desc => "Describe all or specified reserved instances offerings"
11
- method_option :list_filters, :aliases => "-l", :type => :boolean, :default => false, :desc => "List availble filters that you can be used to limit results"
12
- def list
13
- create_ec2_object
14
- if options[:offerings]
15
- @ec2.list_offerings options[:filters]
16
- elsif options[:list_filters]
17
- @ec2.list_filters
18
- else
19
- @ec2.list options[:filters]
20
- end
21
- end
22
-
23
- desc "purchase", "Purchases a Reserved Instance for use with your account"
24
- method_option :reserved_instances_offering_id, :aliases => "-i", :type => :string, :desc => "ID of the Reserved Instance offering you want to purchase"
25
- method_option :instance_count, :aliases => "-c", :type => :numeric, :default => 1, :desc => "The number of Reserved Instances to purchase"
26
- def purchase
27
- create_ec2_object
28
- @ec2.purchase options
29
- end
30
-
31
- private
32
-
33
- def create_ec2_object
34
- puts "ec2 Establishing Connetion..."
35
- $ec2_conn = Awscli::Connection.new.request_ec2
36
- puts "ec2 Establishing Connetion... OK"
37
- @ec2 = Awscli::EC2::ReservedInstances.new($ec2_conn)
38
- end
39
-
40
- AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::ReservedInstances, :resv, 'resv [COMMAND]', 'EC2 ReservedInstances Management'
41
-
42
- end
43
- end
44
- end
45
- end
@@ -1,66 +0,0 @@
1
- module AwsCli
2
- module CLI
3
- module EC2
4
- require 'awscli/cli/ec2'
5
- class SecGroups < Thor
6
-
7
- desc "list", "List Security Groups"
8
- method_option :show_ip_permissions, :aliases => "-p", :type => :boolean, :default => false, :desc => "Enabling this flag will show ip permissions as well"
9
- def list
10
- create_ec2_object
11
- @ec2.list_secgroups options
12
- end
13
-
14
- desc "create", "Create New Security Group"
15
- method_option :name, :aliases => "-n", :required => true, :banner => "NAME", :type => :string, :desc => "Name of the security group to create"
16
- method_option :description, :aliases => "-d", :banner => "DESC", :type => :string, :desc => "Description of the group"
17
- method_option :vpc_id, :aliases => "-v", :banner => "VPCID", :type => :string, :desc => "VPC ID to attach the security group to"
18
- def create
19
- create_ec2_object
20
- @ec2.create_securitygroup options
21
- end
22
-
23
- desc "authorize", "Add a rule to existing Security Group"
24
- method_option :group_id, :aliases => "-g", :required => true, :banner => "SGID", :type => :string, :desc => "ID of the security group to add a rule to"
25
- method_option :protocol_type, :aliases => "-t", :required => true, :required => true, :banner => "TCP|UDP|ICMP", :type => :string, :desc => "Protocol Type to use for the rule"
26
- method_option :start_port, :aliases => "-s", :required => true, :banner => "NUM", :type => :numeric, :desc => "Start of port range (or -1 for ICMP wildcard)"
27
- method_option :end_port, :aliases => "-e", :required => true, :banner => "NUM", :type => :numeric, :desc => "End of port range (or -1 for ICMP wildcard)"
28
- method_option :cidr, :aliases => "-c", :type => :string, :default => "0.0.0.0/0", :desc => "CIDR range"
29
- def authorize
30
- create_ec2_object
31
- @ec2.authorize_securitygroup options
32
- end
33
-
34
- desc "revoke", "Remove a rule from security group"
35
- method_option :group_id, :aliases => "-g", :required => true, :banner => "SGID", :type => :string, :desc => "ID of the security group to add a rule to"
36
- method_option :protocol_type, :aliases => "-t", :required => true, :required => true, :banner => "TCP|UDP|ICMP", :type => :string, :desc => "Protocol Type to use for the rule"
37
- method_option :start_port, :aliases => "-s", :required => true, :banner => "NUM", :type => :numeric, :desc => "Start of port range (or -1 for ICMP wildcard)"
38
- method_option :end_port, :aliases => "-e", :required => true, :banner => "NUM", :type => :numeric, :desc => "End of port range (or -1 for ICMP wildcard)"
39
- method_option :cidr, :aliases => "-c", :type => :string, :default => "0.0.0.0/0", :desc => "CIDR range"
40
- def revoke
41
- create_ec2_object
42
- @ec2.revoke_securitygroup options
43
- end
44
-
45
- desc "delete", "Delete existing security group"
46
- method_option :group_id, :aliases => "-g", :required => true, :banner => "SGID", :type => :string, :desc => "ID of the security group to add a rule to"
47
- def delete
48
- create_ec2_object
49
- @ec2.delete_securitygroup options
50
- end
51
-
52
- private
53
-
54
- def create_ec2_object
55
- puts "ec2 Establishing Connetion..."
56
- $ec2_conn = Awscli::Connection.new.request_ec2
57
- puts "ec2 Establishing Connetion... OK"
58
- @ec2 = Awscli::EC2::SecGroups.new($ec2_conn)
59
- end
60
-
61
- AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::SecGroups, :sg, 'sg [COMMAND]', 'EC2 Security Groups Management'
62
-
63
- end
64
- end
65
- end
66
- end