Class: CfnVpn::Acm
- Inherits:
-
Object
- Object
- CfnVpn::Acm
- Defined in:
- lib/cfnvpn/acm.rb
Instance Method Summary collapse
- #get_certificate_tags(certificate_arn, key = nil) ⇒ Object
- #import_certificate(cert, key, ca) ⇒ Object
-
#initialize(region, cert_dir) ⇒ Acm
constructor
A new instance of Acm.
- #load_certificate(cert) ⇒ Object
- #tag_certificate(arn, name, type, cfnvpn_name) ⇒ Object
Constructor Details
#initialize(region, cert_dir) ⇒ Acm
Returns a new instance of Acm.
7 8 9 10 |
# File 'lib/cfnvpn/acm.rb', line 7 def initialize(region,cert_dir) @client = Aws::ACM::Client.new(region: region) @cert_dir = cert_dir end |
Instance Method Details
#get_certificate_tags(certificate_arn, key = nil) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cfnvpn/acm.rb', line 42 def (certificate_arn,key=nil) resp = @client.({ certificate_arn: certificate_arn }) if key.nil? return resp. else resp..each do |tag| return tag.value if tag.key == key end raise "no tag key #{key} matched the certificate #{certificate_arn}" end end |
#import_certificate(cert, key, ca) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cfnvpn/acm.rb', line 12 def import_certificate(cert,key,ca) cert_body = load_certificate(cert) key_body = load_certificate(key) ca_body = load_certificate(ca) resp = @client.import_certificate({ certificate: cert_body, private_key: key_body, certificate_chain: ca_body }) return resp.certificate_arn end |
#load_certificate(cert) ⇒ Object
38 39 40 |
# File 'lib/cfnvpn/acm.rb', line 38 def load_certificate(cert) File.read("#{@cert_dir}/#{cert}") end |
#tag_certificate(arn, name, type, cfnvpn_name) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cfnvpn/acm.rb', line 25 def tag_certificate(arn,name,type,cfnvpn_name) = [ { key: "Name", value: name }, { key: "cfnvpn:name", value: cfnvpn_name }, { key: "cfnvpn:certificate:type", value: type } ] @client.({ certificate_arn: arn, tags: }) end |