Class: Furnish::Provisioner::AWS
- Inherits:
-
API
- Object
- API
- Furnish::Provisioner::AWS
- Includes:
- Logger::Mixins
- Defined in:
- lib/furnish/provisioners/aws.rb
Overview
AWS base class, handles AWS API basics, argument checking, general utility methods.
See attributes and #new for contraints that apply to all provisioners that inherit from it.
Direct Known Subclasses
Instance Method Summary collapse
-
#access_key ⇒ Object
:attr: access_key.
-
#check_aws_settings ⇒ Object
Ensures #access_key and #secret_key are set.
-
#check_region ⇒ Object
Ensures the region is set.
-
#ec2 ⇒ Object
constructs an AWS::EC2 object.
-
#initialize(args) ⇒ AWS
constructor
Construct a new provisioner.
-
#region ⇒ Object
:attr: region.
-
#secret_key ⇒ Object
:attr: secret_key.
Constructor Details
#initialize(args) ⇒ AWS
Construct a new provisioner. Hash for arguments is required, values supplied will be injected into attributes. If a hash is not supplied, an ArgumentError is raised.
The AWS #access_key and #secret_key are required, and also raise an ArgumentError unless supplied.
In some provisioners, a region may also be required. In those, an… ArgumentError will be raise if it isn’t supplied.
For further constraints, please see provisioners that inherit from this class.
59 60 61 62 |
# File 'lib/furnish/provisioners/aws.rb', line 59 def initialize(args) super check_aws_settings end |
Instance Method Details
#access_key ⇒ Object
:attr: access_key
The AWS access key ID. Required.
22 23 24 |
# File 'lib/furnish/provisioners/aws.rb', line 22 furnish_property :access_key, "AWS access key ID", String |
#check_aws_settings ⇒ Object
Ensures #access_key and #secret_key are set. Used by initializer.
67 68 69 70 71 |
# File 'lib/furnish/provisioners/aws.rb', line 67 def check_aws_settings unless access_key and secret_key raise ArgumentError, "AWS credentials must be provided to the provisioner." end end |
#check_region ⇒ Object
Ensures the region is set. Is not used by default in the initializer, but is common to many provisioners.
77 78 79 80 81 |
# File 'lib/furnish/provisioners/aws.rb', line 77 def check_region unless region raise ArgumentError, "AWS region must be provided to the provisioner." end end |
#ec2 ⇒ Object
constructs an AWS::EC2 object. if a region is supplied, constraints it to the region and a AWS::EC2::Region object will be returned.
these have the same interface for most things, and things that require a region in AWS::EC2 are defaulted to us-east-1. See the aws-sdk documentation for more details.
91 92 93 94 95 96 97 98 |
# File 'lib/furnish/provisioners/aws.rb', line 91 def ec2 ec2 = ::AWS::EC2.new( :access_key_id => access_key, :secret_access_key => secret_key ) return region ? ec2.regions[region] : ec2 end |
#region ⇒ Object
:attr: region
The AWS region. Not required. The default is nil. Inheriting provisioners may affect the default and/or make it required.
41 42 43 |
# File 'lib/furnish/provisioners/aws.rb', line 41 furnish_property :region, "AWS region -- default is nil, may be defaulted or required by subclasses.", String |
#secret_key ⇒ Object
:attr: secret_key
The AWS secret key ID. Required.
31 32 33 |
# File 'lib/furnish/provisioners/aws.rb', line 31 furnish_property :secret_key, "AWS secret key ID", String |