1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JavaScriptでドメインの自動更新設定をする(AWS SDKのRoute53Domainsを使ってみるpart.2)

Posted at

よく見るとSDKドキュメントまんま書いてるだけじゃねーか企画その2。

Route53DomainsのregisterDomainでautorenew(自動更新)の設定ができるのは前回記事で紹介しましたが、これだけだとドメインを解約したいときに困りますよね。

ということで自動更新の設定を有効にしたり無効化したりします。

使う処理

http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Route53Domains.html#enableDomainAutoRenew-property
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Route53Domains.html#disableDomainAutoRenew-property

コード

せっかくなのでモジュールにしてみた。

autorenew.js
var AWS = require('aws-sdk');

exports.autorenew = function ( domain, isAutoRenew ) {
	var config = conf.getConf();
	var route53domains = new AWS.Route53Domains({
		apiVersion: '2014-05-15',
        accessKeyId: "YOUR_AWS_ACCESS_KEY_ID",
        secretAccessKey: "YOUR_AWS_SECRET_ACCESS_KEY",
        region: "REGION" #省くと怒られる。(いらないはずだけど
	});
	var params = {
	  DomainName: domain
	};

	if ( isAutoRenew  ) {
		route53domains.enableDomainAutoRenew(params, function(err, data) {
		  if (err) console.log(err, err.stack); // an error occurred
		  else     console.log(data);           // successful response
		});
	} else {
		route53domains.disableDomainAutoRenew(params, function(err, data) {
		  if (err) console.log(err, err.stack); // an error occurred
		  else     console.log(data);           // successful response
		});
	}
};

使い方

var domainRenew = require('./autorenew.js');
var domain = 'EXAMPLE.com';
var isAutoRenew = true;
domainRenew.autorenew( domain, isAutoRenew );

isAutoRenewをtrueにすると自動更新が有効化されます。
もう更新しなくていいって場合はfalseにしておけばいいかなと。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?