Created
May 15, 2017 03:48
-
-
Save estahn/0d978e0add4feb7837bf36a7d835942f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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