module Formatron::S3::ChefServerCert

manage the Chef Server SSL certificate and key stored on S3

Constants

CERT_NAME
KEY_NAME

Public Class Methods

cert_key(name:, target:, guid:) click to toggle source

rubocop:enable Metrics/MethodLength

# File lib/formatron/s3/chef_server_cert.rb, line 68
def self.cert_key(name:, target:, guid:)
  Path.key(
    name: name,
    target: target,
    sub_key: "#{guid}/#{CERT_NAME}"
  )
end
deploy( aws:, kms_key:, bucket:, name:, target:, guid:, cert:, key: ) click to toggle source

rubocop:disable Metrics/ParameterLists rubocop:disable Metrics/MethodLength

# File lib/formatron/s3/chef_server_cert.rb, line 13
def self.deploy(
  aws:,
  kms_key:,
  bucket:,
  name:,
  target:,
  guid:,
  cert:,
  key:
)
  cert_key = self.cert_key name: name, target: target, guid: guid
  Formatron::LOG.info do
    "Upload Chef Server SSL certifcate to #{bucket}/#{cert_key}"
  end
  aws.upload_file(
    kms_key: kms_key,
    bucket: bucket,
    key: cert_key,
    content: cert
  )
  key_key = self.key_key name: name, target: target, guid: guid
  Formatron::LOG.info do
    "Upload Chef Server SSL key to #{bucket}/#{key_key}"
  end
  aws.upload_file(
    kms_key: kms_key,
    bucket: bucket,
    key: key_key,
    content: key
  )
end
destroy(aws:, bucket:, name:, target:, guid:) click to toggle source

rubocop:disable Metrics/MethodLength

# File lib/formatron/s3/chef_server_cert.rb, line 48
def self.destroy(aws:, bucket:, name:, target:, guid:)
  cert_key = self.cert_key name: name, target: target, guid: guid
  Formatron::LOG.info do
    "Delete Chef Server SSL certificate from #{bucket}/#{cert_key}"
  end
  aws.delete_file(
    bucket: bucket,
    key: cert_key
  )
  key_key = self.key_key name: name, target: target, guid: guid
  Formatron::LOG.info do
    "Delete Chef Server SSL key from #{bucket}/#{key_key}"
  end
  aws.delete_file(
    bucket: bucket,
    key: key_key
  )
end
key_key(name:, target:, guid:) click to toggle source
# File lib/formatron/s3/chef_server_cert.rb, line 76
def self.key_key(name:, target:, guid:)
  Path.key(
    name: name,
    target: target,
    sub_key: "#{guid}/#{KEY_NAME}"
  )
end