如何使用Ruby SDK从Route53中删除CNAME记录

时间:2016-07-19 09:24:08

标签: ruby amazon-web-services amazon-route53

我看到我需要使用change_resource_record_sets方法。但是我提供什么参数?有人有例子吗?

route53.change_resource_record_sets(
  { 
    hosted_zone_id: "/hostedzone/EXAMPLEID",
    change_batch: { 
      changes: [ 
        { 
          action: "DELETE", 
          resource_record_set: { 
            name: "r9i.staging.example.com.", 
            type: "CNAME", 
            resource_records: [ 
              { value: "other.example.io" } 
            ], 
            alias_target: nil 
          } 
        } 
      ] 
    }
  })

返回:

Aws::Route53::Errors::InvalidInput: Invalid request
from /Users/amir/.rvm/gems/ruby-2.2.1/gems/aws-sdk-core-
2.2.3/lib/seahorse/client/plugins/raise_response_errors.rb:15:in 
`call'
from /Users/amir/.rvm/gems/ruby-2.2.1/gems/aws-sdk-core-
2.2.3/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
from /Users/amir/.rvm/gems/ruby-2.2.1/gems/aws-sdk-core-
2.2.3/lib/seahorse/client/plugins/response_target.rb:21:in `call'
from /Users/amir/.rvm/gems/ruby-2.2.1/gems/aws-sdk-core-

2.2.3 / lib / seahorse / client / request.rb:70:in send_request' from /Users/amir/.rvm/gems/ruby-2.2.1/gems/aws-sdk-core- 2.2.3/lib/seahorse/client/base.rb:207:in块(2级)in     define_operation_methods'         来自(irb):62

1 个答案:

答案 0 :(得分:1)

看起来像是缺少TTL。以下为我工作。将TTL值替换为记录值。

require 'aws-sdk'
r53 = Aws::Route53::Client.new(region:'us-east-1')


r53.change_resource_record_sets(
  { 
hosted_zone_id: "/hostedzone/ZZZZZ",
change_batch: { 
  changes: [ 
    { 
      action: "DELETE", 
      resource_record_set: { 
        name: "r9i.staging.example.com.", 
        type: "CNAME", 
        ttl: 300,
        resource_records: [ 
          { value: "other.example.io" } 
        ], 
        alias_target: nil 
      } 
    } 
  ] 
}
})