aws-cloudformation / cloudformation-coverage-roadmap

The AWS CloudFormation Public Coverage Roadmap
https://aws.amazon.com/cloudformation/
Creative Commons Attribution Share Alike 4.0 International
1.11k stars 56 forks source link

AWS::MediaPackage::OriginEndpoint - [Feature Request] Support for Url retrieval of CmafPackage based OriginEndpoint resources #767

Closed shalen-n closed 3 years ago

shalen-n commented 3 years ago

1. Title

[Feature Request] AWS::MediaPackage::OriginEndpoint - Support for Url retrieval of CmafPackage based OriginEndpoint resources

2. Scope of request

The "AWS::MediaPackage::OriginEndpoint" [1] CloudFormation resource supports the Url return value. Upon further investigation it seems that this only supports the retrieval of Urls for DASH and HLS based package OriginEndpoints and not CmafPackage based OriginEndpoint. Consequently, when attempting to return the Url for CmafPackage based OriginEndpoints via stack outputs, the result is an empty Url field.

3. Expected behavior

To return the Url associated with creating CmafPackage based "AWS::MediaPackage::OriginEndpoint" resources in CloudFormation via the Fn::GetAtt intrinsic function associated with this resource.

4. Suggest specific test cases

Test Case 1: For example the following template does not return a Url for the CmafPackage based OrginEndpoint:

AWSTemplateFormatVersion: 2010-09-09

Resources:
  HEVCMediaPackage:
    Type: AWS::MediaPackage::Channel
    Properties:
      Id: HEVC001
      Description: HEVC

  CmafOriginEndpoint:
    Type: AWS::MediaPackage::OriginEndpoint
    Properties:
      Id: CmafOriginEndpoint001
      ChannelId: !Ref HEVCMediaPackage
      Description: CmafOriginEndpoint
      Origination: ALLOW
      StartoverWindowSeconds: 0
      CmafPackage:
        HlsManifests:
          - Id: HlsManifests001
            IncludeIframeOnlyStream: false
            PlaylistWindowSeconds: 300
            ProgramDateTimeIntervalSeconds: 30
        SegmentDurationSeconds: 1
        SegmentPrefix: index
        StreamSelection:
          StreamOrder: ORIGINAL

Outputs:
  CmafOriginEndpoint:
    Value: !GetAtt CmafOriginEndpoint.Url

Test Case 2: The following template will return a Url for the DashPackage based OriginEndpoint

AWSTemplateFormatVersion: 2010-09-09

Resources:
  HEVCMediaPackage:
    Type: AWS::MediaPackage::Channel
    Properties:
      Id: HEVC001
      Description: HEVC

  DashOriginEndpoint:
    Type: AWS::MediaPackage::OriginEndpoint
    Properties:
      Id: CmafOriginEndpoint001
      ChannelId: !Ref HEVCMediaPackage
      Description: DashOriginEndpoint
      Origination: ALLOW
      StartoverWindowSeconds: 0
      DashPackage:
        ManifestLayout: COMPACT
        ManifestWindowSeconds: 200
        MinBufferTimeSeconds: 4
        MinUpdatePeriodSeconds: 4
        Profile: NONE
        SegmentDurationSeconds: 2
        SegmentTemplateFormat: NUMBER_WITH_DURATION
        StreamSelection:
          StreamOrder: ORIGINAL
        SuggestedPresentationDelaySeconds: 4

Outputs:
  DashOriginEndpoint:
    Value: !GetAtt DashOriginEndpoint.Url

5. Helpful Links to speed up research and evaluation

[1] AWS::MediaPackage::OriginEndpoint - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-mediapackage-originendpoint.html

6. Category (required) - Will help with tagging and be easier to find by other users to +1

  1. CloudFormation
  2. MediaPackage
jdub commented 3 years ago

@shalen-n kindly filed this on behalf of my support case, ID 7914332281. 😊

liyuanliu1991 commented 3 years ago

Hi,

The reason why we don't support url in cloudformation is because of we want to keep consistent with our MediaPackage API response. If you call describe_origin_endpoint in aws CLI, the url field is also empty. But you can get the value from the urlfield in HlsManifest section of the response. url will be ambiguous in the long term so that's why we only use it for HLS manifest URL. Due to the addition of hlsmanifests with CMAF, CMAF is different from HLS endpoints.

For getting the url of cmafPackage based on OriginEndpoint, what you can do is, create an aws lambda in the console or via cloudformation. In this lambda code, you can call MediaPackage API to describe the origin endpoint. In the API response, it will contain the url of cmafPackage. For example, if your lambda code is python, you can use Boto3 to call describe_origin_endpoint: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/mediapackage.html#MediaPackage.Client.describe_origin_endpoint In this response, you can find the url in the HlsManifest section of CmafPackage like following, but one thing worth noting is, the url in CmafPackage will be empty, you can only get the valid url from HlsManifests section:


            "Arn": "arn:aws:mediapackage:us-west-2:account_id:origin_endpoints/guid",
            "ChannelId": "channel_id",
            "CmafPackage": {
                "HlsManifests": [
                    {
                        "AdMarkers": "DATERANGE",
                        "Id": " endpoint_id ",
                        "IncludeIframeOnlyStream": true,
                        "PlaylistType": "EVENT",
                        "PlaylistWindowSeconds": 60,
                        "ProgramDateTimeIntervalSeconds": 6,
                        "Url": "https://egress.your_profile.babelfish-us-west-2.com/out/v1/guid/endpoint_id/index.m3u8"
                    }
                ],
                "SegmentDurationSeconds": 6,
                "SegmentPrefix": "cmaf",
                "StreamSelection": {
                    "MaxVideoBitsPerSecond": 2147483647,
                    "MinVideoBitsPerSecond": 0,
                    "StreamOrder": "ORIGINAL"
                }
            },
            "Id": "endpoint_id",
            "ManifestName": "index",
            "Origination": "ALLOW",
            "StartoverWindowSeconds": 0,
            "Tags": {},
            "TimeDelaySeconds": 0,
            "Url": "",
            "Whitelist": []
        }
jdub commented 3 years ago

@liyuanliu1991 I've had to write quite a few custom resources for Media* products… this is incredibly inconvenient for users of CloudFormation. Return values from CloudFormation don't always directly reflect the structure of the data in the API – solving this in the existing MediaPackage OriginEndpoint resource is possible.