in cloudformation/mediapackage_speke_endpoint.py [0:0]
def create_endpoint(mediapackage, event, context, auto_id=True):
"""
Create a MediaPackage channel
Return the channel URL, username and password generated by MediaPackage
"""
if auto_id:
endpoint_id = "%s-%s" % (resource_tools.stack_name(event), event["LogicalResourceId"])
else:
endpoint_id = event["PhysicalResourceId"]
channel_id = event["ResourceProperties"]["ChannelId"]
rotation_interval = event["ResourceProperties"]["RotationInterval"]
role_arn = event["ResourceProperties"]["RoleArn"]
server_url = event["ResourceProperties"]["ServerUrl"]
try:
response = mediapackage.create_origin_endpoint(
Id=endpoint_id,
Description="CloudFormation Stack ID %s" % event["StackId"],
ChannelId=channel_id,
ManifestName="index",
StartoverWindowSeconds=0,
HlsPackage={
"SegmentDurationSeconds": 6,
"PlaylistWindowSeconds": 60,
"PlaylistType": "event",
"AdMarkers": "none",
"IncludeIframeOnlyStream": True,
"UseAudioRenditionGroup": True,
"StreamSelection": {
"StreamOrder": "original"
},
"Encryption": {
"EncryptionMethod": "AES_128",
"KeyRotationIntervalSeconds": int(rotation_interval),
"RepeatExtXKey": False,
"SpekeKeyProvider": {
"ResourceId": str(uuid.uuid4()),
"RoleArn": role_arn,
"SystemIds": ["81376844-f976-481e-a84e-cc25d39b0b33"],
"Url": server_url
}
}
})
print(json.dumps(response))
outputs = {"OriginEndpointUrl": response['Url']}
result = {'Status': 'SUCCESS', 'Data': outputs, 'ResourceId': endpoint_id}
except Exception as ex:
print(ex)
result = {'Status': 'FAILED', 'Data': {"Exception": str(ex)}, 'ResourceId': endpoint_id}
return result