Results 1 to 4 of 4

Thread: Modifying Cloudfront Template to Add Module, Stop, Then Restart Wowza Server

  1. #1
    nath2099 Guest

    Default Modifying Cloudfront Template to Add Module, Stop, Then Restart Wowza Server

    Hi,

    I'm using the following template to create a Cloudfront live stream distribution:

    {
        "AWSTemplateFormatVersion" : "2010-09-09",
    
        "Description" : "This template creates a CloudFormation stack that uses Amazon CloudFront and and Amazon EC2 AMI for Wowza Media Server 3 to deliver live streaming of your event. (Version: 2013-08-15)",
    
        "Parameters" : {
            "InstanceType" : {
                "Type"                  : "String",
                "Description"           : "The type of Amazon EC2 instance to launch. Valid values are: m1.small, m1.medium, m1.large, m1.xlarge, m2.xlarge, m2.2xlarge, m2.4xlarge, c1.medium, c1.xlarge.",
                "Default"               : "m1.small",
                "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."
            },
            "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"     : "http://XXX-DOMAIN-XXX/AWScloudfrontWowza.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"     : "XXX-KEY-XXX"
            },
            "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-7669141f" },
                "us-west-1"      : { "AMI" : "ami-f6b198b3" },
                "us-west-2"      : { "AMI" : "ami-f7ed7ec7" },
                "eu-west-1"      : { "AMI" : "ami-3d869b49" },
                "ap-southeast-1" : { "AMI" : "ami-867930d4" },
                "ap-northeast-1" : { "AMI" : "ami-fd0f9afc" },
                "ap-southeast-2" : { "AMI" : "ami-ef1e8dd5" },
                "sa-east-1"      : { "AMI" : "ami-ae2085b3" }
            }
        },
    
        "Resources" : {
            "LiveStreamingDistribution" : {
                "Type" : "AWS::CloudFront::Distribution",
                "Properties" : {
                   "DistributionConfig" : {
                       "CustomOrigin" : {
                           "DNSName"              : { "Fn::GetAtt" : [ "WowzaServerOriginServer", "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" }  ] ] }}
                }
            },
    
            "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"
            },
            "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"
            }
        }
    }

    I am currently SSH'ing into the instance, adding a module to /lib, then restarting the server. I am wondering if this is possible to do through this template. I know it was through the FMS template I used to use, but not knowing anything about Linux I don't really know where to start.

    Cheers,
    Nathan.

  2. #2
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    Nathan,

    I'm not exactly sure what you mean, but if you add a .jar file to the /lib folder Wowza does have to be restarted, and the usual way with a remote linux server is by connecting to the server using an SSH client.

    Richard

  3. #3
    nath2099 Guest

    Default

    Hi Richard, in the FMS Cloudfront Template is this code:

    "UserData" : { "Fn::Base64" : { "Fn::Join" : [ "", [
                              "#!/bin/bash",
                        "\n", "sed -i \"s/^SERVER.ADMIN_USERNAME.*=/SERVER.ADMIN_USERNAME = ", { "Ref" : "amsAdminUsername" },"/\" /opt/adobe/ams/conf/ams.ini",
                        "\n", "sed -i \"s/^SERVER.ADMINSERVER_HOSTPORT.*=/SERVER.ADMINSERVER_HOSTPORT = :1111/\" /opt/adobe/ams/conf/ams.ini",
                        "\n", "chown amsuser:amsgroup /opt/adobe/ams/conf/ams.ini",
                        "\n", "/opt/adobe/ams/amsmgr adminserver stop",
                        "\n", "echo \"", { "Ref" : "amsAdminPassword" },"\" | /opt/adobe/ams/amsadmin -console -user ", { "Ref" : "amsAdminUsername" },
                        "\n", "/opt/adobe/ams/amsmgr adminserver start",
                        "\n", "cat > /mnt/webroot/crossdomain.xml <<EOFF",
                        "\n", "<?xml version=\"1.0\"?>",
                        "\n", " <cross-domain-policy>",
                        "\n", " <site-control permitted-cross-domain-policies=\"master-only\" />",
                        "\n", " <allow-access-from domain=\"*\" />",
                        "\n", "</cross-domain-policy>",
                        "\n", "EOFF",
                        "\n", "chown amsuser:amsgroup /mnt/webroot/crossdomain.xml",
                        "\n", "/opt/adobe/ams/amsmgr server ams restart"
                      ] ] }}
    which looks to me like it stops the server, modifies the crossdomain policy file, then restarts the server.

    I am wondering if it's possible to stop the Wowza server, copy a file from either another domain or S3 to the lib folder, then restart the server... all from the template file.

    Does this make sense? It's to save me having to SSH into every instance I create to do it manually.

    Thanks,
    Nathan.
    Last edited by nath2099; 10-04-2013 at 04:06 PM.

  4. #4
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    Nathan,

    You can use a startup package with Wowza EC2 AMIs when you first start the instance. The package is used to configure Wowza during startup, and I think this the same as what you are showing for FMS.

    Take a look at the EC2 Quickstart Guide for more details on using a startup package (which is very simple)

    Richard

Similar Threads

  1. Start, stop, restart Wowza with PHP
    By kleelof in forum General Forum
    Replies: 2
    Last Post: 05-03-2014, 11:50 PM
  2. Replies: 1
    Last Post: 11-15-2012, 04:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •