Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaPackage: speke 2 configuration error #26207

Open
lightglitch opened this issue Jul 3, 2023 · 6 comments
Open

MediaPackage: speke 2 configuration error #26207

lightglitch opened this issue Jul 3, 2023 · 6 comments
Labels
@aws-cdk/aws-mediapackage Related to AWS MediaPackage bug This issue is a bug. effort/small Small work item – less than a day of effort needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p3

Comments

@lightglitch
Copy link

lightglitch commented Jul 3, 2023

Describe the bug

The speke 2 configuration "EncryptionContractConfiguration" is not correctly converted to the cloud formation template, giving an error when deploying.

Expected Behavior

The cf template should include the speke 2 configurations and the deploy show set speke 2 configuration.

Current Behavior

When generating a cmaf or dash mediapackage with the following information:

              spekeKeyProvider: {
                  roleArn: "arn",
                  systemIds: "xxxxxxxxxxx",
                  url: "https://xxx.xx",
                  resourceId: `resource-cmaf`,
                  encryptionContractConfiguration: {
                      presetSpeke20Audio: "PRESET-AUDIO-1",
                      presetSpeke20Video: "PRESET-VIDEO-1",
                  },
              },

the generated cloudformation template doesn't include the preset information:

      "SpekeKeyProvider": {
       "EncryptionContractConfiguration": {},
       "ResourceId": "resource-xxxx",
       "RoleArn": {
        "Fn::ImportValue": "role"
       },
       "SystemIds": [
        "xxxxx"
       ],

And when we deploy we get the following error:

Resource handler returned message: "Model validation failed (#: #: only 1 subschema matches out of 2)
#/CmafPackage/Encryption/SpekeKeyProvider/EncryptionContractConfiguration: 2 schema violations found (#/CmafPackage/Encryption/SpekeKeyProvider/EncryptionContractConfiguration)" (RequestToken: a53b01e3-b50a-3ce3-4cd8-6550561eda09, HandlerErrorCode: InvalidRequest)

Reproduction Steps

Just create a media package endpoint with speke 2 configurations and check the generated cf template.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.86.0 (build 1130fab)

Framework Version

2.86

Node.js Version

v18.16.0

OS

windows 11

Language

Typescript

Language Version

5.1.6

Other information

No response

@lightglitch lightglitch added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 3, 2023
@github-actions github-actions bot added the @aws-cdk/aws-mediapackage Related to AWS MediaPackage label Jul 3, 2023
@pahud
Copy link
Contributor

pahud commented Jul 3, 2023

Looks like you are using the aws_mediapackage L1 constructs.

Can you share a minimal working sample that I can copy/paste to reproduce this issue in my account?

@pahud pahud added needs-reproduction This issue needs reproduction. p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jul 3, 2023
@lightglitch
Copy link
Author

Here you have it:

new MediaPackageTest(app, "test-channel-1", {
    project: "project",
    channelName: "ch-1",
    env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION || "eu-west-1" },
})

import * as cdk from "aws-cdk-lib"
import { Construct, DependencyGroup } from "constructs"
import * as mediapackage from "aws-cdk-lib/aws-mediapackage"

export class MediaPackageTest extends cdk.Stack {

    constructor(scope?: Construct, id?: string, props?: {
        env: { region: any; account: any };
        project: string;
        channelName: string;
    }) {
        super(scope, id, props)

        const mpChannel = new mediapackage.CfnChannel(this, (id = `${props!.project}-mp-${props!.channelName}`), {
            id: `${props!.project}-mp-${props!.channelName}`,
            description: `Media Package channel for ${props!.channelName}`,
        })

        const cmafPackage: mediapackage.CfnOriginEndpoint.CmafPackageProperty = {
            segmentDurationSeconds: 6,

            encryption: {
                spekeKeyProvider: {
                    roleArn: "testRole",
                    systemIds: ["94ce86fb-07ff-4f43-adb8-93d2fa968ca2"],
                    url: "https://localhost",
                    resourceId: `${props!.project}-${props!.channelName}-cmaf-20230703`,
                    encryptionContractConfiguration: {
                        presetSpeke20Audio: "PRESET-AUDIO-1",
                        presetSpeke20Video: "PRESET-VIDEO-1",
                    },
                },
                keyRotationIntervalSeconds: 0,
            },
            streamSelection: {
                minVideoBitsPerSecond: 0,
                maxVideoBitsPerSecond: 2147483647,
                streamOrder: "ORIGINAL",
            },
            hlsManifests: [
                {
                    id: "hls_id",
                    url: "https://localhost",
                    playlistWindowSeconds: 7200,
                    programDateTimeIntervalSeconds: 6,
                },
            ],
        }

        const cmaf_endpoint = new mediapackage.CfnOriginEndpoint(
            this,
            (id = `cmaf-endpoint-${props!.channelName}-20230703`),
            {
                channelId: mpChannel.id,
                id: `cmaf-endpoint-${props!.channelName}-20230703`,
                cmafPackage,
                manifestName: "cmaf",
                startoverWindowSeconds: 1209600,
                description: `CMAF Endpoint for ${props!.channelName}`,
            },
        )

        cmaf_endpoint.addDependency(mpChannel)
    }
}

@peterwoodworth
Copy link
Contributor

This is occurring because it's misdefined in the Cloudformation Spec file - search here for the property definition and you'll see: https://d1uauaxba7bl26.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json

You can work around this by manually overriding the property with an escape hatch

@peterwoodworth peterwoodworth added @aws-cdk/cfnspec effort/small Small work item – less than a day of effort and removed needs-reproduction This issue needs reproduction. effort/medium Medium work item – several days of effort labels Jul 4, 2023
@lightglitch
Copy link
Author

@peterwoodworth can you clarify how can I override the property with an example? I can't find any documentation to guide me.

@peterwoodworth
Copy link
Contributor

Sure @lightglitch, view this page to see how to override the template. Here, it will look something like this:

cmaf_endpoint.addPropertyOverride('CmafPackage.Encryption.SpekeKeyProvider.EncryptionContractConfiguration.PresetSpeke20Audio', 'PRESET-AUDIO-1');

After doing this synth and check your template and this property should now be filled out with PRESET-AUDIO-1

@peterwoodworth peterwoodworth added p2 needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. and removed needs-review p1 @aws-cdk/cfnspec labels Jul 12, 2023
@peterwoodworth
Copy link
Contributor

Reported this internally P94116434

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-mediapackage Related to AWS MediaPackage bug This issue is a bug. effort/small Small work item – less than a day of effort needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p3
Projects
None yet
Development

No branches or pull requests

3 participants