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

How do I delete a CNAME record from Route53 with the Ruby SDK

我知道我需要使用 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 
          } 
        } 
      ] 
    }
  })

Returns:

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:在 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 级)中 define_operation_methods' 来自 (irb):62

似乎缺少 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 
      } 
    } 
  ] 
}
})