Class: Shards::Dns
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#aws_route53_resp ⇒ Object
Returns the value of attribute aws_route53_resp.
-
#begin_comment ⇒ Object
readonly
Returns the value of attribute begin_comment.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#r53 ⇒ Object
Returns the value of attribute r53.
- #resource_records ⇒ Object
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Base
Attributes included from Meta
Instance Method Summary collapse
- #delete ⇒ Object
- #exist? ⇒ Boolean
- #host_param ⇒ Object
- #include_target? ⇒ Boolean
-
#initialize(stage:, domain: nil) ⇒ Dns
constructor
A new instance of Dns.
- #record_data ⇒ Object
- #record_list ⇒ Object
- #record_sets ⇒ Object
- #set(dryrun: true) ⇒ Object
- #set_aws_route53_record ⇒ Object
Methods inherited from Base
#default_region, method_list, #set_config
Methods included from Meta
#add, #custom_yaml, #default_yaml, #get_config, #method_list, #output, #print_output, #proxy, #proxy_user, #reset_output, #run, #ssh_conn, #test_env?, #write_extra_config_dirs, #yaml_file
Constructor Details
#initialize(stage:, domain: nil) ⇒ Dns
Returns a new instance of Dns.
16 17 18 19 20 21 22 23 24 |
# File 'lib/shards/dns.rb', line 16 def initialize stage:, domain: nil set_config @stage=stage @domain=domain.downcase if domain reset_output @r53 = Aws::Route53::Client.new( region: default_region ) @ttl=300 @type='CNAME' end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
12 13 14 |
# File 'lib/shards/dns.rb', line 12 def action @action end |
#aws_route53_resp ⇒ Object
Returns the value of attribute aws_route53_resp.
13 14 15 |
# File 'lib/shards/dns.rb', line 13 def aws_route53_resp @aws_route53_resp end |
#begin_comment ⇒ Object (readonly)
Returns the value of attribute begin_comment.
12 13 14 |
# File 'lib/shards/dns.rb', line 12 def begin_comment @begin_comment end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/shards/dns.rb', line 12 def domain @domain end |
#r53 ⇒ Object
Returns the value of attribute r53.
13 14 15 |
# File 'lib/shards/dns.rb', line 13 def r53 @r53 end |
#resource_records ⇒ Object
26 27 28 |
# File 'lib/shards/dns.rb', line 26 def resource_records @resource_records||= [ { value: target } ] end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
12 13 14 |
# File 'lib/shards/dns.rb', line 12 def stage @stage end |
#ttl ⇒ Object
Returns the value of attribute ttl.
13 14 15 |
# File 'lib/shards/dns.rb', line 13 def ttl @ttl end |
#type ⇒ Object
Returns the value of attribute type.
13 14 15 |
# File 'lib/shards/dns.rb', line 13 def type @type end |
Instance Method Details
#delete ⇒ Object
45 46 47 |
# File 'lib/shards/dns.rb', line 45 def delete @aws_route53_resp = r53.change_resource_record_sets r53delete end |
#exist? ⇒ Boolean
49 50 51 |
# File 'lib/shards/dns.rb', line 49 def exist? !record_list.empty? end |
#host_param ⇒ Object
74 75 76 |
# File 'lib/shards/dns.rb', line 74 def host_param subdomain_param || host end |
#include_target? ⇒ Boolean
58 59 60 |
# File 'lib/shards/dns.rb', line 58 def include_target? exist? and record_data[:resource_records].include?( { value: target} ) end |
#record_data ⇒ Object
53 54 55 56 |
# File 'lib/shards/dns.rb', line 53 def record_data data=record_list.first || {} data.to_h end |
#record_list ⇒ Object
62 63 64 |
# File 'lib/shards/dns.rb', line 62 def record_list record_sets.select { |x| x.name.include? host_param } end |
#record_sets ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/shards/dns.rb', line 66 def record_sets r53.list_resource_record_sets({ hosted_zone_id: zone, start_record_name: host_param, max_items: 20 }).resource_record_sets end |
#set(dryrun: true) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/shards/dns.rb', line 30 def set dryrun: true if dryrun else print_output set_aws_route53_record end print_output end |
#set_aws_route53_record ⇒ Object
41 42 43 |
# File 'lib/shards/dns.rb', line 41 def set_aws_route53_record @aws_route53_resp = r53.change_resource_record_sets r53upsert end |