Created
October 27, 2015 03:04
-
-
Save higebu/858a220b17282340b2eb to your computer and use it in GitHub Desktop.
NIFTY Cloud DNS CreateHostedZone in bash
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
#!/bin/bash | |
ZONE=<Zone name> | |
ACCESS_KEY_ID=<NIFTY Cloud Access Key ID> | |
SECRET_KEY=<NIFTY Cloud Secret Key> | |
ENDPOINT=https://dns.api.cloud.nifty.com/2012-12-12N2013-12-16/hostedzone | |
# Generate signature version 2 | |
datetime=$(LC_ALL=en TZ='GMT' date "+%a, %d %b %Y %H:%M:%S %Z") | |
signature=`echo -en "${datetime}" | openssl sha1 -hmac ${SECRET_KEY} -binary | base64` | |
# Create request body | |
body="<?xml version=\"1.0\" encoding=\"UTF-8\"?> | |
<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2012-12-12/\"> | |
<Name>${ZONE}</Name> | |
<CallerReference></CallerReference> | |
<HostedZoneConfig></HostedZoneConfig> | |
<Comment>Created by API.</Comment> | |
</CreateHostedZoneRequest>" | |
# Request CreateHostedZone | |
curl -X POST \ | |
-H "Date: ${datetime}" \ | |
-H "Host: dns.api.cloud.nifty.com" \ | |
-H "Content-Type: text/xml" \ | |
-H "X-Nifty-Authorization: NIFTY3-HTTPS NiftyAccessKeyId=${ACCESS_KEY_ID},Algorithm=HmacSHA1,Signature=${signature}" \ | |
-d "${body}" \ | |
${ENDPOINT} | |
# Request ListHostedZones | |
curl -X GET \ | |
-H "Date: ${datetime}" \ | |
-H "X-Nifty-Authorization: NIFTY3-HTTPS NiftyAccessKeyId=${ACCESS_KEY_ID},Algorithm=HmacSHA1,Signature=${signature}" \ | |
${ENDPOINT} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment