in lambda/R53Associate.py [0:0]
def handler(event, context):
logger.info(
"custom resource triggered by {} request type: {}".format(event.get("StackId"), event.get("RequestType"))
)
logger.info("custom resource invoked with these properties: {}".format(event.get("ResourceProperties")))
# Get the variables from the Custom Resource
properties = event.get("ResourceProperties")
vpc_id = properties.get("VPCID")
phz_id = properties.get("HostedZoneID")
account_id = properties.get("AccountID")
RoleArn = properties.get("RoleARN")
# Run the function depending on Request Type
request_type = event["RequestType"]
if request_type == "Create":
return authenticate_and_associate_vpc_to_hosted_zone(vpc_id, phz_id, account_id, RoleArn)
if request_type == "Update":
return authenticate_and_associate_vpc_to_hosted_zone(vpc_id, phz_id, account_id, RoleArn)
if request_type == "Delete":
return disassociate_vpc_from_hosted_zone(vpc_id, phz_id)
raise Exception("Invalid request type: %s" % request_type)