Class: Encryptbot::Services::Route53
- Inherits:
-
Object
- Object
- Encryptbot::Services::Route53
- Defined in:
- lib/encryptbot/services/route53.rb
Instance Attribute Summary collapse
-
#aws_acme_record_name ⇒ Object
Returns the value of attribute aws_acme_record_name.
-
#client ⇒ Object
Returns the value of attribute client.
-
#dns_entry ⇒ Object
Returns the value of attribute dns_entry.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#hosted_zone_id ⇒ Object
Returns the value of attribute hosted_zone_id.
Instance Method Summary collapse
- #add_challenge ⇒ Object
-
#initialize(domain, dns_entry) ⇒ Route53
constructor
A new instance of Route53.
Constructor Details
#initialize(domain, dns_entry) ⇒ Route53
Returns a new instance of Route53.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/encryptbot/services/route53.rb', line 10 def initialize(domain, dns_entry) @dns_entry = dns_entry @hosted_zone_id = Encryptbot.configuration.route53_hosted_zone_id @acme_name = Encryptbot.configuration.route53_acme_record_name @client = Aws::Route53::Client.new({ region: "global", credentials: Aws::Credentials.new( Encryptbot.configuration.route53_access_key_id, Encryptbot.configuration.route53_secret_access_key )}) end |
Instance Attribute Details
#aws_acme_record_name ⇒ Object
Returns the value of attribute aws_acme_record_name.
8 9 10 |
# File 'lib/encryptbot/services/route53.rb', line 8 def aws_acme_record_name @aws_acme_record_name end |
#client ⇒ Object
Returns the value of attribute client.
8 9 10 |
# File 'lib/encryptbot/services/route53.rb', line 8 def client @client end |
#dns_entry ⇒ Object
Returns the value of attribute dns_entry.
8 9 10 |
# File 'lib/encryptbot/services/route53.rb', line 8 def dns_entry @dns_entry end |
#domain ⇒ Object
Returns the value of attribute domain.
8 9 10 |
# File 'lib/encryptbot/services/route53.rb', line 8 def domain @domain end |
#hosted_zone_id ⇒ Object
Returns the value of attribute hosted_zone_id.
8 9 10 |
# File 'lib/encryptbot/services/route53.rb', line 8 def hosted_zone_id @hosted_zone_id end |
Instance Method Details
#add_challenge ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/encryptbot/services/route53.rb', line 22 def add_challenge begin response = @client.change_resource_record_sets({ change_batch: { changes: [ action: "UPSERT", resource_record_set: { name: @acme_name, resource_records: [ { value: "\"#{@dns_entry[:content]}\"", }, ], ttl: 0, type: "TXT", } ], comment: "ACME Challege update", }, hosted_zone_id: @hosted_zone_id }) change_id = response.change_info.id change_status = response.change_info.status while change_status == "PENDING" sleep(10) change_status = @client.get_change({id: change_id}).change_info.status end change_status == "INSYNC" rescue => e raise Encryptbot::Error::Route53DNSError, e end end |