Last active
November 28, 2021 00:41
-
-
Save mmasashi/5005647 to your computer and use it in GitHub Desktop.
AWS SDK Route53 ruby sample. Register the new record sets. http://docs.aws.amazon.com/AWSRubySDK/latest/frames.html
http://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html#API_ChangeResourceRecordSets_Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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