Class: Fog::AWS::KMS::Real
- Inherits:
-
Object
- Object
- Fog::AWS::KMS::Real
- Includes:
- CredentialFetcher::ConnectionMethods
- Defined in:
- lib/fog/aws/kms.rb,
lib/fog/aws/requests/kms/sign.rb,
lib/fog/aws/requests/kms/list_keys.rb,
lib/fog/aws/requests/kms/create_key.rb,
lib/fog/aws/requests/kms/describe_key.rb,
lib/fog/aws/requests/kms/get_public_key.rb,
lib/fog/aws/requests/kms/schedule_key_deletion.rb
Instance Method Summary collapse
-
#create_key(*args) ⇒ Object
Create Key.
- #describe_key(identifier) ⇒ Object
- #get_public_key(identifier, grant_tokens = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
Initialize connection to KMS.
- #list_keys(options = {}) ⇒ Object
- #reload ⇒ Object
- #schedule_key_deletion(identifier, pending_window_in_days) ⇒ Object
-
#sign(identifier, message, algorithm, options = {}) ⇒ Object
Sign.
Methods included from CredentialFetcher::ConnectionMethods
#refresh_credentials_if_expired
Constructor Details
#initialize(options = {}) ⇒ Real
Initialize connection to KMS
Notes
options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection
Examples
kms = KMS.new(
:aws_access_key_id => your_aws_access_key_id,
:aws_secret_access_key => your_aws_secret_access_key
)
Parameters
-
options<~Hash> - config arguments for connection. Defaults to {}.
-
region<~String> - optional region to use. For instance, ‘eu-west-1’, ‘us-east-1’, etc.
-
Returns
-
KMS object with connection to AWS.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/fog/aws/kms.rb', line 95 def initialize(={}) @use_iam_profile = [:use_iam_profile] @connection_options = [:connection_options] || {} @instrumentor = [:instrumentor] @instrumentor_name = [:instrumentor_name] || 'fog.aws.kms' [:region] ||= 'us-east-1' @region = [:region] @host = [:host] || "kms.#{@region}.amazonaws.com" @path = [:path] || '/' @persistent = [:persistent] || false @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options) setup_credentials() end |
Instance Method Details
#create_key(*args) ⇒ Object
Create Key
Parameters
-
options<~Hash>:
-
‘Description’<~String>:
-
‘KeyUsage’<~String>:
-
‘Policy’<~String>:
-
… (see docs from see also)
-
Returns
See Also
docs.aws.amazon.com/kms/latest/APIReference/API_CreateKey.html
20 21 22 23 24 25 26 |
# File 'lib/fog/aws/requests/kms/create_key.rb', line 20 def create_key(*args) = Fog::AWS::KMS.parse_create_key_args(args) request({ 'Action' => 'CreateKey', :parser => Fog::Parsers::AWS::KMS::DescribeKey.new }.merge!()) end |
#describe_key(identifier) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/fog/aws/requests/kms/describe_key.rb', line 7 def describe_key(identifier) request( 'Action' => 'DescribeKey', 'KeyId' => identifier, :parser => Fog::Parsers::AWS::KMS::DescribeKey.new ) end |
#get_public_key(identifier, grant_tokens = nil) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/fog/aws/requests/kms/get_public_key.rb', line 7 def get_public_key(identifier, grant_tokens = nil) request( 'Action' => 'GetPublicKey', 'GrantTokens' => grant_tokens, 'KeyId' => identifier, :parser => Fog::Parsers::AWS::KMS::GetPublicKey.new ) end |
#list_keys(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fog/aws/requests/kms/list_keys.rb', line 7 def list_keys(={}) params = {} if [:marker] params['Marker'] = [:marker] end if [:limit] params['Limit'] = [:limit] end request({ 'Action' => 'ListKeys', :parser => Fog::Parsers::AWS::KMS::ListKeys.new }.merge(params)) end |
#reload ⇒ Object
116 117 118 |
# File 'lib/fog/aws/kms.rb', line 116 def reload @connection.reset end |
#schedule_key_deletion(identifier, pending_window_in_days) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/fog/aws/requests/kms/schedule_key_deletion.rb', line 7 def schedule_key_deletion(identifier, pending_window_in_days) request( 'Action' => 'ScheduleKeyDeletion', 'KeyId' => identifier, 'PendingWindowInDays' => pending_window_in_days, :parser => Fog::Parsers::AWS::KMS::ScheduleKeyDeletion.new ) end |
#sign(identifier, message, algorithm, options = {}) ⇒ Object
Sign
Parameters
-
identifier<~String>: id, arn, alias name, or alias arn for key to sign with
-
message<~String>: base64 encoded message to sign
Returns
-
response<~Excon::Response>:
See Also
19 20 21 22 23 24 25 26 27 |
# File 'lib/fog/aws/requests/kms/sign.rb', line 19 def sign(identifier, , algorithm, = {}) request({ 'Action' => 'Sign', 'KeyId' => identifier, 'Message' => , 'SigningAlgorithm' => algorithm, :parser => Fog::Parsers::AWS::KMS::Sign.new }.merge!()) end |