class Comodule::Deployment::Helper::Aws::Ssl::Service

Public Instance Methods

delete() click to toggle source
# File lib/comodule/deployment/helper/aws/ssl.rb, line 27
def delete
  name = config.ssl.name
  cert = iam.server_certificates[name]
  puts "I am going to delete this server certificate #{name}. Are you sure? [N/y] "
  confirm = STDIN.gets
  unless confirm =~ /^y(es)?$/
    puts "\nAbort!\n"
    return
  end
  puts cert.delete
end
describe() click to toggle source
# File lib/comodule/deployment/helper/aws/ssl.rb, line 20
def describe
  puts
  iam.server_certificates.each do |cert|
    inspect_certificate cert
  end
end
find() click to toggle source
# File lib/comodule/deployment/helper/aws/ssl.rb, line 105
def find
  iam.server_certificates.find do |cert|
    cert.name == config.ssl.name
  end
end
iam() click to toggle source
# File lib/comodule/deployment/helper/aws/ssl.rb, line 16
def iam
  aws.iam
end
inspect_certificate(cert) click to toggle source
# File lib/comodule/deployment/helper/aws/ssl.rb, line 78
def inspect_certificate(cert)
  inspect_certificate_summary cert
  inspect_certificate_body cert
  inspect_certificate_chain cert
end
inspect_certificate_body(cert) click to toggle source
# File lib/comodule/deployment/helper/aws/ssl.rb, line 93
def inspect_certificate_body(cert)
  puts "body:"
  puts cert.certificate_body
  puts
end
inspect_certificate_chain(cert) click to toggle source
# File lib/comodule/deployment/helper/aws/ssl.rb, line 99
def inspect_certificate_chain(cert)
  puts "chain:"
  puts cert.certificate_chain
  puts
end
inspect_certificate_summary(cert) click to toggle source
# File lib/comodule/deployment/helper/aws/ssl.rb, line 84
def inspect_certificate_summary(cert)
  puts "arn:         #{cert.arn}"
  puts "id:          #{cert.id}"
  puts "name:        #{cert.name}"
  puts "path:        #{cert.path}"
  puts "upload_date: #{cert.upload_date}"
  puts
end
upload() click to toggle source
# File lib/comodule/deployment/helper/aws/ssl.rb, line 39
def upload
  body  = File.open(owner.file_path(config.ssl.dir, config.ssl.body_file)).read
  chain = File.open(owner.file_path(config.ssl.dir, config.ssl.chain_file)).read
  key   = File.open(owner.file_path(config.ssl.dir, config.ssl.key_file)).read
  puts "body:"
  puts body
  puts
  puts "chain:"
  puts chain
  puts
  puts "key"
  puts key
  puts
  puts "AWS IAM server certificate name: #{config.ssl.name}"
  puts "I am going to upload this server certificate to AWS IAM. Are you sure? [N/y] "
  confirm = STDIN.gets
  unless confirm =~ /^y(es)?$/
    puts "\nAbort!\n"
    return
  end

  cert = iam.server_certificates.create(
    certificate_body: body,
    name: config.ssl.name,
    path: config.ssl.path || ?/,
    private_key: key,
    certificate_chain: chain
  )

  unless cert
    'Failed!'
    return
  end

  puts
  puts "Success:"
  inspect_certificate cert
end