diff --git a/lib/route53.rb b/lib/route53.rb index 63bc02f..6102c10 100644 --- a/lib/route53.rb +++ b/lib/route53.rb @@ -372,6 +372,8 @@ def update(name,type,ttl,values,comment=nil, zone_apex = nil) @ttl = ttl unless ttl.nil? @values = values unless values.nil? @zone_apex = zone_apex unless zone_apex.nil? + @zone_apex = nil unless @zone_apex + @zone.perform_actions([ {:action => "DELETE", :record => prev}, {:action => "CREATE", :record => self}, diff --git a/lib/route53/cli.rb b/lib/route53/cli.rb index 0668cb5..727d472 100644 --- a/lib/route53/cli.rb +++ b/lib/route53/cli.rb @@ -68,7 +68,7 @@ def parsed_options? opts.on('--weight [WEIGHT]', String, "Specify a Weight for a record") { |weight| @options.weight = weight } opts.on('--ident [IDENTIFIER]', String, "Specify a unique identifier for a record") { |ident| @options.ident = ident } opts.on('--values [VALUE1],[VALUE2],[VALUE3]', Array, "Specify one or multiple values for a record") { |value| @options.values = value } - opts.on('--zone-apex-id [ZONE_APEX_ID]', String, "Specify a zone apex if for the record") { |zone_apex| @options.zone_apex = zone_apex } + opts.on('--zone-apex-id [ZONE_APEX_ID]', String, "Specify a zone apex if for the record") { |zone_apex| @options.zone_apex = zone_apex || false } opts.on('-m', '--comment [COMMENT]', String, "Provide a comment for this operation") { |comment| @options.comment = comment } @@ -277,7 +277,11 @@ def change_record end records.each do |r| puts "Modifying Record #{r.name}" - resp = r.update(@options.name,@options.dnstype,@options.ttl,@options.values,comment=nil) + if !@options.zone_apex.nil? && !@options.zone_apex && @options.ttl.nil? + $stderr.puts "ERROR: must provide --ttl if --zone_apex is set to empty string" + exit 1 + end + resp = r.update(@options.name,@options.dnstype,@options.ttl,@options.values,@options.comment,@options.zone_apex) pending_wait(resp) puts "Record Modified." unless resp.error? end