Skip to content

Instantly share code, notes, and snippets.

@estahn
Created May 15, 2017 03:48
Show Gist options
  • Save estahn/0d978e0add4feb7837bf36a7d835942f to your computer and use it in GitHub Desktop.
Save estahn/0d978e0add4feb7837bf36a7d835942f to your computer and use it in GitHub Desktop.
var handler = require('lambda-formation').resource.create;
var util = require('lambda-formation').util;
var aws = require("aws-sdk");
/**
* Creates a Hosted Zone and supports delegation sets
*
* Type: "AWS::Route53::HostedZone"
* Properties:
* DelegationSetId: <Your delegation set id>
* HostedZoneConfig:
* HostedZoneConfig
* HostedZoneTags:
* - HostedZoneTags
* Name: String
* VPCs:
* - HostedZoneVPCs
*
* @param err
* @param event
* @param context
* @see http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Route53.html#createHostedZone-property
*/
var create = function (err, event, context) {
if (err) {
return util.done(err);
}
var route53 = new aws.Route53();
var params = event.ResourceProperties;
params.CallerReference = event.ResourceProperties.Name;
if (event.ResourceProperties.DelegationSetId) {
params.DelegationSetId = event.ResourceProperties.DelegationSetId;
}
route53.createHostedZone(params, function(err, data) {
if (err) {
return util.done(err, event, context, {}, 'ID');
}
return util.done(null, event, context, data, data.Id);
});
};
/* Do not change this function */
module.exports.handler = function (event, context) {
handler.apply(this, [event, context, create]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment