Skip to content

AWS setup route53 via aws sdk nodejs

Chakradhar Rao Jonagam edited this page Apr 22, 2016 · 3 revisions
npm install aws-sdk --save
export AWS_ACCESS_KEY_ID='ACCESSKEYID'
export AWS_SECRET_ACCESS_KEY='SECRETACCESSKEY'
touch create.js
var AWS = require('aws-sdk');
//AWS.config.region = 'us-west-2';
var route53 = new AWS.Route53();
var params = {
  ChangeBatch: { 
    Changes: [ 
      {
        Action: 'UPSERT', 
        ResourceRecordSet: { 
          Name: '*.openshift.ck.osecloud.com', 
          Type: 'A',
          TTL: 600,
          ResourceRecords: [
            {
              Value: '130.211.187.179'
            }
          ]
        }
      },
      {
        Action: 'UPSERT',
        ResourceRecordSet: {
          Name: 'openshift.ck.osecloud.com',
          Type: 'A',
          TTL: 600,
          ResourceRecords: [
            {
              Value: '130.211.187.179'
            }
          ]
        }
      }
    ],
    Comment: 'OSE'
  },
  HostedZoneId: 'DUMMYZONEID'
};
route53.changeResourceRecordSets(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});
Clone this wiki locally