{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "This template uses Amazon Cloudfront, Wowza Media Server on EC2 and an aiCache EC2 Instance to create a CloudFormation stack for HTTP streaming of your live event.", "Parameters": { "InstanceType": { "Type": "String", "Description": "The type of Amazon EC2 instance to launch for Wowza. Valid values are: m1.small, m1.medium, m1.large, m1.xlarge, m2.xlarge, m2.2xlarge, m2.4xlarge, c1.medium, c1.xlarge.", "Default": "m1.large", "AllowedValues": [ "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge" ], "ConstraintDescription": "must be a valid Amazon EC2 instance type." }, "aiCacheInstanceType": { "Type": "String", "AllowedValues": [ "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge" ], "Description": "Type of EC2 instance to launch for aiCache - options in clude m1.large, m1.xlarge, m2.xlarge, m2.2xlarge, m2.4xlarge, and c1.xlarge", "Default": "m1.large", "ConstraintDescription": "must be a valid Amazon EC2 instance type." }, "KeyPair": { "Type": "String", "Description": "The name of an Amazon EC2 key pair in the region where you are creating the CloudFormation stack." }, "StartupPackageURL": { "Type": "String", "Description": "The startup package to use for the Wowza Media Server configuration. Default value is a CloudFront delivery startup package.", "Default": "https://s3.amazonaws.com/wowzamediasystems/com/wowza/startup/3.6.0/cloudfront.zip" }, "WowzaLicenseKey": { "Type": "String", "Description": "The Wowza Media Server 3 license key(s) (pipe '|' separated if multiple keys such as Wowza Transcoder).", "MinLength": "0", "MaxLength": "200", "Default": "" }, "ApplicationName": { "Type": "String", "Description": "The Wowza Media Server application name (no spaces allowed). If you are not using a custom application, do not change this value.", "Default": "livecf" }, "StreamName": { "Type": "String", "Description": "The Wowza Media Server stream name (no spaces allowed). Default value is myStream.", "Default": "myStream" } }, "Mappings": { "RegionMap": { "us-east-1": { "AMI": "ami-fd195494" }, "us-west-1": { "AMI": "ami-72f2d837" }, "us-west-2": { "AMI": "ami-18f26e28" }, "eu-west-1": { "AMI": "ami-b7b0abc3" }, "ap-southeast-1": { "AMI": "ami-fa1d56a8" }, "ap-northeast-1": { "AMI": "ami-75900274" }, "sa-east-1": { "AMI": "ami-e904a0f4" } }, "aiCacheRegionMap": { "us-east-1": { "AMI": "ami-9b35e0f2" }, "ap-southeast-1": { "AMI": "ami-ccfdb89e" }, "ap-northeast-1": { "AMI": "ami-ecb204ed" }, "us-west-1": { "AMI": "ami-dfd08e9a" }, "eu-west-1": { "AMI": "ami-1d88b769" } } }, "Resources": { "LiveStreamingDistribution": { "Type": "AWS::CloudFront::Distribution", "Properties": { "DistributionConfig": { "CustomOrigin": { "DNSName": { "Fn::GetAtt": [ "aiCacheEc2Instance", "PublicDnsName" ] }, "HTTPPort": "80", "HTTPSPort": "443", "OriginProtocolPolicy": "http-only" }, "Enabled": "true", "Comment": "Live HTTP Streaming" } } }, "WowzaServerOriginServer": { "Type": "AWS::EC2::Instance", "Properties": { "SecurityGroups": [ { "Ref": "WowzaServerOriginServerSecurityGroup" } ], "KeyName": { "Ref": "KeyPair" }, "ImageId": { "Fn::FindInMap": [ "RegionMap", { "Ref": "AWS::Region" }, "AMI" ] }, "InstanceType": { "Ref": "InstanceType" }, "UserData": { "Fn::Base64": { "Fn::Join": [ "", [ "WZA_startupPackageURL=", { "Ref": "StartupPackageURL" }, ",", "WZA_wowzaServerLicenseKey=", { "Ref": "WowzaLicenseKey" } ] ] } } } }, "aiCacheEc2Instance": { "Type": "AWS::EC2::Instance", "Properties": { "SecurityGroups": [ { "Ref": "aiCacheInstanceSecurityGroup" } ], "KeyName": { "Ref": "KeyPair" }, "ImageId": { "Fn::FindInMap": [ "aiCacheRegionMap", { "Ref": "AWS::Region" }, "AMI" ] }, "InstanceType": { "Ref": "aiCacheInstanceType" }, "UserData": { "Fn::Base64": { "Fn::Join": [ "", [ "#!/bin/bash", "\n", "cp /root/aicache.cfg.tpl /root/aicache.cfg", "\n", "sed -i 's/hostname example.com/hostname ./' /root/aicache.cfg", "\n", "sed -i 's/cname EC2_PUBLIC_HOSTNAME/wildcard ./' /root/aicache.cfg", "\n", "sed -i 's/^healthcheck/#healthcheck/' /root/aicache.cfg", "\n", "sed -i 's/^pattern/#pattern/' /root/aicache.cfg", "\n", "sed -i 's/origin 74.125.67.100/origin ", { "Fn::GetAtt": [ "WowzaServerOriginServer", "PublicIp" ] }, "/' /root/aicache.cfg", "\n" ] ] } } } }, "aiCacheInstanceSecurityGroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "GroupDescription": "Security group for aiCache used for live strea ming using Amazon CloudFront", "SecurityGroupIngress": [ { "IpProtocol": "tcp", "FromPort": "80", "ToPort": "80", "CidrIp": "0.0.0.0/0" }, { "IpProtocol": "tcp", "FromPort": "22", "ToPort": "22", "CidrIp": "0.0.0.0/0" } ] } }, "WowzaServerOriginServerSecurityGroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "GroupDescription": "Security group for live HTTP streaming using Amazon CloudFront", "SecurityGroupIngress": [ { "IpProtocol": "tcp", "FromPort": "21", "ToPort": "21", "CidrIp": "0.0.0.0/0" }, { "IpProtocol": "tcp", "FromPort": "22", "ToPort": "22", "CidrIp": "0.0.0.0/0" }, { "IpProtocol": "tcp", "FromPort": "80", "ToPort": "80", "CidrIp": "0.0.0.0/0" }, { "IpProtocol": "tcp", "FromPort": "443", "ToPort": "443", "CidrIp": "0.0.0.0/0" }, { "IpProtocol": "tcp", "FromPort": "554", "ToPort": "554", "CidrIp": "0.0.0.0/0" }, { "IpProtocol": "tcp", "FromPort": "1935", "ToPort": "1935", "CidrIp": "0.0.0.0/0" }, { "IpProtocol": "tcp", "FromPort": "8084", "ToPort": "8086", "CidrIp": "0.0.0.0/0" }, { "IpProtocol": "udp", "FromPort": "0", "ToPort": "65535", "CidrIp": "0.0.0.0/0" } ] } } }, "Outputs": { "PublishRTMPURL": { "Value": { "Fn::Join": [ "", [ "rtmp://", { "Fn::GetAtt": [ "WowzaServerOriginServer", "PublicDnsName" ] }, "/", { "Ref": "ApplicationName" } ] ] }, "Description": "RTMP Publish URL" }, "PublishStreamName": { "Value": { "Ref": "StreamName" }, "Description": "RTMP Publish Stream Name" }, "PlaybackHLSURL": { "Value": { "Fn::Join": [ "", [ "http://", { "Fn::GetAtt": [ "LiveStreamingDistribution", "DomainName" ] }, "/", { "Ref": "ApplicationName" }, "/", { "Ref": "StreamName" }, "/playlist.m3u8" ] ] }, "Description": "Apple HLS Playback URL" }, "PlaybackHDSURL": { "Value": { "Fn::Join": [ "", [ "http://", { "Fn::GetAtt": [ "LiveStreamingDistribution", "DomainName" ] }, "/", { "Ref": "ApplicationName" }, "/", { "Ref": "StreamName" }, "/manifest.f4m" ] ] }, "Description": "Adobe HDS Playback URL" }, "PlaybackSmoothURL": { "Value": { "Fn::Join": [ "", [ "http://", { "Fn::GetAtt": [ "LiveStreamingDistribution", "DomainName" ] }, "/", { "Ref": "ApplicationName" }, "/", { "Ref": "StreamName" }, "/Manifest" ] ] }, "Description": "Microsoft Smooth Streaming Playback URL" }, "CloudFrontDomainName": { "Value": { "Fn::GetAtt": [ "LiveStreamingDistribution", "DomainName" ] }, "Description": "CloudFront Domain Name" }, "WowzaServerDomainName": { "Value": { "Fn::GetAtt": [ "WowzaServerOriginServer", "PublicDnsName" ] }, "Description": "Wowza Media Server Domain Name" }, "aiCacheServerDomainName": { "Value": { "Fn::GetAtt": [ "aiCacheEc2Instance", "PublicDnsName" ] }, "Description": "aiCache Server Domain Name" }, "WowzaServerStreamManagerURL": { "Value": { "Fn::Join": [ "", [ "http://", { "Fn::GetAtt": [ "WowzaServerOriginServer", "PublicDnsName" ] }, ":8086/streammanager" ] ] }, "Description": "Wowza Media Server Stream Manager URL" }, "WowzaServerStreamFTPURL": { "Value": { "Fn::Join": [ "", [ "ftp://", { "Fn::GetAtt": [ "WowzaServerOriginServer", "PublicDnsName" ] } ] ] }, "Description": "Wowza Media Server FTP Server URL" }, "WowzaServerLoginInfo": { "Value": { "Fn::Join": [ "", [ "username=wowza, password=", { "Ref": "WowzaServerOriginServer" } ] ] }, "Description": "Wowza Media Server login information for Stream Manager and FTP access" } } }