awscli 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.rdoc +5 -0
- data/Rakefile +44 -0
- data/bin/awscli +32 -0
- data/features/awscli.feature +8 -0
- data/features/step_definitions/awscli_steps.rb +6 -0
- data/features/support/env.rb +15 -0
- data/lib/awscli.rb +44 -0
- data/lib/awscli/cli.rb +21 -0
- data/lib/awscli/cli/ec2.rb +23 -0
- data/lib/awscli/cli/ec2/ami.rb +46 -0
- data/lib/awscli/cli/ec2/ebs.rb +85 -0
- data/lib/awscli/cli/ec2/eip.rb +56 -0
- data/lib/awscli/cli/ec2/instances.rb +195 -0
- data/lib/awscli/cli/ec2/keypairs.rb +60 -0
- data/lib/awscli/cli/ec2/monitoring.rb +35 -0
- data/lib/awscli/cli/ec2/placement.rb +42 -0
- data/lib/awscli/cli/ec2/reservedinstmng.rb +45 -0
- data/lib/awscli/cli/ec2/secgroups.rb +66 -0
- data/lib/awscli/cli/ec2/spot.rb +81 -0
- data/lib/awscli/cli/ec2/subnet.rb +43 -0
- data/lib/awscli/cli/ec2/tags.rb +45 -0
- data/lib/awscli/cli/ec2/vmmng.rb +17 -0
- data/lib/awscli/cli/ec2/vpc.rb +42 -0
- data/lib/awscli/cli/ec2/vpc/connections.rb +0 -0
- data/lib/awscli/cli/ec2/vpc/cust_gateways.rb +0 -0
- data/lib/awscli/cli/ec2/vpc/dhcp.rb +51 -0
- data/lib/awscli/cli/ec2/vpc/internet_gateways.rb +58 -0
- data/lib/awscli/cli/ec2/vpc/net_interfaces.rb +75 -0
- data/lib/awscli/cli/ec2/vpc/network_acls.rb +29 -0
- data/lib/awscli/cli/ec2/vpc/priv_gatewats.rb +0 -0
- data/lib/awscli/cli/ec2/vpc/route_tables.rb +0 -0
- data/lib/awscli/cli/s3.rb +12 -0
- data/lib/awscli/cli/s3/directories.rb +82 -0
- data/lib/awscli/cli/s3/files.rb +77 -0
- data/lib/awscli/connection.rb +55 -0
- data/lib/awscli/ec2.rb +790 -0
- data/lib/awscli/errors.rb +64 -0
- data/lib/awscli/helper.rb +8 -0
- data/lib/awscli/s3.rb +108 -0
- data/lib/awscli/version.rb +3 -0
- data/test/default_test.rb +14 -0
- data/test/test_helper.rb +9 -0
- metadata +182 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
require 'awscli/cli/ec2'
|
5
|
+
class Vpc < Thor
|
6
|
+
|
7
|
+
desc "list", "List VPCs"
|
8
|
+
def list
|
9
|
+
create_ec2_object
|
10
|
+
@ec2.list
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "create", "Create a VPC with the CIDR block you specify"
|
14
|
+
method_option :cidr_block, :aliases => "-c", :type => :string, :required => true, :desc => "The CIDR block you want the VPC to cover (e.g., 10.0.0.0/16), You can't change the size of a VPC after you create it"
|
15
|
+
method_option :tenancy, :type => :string, :default => "default", :desc => "The allowed tenancy of instances launched into the VPC. A value of default means instances can be launched with any tenancy; a value of dedicated means instances must be launched with tenancy as dedicated"
|
16
|
+
def create
|
17
|
+
create_ec2_object
|
18
|
+
@ec2.create options
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "delete", "Deletes a VPC. You must detach or delete all gateways or other objects that are dependent on the VPC first"
|
22
|
+
method_option :vpc_id, :aliases => "-v", :type => :string, :required => true, :desc => "The ID of the VPC you want to delete"
|
23
|
+
def delete
|
24
|
+
create_ec2_object
|
25
|
+
@ec2.delete options[:vpc_id]
|
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::Vpc.new($ec2_conn)
|
35
|
+
end
|
36
|
+
|
37
|
+
AwsCli::CLI::Ec2.register AwsCli::CLI::EC2::Vpc, :vpc, 'vpc [COMMAND]', 'EC2 VPC Management'
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
module VPC
|
5
|
+
require 'awscli/cli/ec2/vpc'
|
6
|
+
class Dhcp < Thor
|
7
|
+
|
8
|
+
desc "list", "List Dhcp Options"
|
9
|
+
def list
|
10
|
+
create_ec2_object
|
11
|
+
@ec2.list
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "create", "Creates a set of DHCP options for your VPC"
|
15
|
+
method_option :dhcp_configuration_options, :aliases => "-o", :type => :hash, :required => true, :desc => "hash of key value dhcp options(domain-name, domain-name-servers, ntp-servers, netbios-name-servers, netbios-node-type) to assign"
|
16
|
+
def create
|
17
|
+
create_ec2_object
|
18
|
+
@ec2.create options[:dhcp_configuration_options]
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "delete", "Deletes a set of DHCP options that you specify"
|
22
|
+
method_option :dhcp_options_id, :aliases => "-d", :type => :string, :required => true, :desc => "The ID of the DHCP options set you want to delete"
|
23
|
+
def delete
|
24
|
+
create_ec2_object
|
25
|
+
@ec2.delete options[:dhcp_options_id]
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "associate", "Associates a set of DHCP options (that you've previously created) with the specified VPC. Or, associates no DHCP options with the VPC"
|
29
|
+
method_option :dhcp_options_id, :aliases => "-d", :type => :string, :required => true, :desc => "The ID of the DHCP options you want to associate with the VPC"
|
30
|
+
method_option :vpc_id, :aliases => "-v", :type => :string, :required => true, :desc => "The ID of the VPC you want to associate the DHCP options with"
|
31
|
+
def associate
|
32
|
+
create_ec2_object
|
33
|
+
@ec2.associate options[:dhcp_options_id], options[:vpc_id]
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def create_ec2_object
|
39
|
+
puts "ec2 Establishing Connetion..."
|
40
|
+
$ec2_conn = Awscli::Connection.new.request_ec2
|
41
|
+
puts "ec2 Establishing Connetion... OK"
|
42
|
+
@ec2 = Awscli::EC2::Dhcp.new($ec2_conn)
|
43
|
+
end
|
44
|
+
|
45
|
+
AwsCli::CLI::EC2::Vpc.register AwsCli::CLI::EC2::VPC::Dhcp, :dhcp, 'dhcp [COMMAND]', 'VPC DHCP Management'
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
module VPC
|
5
|
+
require 'awscli/cli/ec2/vpc'
|
6
|
+
class InternetGateways < Thor
|
7
|
+
|
8
|
+
desc "list", "List Internet Gateways"
|
9
|
+
def list
|
10
|
+
create_ec2_object
|
11
|
+
@ec2.list
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "create", "Create Internet Gateway"
|
15
|
+
def create
|
16
|
+
create_ec2_object
|
17
|
+
@ec2.create
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "delete", "Delete Internet Gateway"
|
21
|
+
method_option :internet_gateway_id, :aliases => "-i", :type => :string, :required => true, :desc => "id of the internet gateway to delete"
|
22
|
+
def delete
|
23
|
+
create_ec2_object
|
24
|
+
@ec2.delete options[:internet_gateway_id]
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "attach", "Attach Internet Gateway"
|
28
|
+
method_option :internet_gateway_id, :aliases => "-i", :type => :string, :required => true, :desc => "id of the internet gateway to attach"
|
29
|
+
method_option :vpc_id, :aliases => "-v", :type => :string, :required => true, :desc => "id vpc to attach to"
|
30
|
+
def attach
|
31
|
+
create_ec2_object
|
32
|
+
@ec2.attach options[:internet_gateway_id], options[:vpc_id]
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "deattach", "Deattach Internet Gateway"
|
36
|
+
method_option :internet_gateway_id, :aliases => "-i", :type => :string, :required => true, :desc => "id of the internet gateway to attach"
|
37
|
+
method_option :vpc_id, :aliases => "-v", :type => :string, :required => true, :desc => "id vpc to attach to"
|
38
|
+
def deattach
|
39
|
+
create_ec2_object
|
40
|
+
@ec2.deattach options[:internet_gateway_id], options[:vpc_id]
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def create_ec2_object
|
46
|
+
puts "ec2 Establishing Connetion..."
|
47
|
+
$ec2_conn = Awscli::Connection.new.request_ec2
|
48
|
+
puts "ec2 Establishing Connetion... OK"
|
49
|
+
@ec2 = Awscli::EC2::InternetGateways.new($ec2_conn)
|
50
|
+
end
|
51
|
+
|
52
|
+
AwsCli::CLI::EC2::Vpc.register AwsCli::CLI::EC2::VPC::InternetGateways, :internetgateways, 'internetgateways [COMMAND]', 'VPC Network Internet Gateway Management'
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
module VPC
|
5
|
+
require 'awscli/cli/ec2/vpc'
|
6
|
+
class NetworkInterfaces < Thor
|
7
|
+
|
8
|
+
desc "list", "List Network Interfaces"
|
9
|
+
def list
|
10
|
+
create_ec2_object
|
11
|
+
@ec2.list
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "create", "Creates a network interface in the specified subnet. This command is supported only in EC2-VPC"
|
15
|
+
method_option :subnet_id, :aliases => "-s", :type => :string, :required => true, :desc => "subnet id"
|
16
|
+
method_option :description, :aliases => "-d", :type => :string, :desc => "Set the description of the network interface"
|
17
|
+
method_option :private_ip_address, :aliases => "-p", :type => :string, :desc => "The primary private IP address of the network interface. If an IP address is not specified, one will be auto-assigned to the interface"
|
18
|
+
method_option :group_set, :aliases => "-g", :type => :array, :desc => "A security group to add to the network interface"
|
19
|
+
def create
|
20
|
+
create_ec2_object
|
21
|
+
@ec2.create options
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "delete", "Deletes a network interface. Network interfaces must be detached from an instance before they can be deleted."
|
25
|
+
method_option :network_interface_id, :aliases => "-n", :type => :string, :required => true, :desc => "Id of the network interface to delete"
|
26
|
+
def delete
|
27
|
+
create_ec2_object
|
28
|
+
@ec2.delete options[:network_interface_id]
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "attach", "Attaches a network interface to an instance"
|
32
|
+
method_option :network_interface_id, :aliases => "-n", :type => :string, :required => true, :desc => "ID of the network interface to attach"
|
33
|
+
method_option :instance_id, :aliases => "-i", :type => :string, :required => true, :desc => "ID of the instance that will be attached to the network interface"
|
34
|
+
method_option :device_index, :aliases => "-d", :type => :numeric, :required => true, :desc => "index of the device for the network interface attachment on the instance"
|
35
|
+
def attach
|
36
|
+
create_ec2_object
|
37
|
+
@ec2.attach options[:network_interface_id], options[:instance_id], options[:device_index]
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "deattach", "Detaches a network interface"
|
41
|
+
method_option :attachment_id, :aliases => "-a", :type => :string, :required => true, :desc => "ID of the attachment to detach"
|
42
|
+
method_option :force, :aliases => "-f", :type => :boolean, :default => false, :desc => "Set to true to force a detachment"
|
43
|
+
def deattach
|
44
|
+
create_ec2_object
|
45
|
+
@ec2.deattach options[:attachment_id], options[:force]
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "modify_attribute", "Modifies a network interface attribute. You can specify only one attribute at a time"
|
49
|
+
method_option :network_interface_id, :aliases => "-n", :type => :string, :required => true, :desc => "The ID of the network interface you want to modify an attribute of"
|
50
|
+
method_option :attribute, :aliases => "-a", :type => :string, :required => true, :desc => "The attribute to modify, must be one of 'description', 'groupSet', 'sourceDestCheck' or 'attachment'"
|
51
|
+
method_option :description, :aliases => "-d", :type => :string, :desc => "New value of attribute - description"
|
52
|
+
method_option :group_set, :aliases => "-g", :type => :array, :desc => "New value of attribute - a list of group id's"
|
53
|
+
method_option :source_dest_check, :aliases => "-s", :type => :boolean, :desc => "New value of attribute - a boolean value"
|
54
|
+
method_option :attachment, :aliases => "-t", :type => :hash, :desc => "a hash with: attachmentid - the attachment to change & deleteOnTermination - a boolean"
|
55
|
+
def modify_attribute
|
56
|
+
create_ec2_object
|
57
|
+
@ec2.modify_attribute options
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def create_ec2_object
|
63
|
+
puts "ec2 Establishing Connetion..."
|
64
|
+
$ec2_conn = Awscli::Connection.new.request_ec2
|
65
|
+
puts "ec2 Establishing Connetion... OK"
|
66
|
+
@ec2 = Awscli::EC2::NetworkInterfaces.new($ec2_conn)
|
67
|
+
end
|
68
|
+
|
69
|
+
AwsCli::CLI::EC2::Vpc.register AwsCli::CLI::EC2::VPC::NetworkInterfaces, :netinterfaces, 'netinterfaces [COMMAND]', 'VPC Network Acl Management'
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module EC2
|
4
|
+
module VPC
|
5
|
+
require 'awscli/cli/ec2/vpc'
|
6
|
+
class NetworkAcl < Thor
|
7
|
+
|
8
|
+
desc "list", "List NACLs"
|
9
|
+
def list
|
10
|
+
create_ec2_object
|
11
|
+
@ec2.list
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def create_ec2_object
|
17
|
+
puts "ec2 Establishing Connetion..."
|
18
|
+
$ec2_conn = Awscli::Connection.new.request_ec2
|
19
|
+
puts "ec2 Establishing Connetion... OK"
|
20
|
+
@ec2 = Awscli::EC2::NetworkAcl.new($ec2_conn)
|
21
|
+
end
|
22
|
+
|
23
|
+
AwsCli::CLI::EC2::Vpc.register AwsCli::CLI::EC2::VPC::NetworkAcl, :networkacl, 'networkacl [COMMAND]', 'VPC Network Acl Management'
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
require 'awscli/cli'
|
4
|
+
require 'awscli/connection'
|
5
|
+
require 'awscli/s3'
|
6
|
+
class S3 < Thor
|
7
|
+
class_option :region, :type => :string, :desc => "region to connect to"
|
8
|
+
|
9
|
+
AwsCli::Cli.register AwsCli::CLI::S3, :s3, 's3 [COMMAND]', 'Simple Storage Service Interface'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module Sss
|
4
|
+
require 'awscli/cli/s3'
|
5
|
+
class Directories < Thor
|
6
|
+
|
7
|
+
desc "list", "List S3 buckets"
|
8
|
+
def list
|
9
|
+
create_s3_object
|
10
|
+
@s3.list
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "create", "Create an new S3 bucket"
|
14
|
+
method_option :key, :aliases => "-k", :type => :string, :required => true, :desc => "name of the bucket to create(name should be globally unique)"
|
15
|
+
method_option :public, :aliases => "-p", :type => :boolean, :default => false, :desc => "makes the bucket publicly availble"
|
16
|
+
# method_option :x_amz_acl, :aliases => "-x", :type => :string, :desc => "Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']"
|
17
|
+
def create
|
18
|
+
create_s3_object
|
19
|
+
@s3.create options
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "delete", "Delete existing S3 bucket"
|
23
|
+
method_option :key, :aliases => "-k", :type => :string, :required => true, :desc => "name of the bucket to delete"
|
24
|
+
def delete
|
25
|
+
create_s3_object
|
26
|
+
@s3.delete options[:key]
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "set_acl", "Change access control list for an S3 bucket"
|
30
|
+
method_option :key, :aliases => "-k", :type => :string, :required => true, :desc => "name of the bucket to change acl"
|
31
|
+
method_option :acl, :aliases => "-a", :type => :string, :required => true, :desc => "Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']"
|
32
|
+
def set_acl
|
33
|
+
create_s3_object
|
34
|
+
@s3.set_acl options[:key], options[:acl]
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "get_acl", "Get access control list for an S3 bucket"
|
38
|
+
method_option :key, :aliases => "-k", :type => :string, :required => true, :desc => "name of the bucket to get acl"
|
39
|
+
def get_acl
|
40
|
+
create_s3_object
|
41
|
+
@s3.get_acl options[:key]
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "get_logging_status", "Get logging status for an S3 bucket"
|
45
|
+
method_option :key, :aliases => "-k", :type => :string, :required => true, :desc => "name of the bucket"
|
46
|
+
def get_logging_status
|
47
|
+
create_s3_object
|
48
|
+
@s3.get_logging_status options[:key]
|
49
|
+
end
|
50
|
+
|
51
|
+
# desc "set_logging_status", "Change logging status for an S3 bucket"
|
52
|
+
# method_option :key, :aliases => "-k", :type => :string, :required => true, :desc => "name of the bucket"
|
53
|
+
# method_option :owner, :aliases => "-o", :type => :hash, :banner => "ID:NAME", :desc => "set id and displayname of the owner"
|
54
|
+
# method_option :grantee, :aliases => "-g", :type => :hash, :banner => "NAME:ID|EMAIL|URI", :desc => "Grantee hash containing, <Display name of the grantee>: <ID of the grantee (or) Email of the grantee (or) Uri of the group to grant access>"
|
55
|
+
# method_option :permission, :aliases => "-p", :type => :string, :desc => "Permission, in [FULL_CONTROL, WRITE, WRITE_ACP, READ, READ_ACP]"
|
56
|
+
# def set_logging_status
|
57
|
+
# create_s3_object
|
58
|
+
# (acl ||= []) << options[:grantee] if options[:grantee]
|
59
|
+
# acl << options[:permission] if options[:permission]
|
60
|
+
# logging_status = Hash.new
|
61
|
+
# logging_status['Owner'] = options[:owner] if options[:owner]
|
62
|
+
# logging_status['AccessControlList'] = acl if acl
|
63
|
+
# puts "Empty logging_status will disable logging" if logging_status.nil?
|
64
|
+
# puts "#{logging_status}"
|
65
|
+
# @s3.set_logging_status options[:key], logging_status
|
66
|
+
# end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def create_s3_object
|
71
|
+
puts "S3 Establishing Connetion..."
|
72
|
+
$s3_conn = Awscli::Connection.new.request_s3
|
73
|
+
puts "S3 Establishing Connetion... OK"
|
74
|
+
@s3 = Awscli::S3::Directories.new($s3_conn)
|
75
|
+
end
|
76
|
+
|
77
|
+
AwsCli::CLI::S3.register AwsCli::CLI::Sss::Directories, :dirs, 'dirs [COMMAND]', 'S3 Directories Management'
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module AwsCli
|
2
|
+
module CLI
|
3
|
+
module Sss
|
4
|
+
require 'awscli/cli/s3'
|
5
|
+
class Files < Thor
|
6
|
+
|
7
|
+
desc "list", "list objects(files) in a bucket"
|
8
|
+
method_option :bucket_name, :aliases => "-b", :required => true, :desc => "bucket name to print the contents from"
|
9
|
+
def list
|
10
|
+
create_s3_object
|
11
|
+
@s3.list options[:bucket_name]
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "put", "put a file into a bucket"
|
15
|
+
method_option :bucket_name, :aliases => "-b", :required => true, :desc => "name of the bucket to upload the file to"
|
16
|
+
method_option :file_path, :aliases => "-p", :required => true, :desc => "local file path"
|
17
|
+
def put
|
18
|
+
create_s3_object
|
19
|
+
@s3.upload_file options[:bucket_name], options[:file_path]
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "get", "get a file from a bucket"
|
23
|
+
method_option :bucket_name, :aliases => "-b", :required => true, :desc => "name of the bucket to download the file from"
|
24
|
+
method_option :file_name, :aliases => "-f", :required => true, :desc => "name of file to download"
|
25
|
+
method_option :local_path, :aliases => "-p", :required => true, :desc => "local fs path, where to download the file to"
|
26
|
+
def get
|
27
|
+
create_s3_object
|
28
|
+
@s3.download_file options[:bucket_name], options[:file_name], options[:local_path]
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "delete", "delete a file from a bucket"
|
32
|
+
method_option :bucket_name, :aliases => "-b", :required => true, :desc => "name of the bucket to download the file from"
|
33
|
+
method_option :file_name, :aliases => "-f", :required => true, :desc => "name of file to download"
|
34
|
+
def delete
|
35
|
+
create_s3_object
|
36
|
+
@s3.delete_file options[:bucket_name], options[:file_name]
|
37
|
+
end
|
38
|
+
|
39
|
+
# s3.directories.get('arun123').files.get('block_9091299035346850259').copy('ashrithtst', 'testfile')
|
40
|
+
desc "copy", "copy object from one bucket to another"
|
41
|
+
method_option :source_bucket, :aliases => "-s", :required => true, :desc => "source bucket name from where to copy the file"
|
42
|
+
method_option :source_file, :aliases => "-f", :required => true, :desc => "source file name to copy"
|
43
|
+
method_option :dest_bucket, :aliases => "-d", :required => true, :desc => "destination bucket name to copy the file to"
|
44
|
+
method_option :dest_file, :alises => "-r", :required => true, :desc => "destination file name"
|
45
|
+
def copy
|
46
|
+
create_s3_object
|
47
|
+
@s3.copy_file options[:source_bucket], options[:source_file], options[:dest_bucket], options[:dest_file]
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "public_url", "show the public url of a file"
|
51
|
+
method_option :bucket_name, :aliases => "-b", :required => true, :desc => "name of the bucket to download the file from"
|
52
|
+
method_option :file_name, :aliases => "-f", :required => true, :desc => "name of file to download"
|
53
|
+
def public_url
|
54
|
+
create_s3_object
|
55
|
+
@s3.get_public_url options[:bucket_name], options[:file_name]
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def create_s3_object
|
62
|
+
puts "S3 Establishing Connetion..."
|
63
|
+
$s3_conn = if parent_options[:region]
|
64
|
+
Awscli::Connection.new.request_s3(parent_options[:region])
|
65
|
+
else
|
66
|
+
Awscli::Connection.new.request_s3
|
67
|
+
end
|
68
|
+
puts "S3 Establishing Connetion... OK"
|
69
|
+
@s3 = Awscli::S3::Files.new($s3_conn)
|
70
|
+
end
|
71
|
+
|
72
|
+
AwsCli::CLI::S3.register AwsCli::CLI::Sss::Files, :files, 'files [COMMAND]', 'S3 Files Management'
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|