Skip to content

Instantly share code, notes, and snippets.

@mmasashi
Last active November 28, 2021 00:41
Show Gist options
  • Save mmasashi/5005647 to your computer and use it in GitHub Desktop.
Save mmasashi/5005647 to your computer and use it in GitHub Desktop.
r53 = AWS::Route53.new(
:access_key_id => 'aws-key-id',
:secret_access_key => 'aws-secret-key')
response = r53.client.list_resource_record_sets(
:hosted_zone_id => "zone-id",
:start_record_name => 'xxx.example.com',
:start_record_type => 'CNAME'
)
puts response[:resource_record_sets].map{|r| r[:name]}
change1 = {
:action => 'CREATE',
:resource_record_set => {
:name => "sub-domain-name.example.com",
:type => "CNAME",
:ttl => 600,
:resource_records => [{:value => "example.com"}]
}}
change2 = {
:action => 'CREATE',
:resource_record_set => {
:name => "sub-domain-name.example.com",
:type => "A",
:ttl => 600,
:resource_records => [{:value => "XX.XX.XX.XX"}]
}}
r53.client.change_resource_record_sets({
:hosted_zone_id => '/hostedzone/XXXXXXXXXXXX',
:change_batch => {
:changes => [change1, change2]
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment