Sha256: 05c8b39a2094f4a846795793d1f20f8105861f16d4d1a34cb31d1d4f81a065e7

Contents?: true

Size: 1.53 KB

Versions: 74

Compression:

Stored size: 1.53 KB

Contents

module Fog
  module AWS
    class KMS
      class Real
        DEFAULT_KEY_POLICY = <<-JSON
{
  "Version": "2012-10-17",
  "Id": "key-default-1",
  "Statement": [
    {
      "Sid": "Enable IAM User Permissions",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::915445820265:root"
      },
      "Action": "kms:*",
      "Resource": "*"
    }
  ]
}
        JSON

        require 'fog/aws/parsers/kms/describe_key'

        def create_key(policy = nil, description = nil, usage = "ENCRYPT_DECRYPT")
          request(
            'Action'      => 'CreateKey',
            'Description' => description,
            'KeyUsage'    => usage,
            'Policy'      => policy,
            :parser       => Fog::Parsers::AWS::KMS::DescribeKey.new
          )
        end
      end

      class Mock
        def create_key(policy = nil, description = nil, usage = "ENCRYPT_DECRYPT")
          response = Excon::Response.new
          key_id   = UUID.uuid
          key_arn  = Fog::AWS::Mock.arn("kms", self.account_id, "key/#{key_id}", @region)

          key = {
            "KeyUsage"     => usage,
            "AWSAccountId" => self.account_id,
            "KeyId"        => key_id,
            "Description"  => description,
            "CreationDate" => Time.now,
            "Arn"          => key_arn,
            "Enabled"      => true,
          }

          # @todo use default policy

          self.data[:keys][key_id] = key

          response.body = { "KeyMetadata" => key }
          response
        end
      end
    end
  end
end

Version data entries

74 entries across 72 versions & 3 rubygems

Version Path
fog-aws-3.29.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.28.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.27.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.26.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.25.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.24.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.23.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.22.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.21.1 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.21.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.20.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.19.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.18.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.17.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.16.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.15.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.14.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.13.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.12.0 lib/fog/aws/requests/kms/create_key.rb
fog-aws-3.11.0 lib/fog/aws/requests/kms/create_key.rb