Class: Acmesmith::ChallengeResponders::Route53
- Inherits:
-
Base
- Object
- Base
- Acmesmith::ChallengeResponders::Route53
show all
- Defined in:
- lib/acmesmith/challenge_responders/route53.rb
Defined Under Namespace
Classes: AmbiguousHostedZones, HostedZoneNotFound
Instance Method Summary
collapse
Methods inherited from Base
#applicable?, #cleanup, #respond
Constructor Details
#initialize(aws_access_key: nil, assume_role: nil, hosted_zone_map: {}, restore_to_original_records: false, substitution_map: {}) ⇒ Route53
Returns a new instance of Route53.
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/acmesmith/challenge_responders/route53.rb', line 20
def initialize(aws_access_key: nil, assume_role: nil, hosted_zone_map: {}, restore_to_original_records: false, substitution_map: {})
aws_options = {region: 'us-east-1'}.tap do |opt|
opt[:credentials] = Aws::Credentials.new(aws_access_key['access_key_id'], aws_access_key['secret_access_key'], aws_access_key['session_token']) if aws_access_key
end
@route53 = Aws::Route53::Client.new(aws_options.dup.tap do |opt|
case
when assume_role
opt[:credentials] = Aws::AssumeRoleCredentials.new(
client: Aws::STS::Client.new(aws_options),
**({role_session_name: "acmesmith-#{$$}"}.merge(assume_role.map{ |k,v| [k.to_sym,v] }.to_h)),
)
end
end)
@hosted_zone_map = hosted_zone_map
@hosted_zone_cache = {}
@restore_to_original_records = restore_to_original_records
@original_records = {}
@substitution_map = substitution_map.map { |k,v| [canonical_fqdn(k), v] }.to_h
end
|
Instance Method Details
#cap_respond_all? ⇒ Boolean
16
17
18
|
# File 'lib/acmesmith/challenge_responders/route53.rb', line 16
def cap_respond_all?
true
end
|
#cleanup_all(*domain_and_challenges) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/acmesmith/challenge_responders/route53.rb', line 66
def cleanup_all(*domain_and_challenges)
domain_and_challenges = apply_substitution_for_domain_and_challenges(domain_and_challenges)
challenges_by_hosted_zone = domain_and_challenges.group_by { |(domain, _)| find_hosted_zone(domain) }
zone_and_batches = challenges_by_hosted_zone.map do |zone_id, dcs|
[
zone_id,
change_batch_for_challenges(
dcs,
action: 'DELETE',
comment: '(cleanup)',
post_changes: changes_to_restore_original_records(zone_id, *dcs),
),
]
end
request_changing_rrset(zone_and_batches, comment: 'to remove challenge responses')
end
|
#respond_all(*domain_and_challenges) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/acmesmith/challenge_responders/route53.rb', line 44
def respond_all(*domain_and_challenges)
domain_and_challenges = apply_substitution_for_domain_and_challenges(domain_and_challenges)
save_original_records(*domain_and_challenges) if @restore_to_original_records
challenges_by_hosted_zone = domain_and_challenges.group_by { |(domain, _)| find_hosted_zone(domain) }
zone_and_batches = challenges_by_hosted_zone.map do |zone_id, dcs|
[
zone_id,
change_batch_for_challenges(
dcs,
action: 'UPSERT',
pre_changes: changes_to_delete_original_cname(zone_id, *dcs),
),
]
end
change_ids = request_changing_rrset(zone_and_batches, comment: 'for challenge response')
wait_for_sync(change_ids)
end
|
#support?(type) ⇒ Boolean
11
12
13
14
|
# File 'lib/acmesmith/challenge_responders/route53.rb', line 11
def support?(type)
type == 'dns-01'
end
|