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

EMPv2 SDK Harvest Job issue #6635

Open
1 task
kannansamynathan opened this issue Nov 6, 2024 · 4 comments
Open
1 task

EMPv2 SDK Harvest Job issue #6635

kannansamynathan opened this issue Nov 6, 2024 · 4 comments
Assignees
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p2 This is a standard priority issue

Comments

@kannansamynathan
Copy link

kannansamynathan commented Nov 6, 2024

Describe the bug

I am using the below package to create the harvest job. But facing error when executing the code from the lambda (Runtime: Node.js 20.x).

Package: @aws-sdk/client-mediapackagev2
version: "3.682.0"
Error: GetHarvestJobCommand is not a constructor

Typescript code snippet used.

import {
    MediaPackageV2Client,
    CreateHarvestJobCommand,
    CreateHarvestJobCommandOutput,
    GetHarvestJobResponse,
    GetHarvestJobCommand,
} from '@aws-sdk/client-mediapackagev2';

const mediapackageClient = new MediaPackageV2Client({ region: process.env.REGION });

const input = {
        ChannelGroupName: channelGroupName,
        ChannelName: channelName,
        OriginEndpointName: originEndpointName,
        Description: description,
        HarvestedManifests: {
            HlsManifests: [
                {
                    ManifestName: manifestName,
                },
            ],
        },
        ScheduleConfiguration: {
            StartTime: new Date(Number(start) * 1000),
            EndTime: new Date(Number(end) * 1000),
        },
        Destination: {
            S3Destination: {
                BucketName: bucket,
                DestinationPath: manifest,
            },
        },
        ClientToken: UUID,
        HarvestJobName: UUID,
    };

const createHarvestJobCommand = new CreateHarvestJobCommand(input);
const createHarvestResponse: CreateHarvestJobCommandOutput =
                await mediapackageClient.send(createHarvestJobCommand);

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

It should create harves job in EMPV2

Current Behavior

Throwing error 'GetHarvestJobCommand is not a constructor' , when using the Package: @aws-sdk/client-mediapackagev2
version: "3.682.0"

Reproduction Steps

Create the above code snippet in typescript and deploy that to a lambda with runtime Node.js 20.x - it will throw the error

Possible Solution

No response

Additional Information/Context

No response

SDK version used

3.682.0

Environment details (OS name and version, etc.)

Lambda: Runtime Node.js 20.x, Architecture x86_64

@kannansamynathan kannansamynathan added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 6, 2024
@aBurmeseDev aBurmeseDev self-assigned this Nov 6, 2024
@aBurmeseDev aBurmeseDev transferred this issue from aws/aws-sdk-js Nov 6, 2024
@aBurmeseDev
Copy link
Member

Hi @kannansamynathan - thanks for reaching out.

I'm not sure if the code you share is incomplete as it's not showing where you call GetHarvestJobCommand but here's how I modified your code and it works as expected.

import {
    MediaPackageV2Client,
    CreateHarvestJobCommand,
    CreateHarvestJobCommandOutput,
    GetHarvestJobCommand,
    GetHarvestJobCommandOutput,
} from '@aws-sdk/client-mediapackagev2';

const mediapackageClient = new MediaPackageV2Client({ region: process.env.REGION });

const input = {
    ChannelGroupName: channelGroupName,
    ChannelName: channelName,
    OriginEndpointName: originEndpointName,
    Description: description,
    HarvestedManifests: {
        HlsManifests: [
            {
                ManifestName: manifestName,
            },
        ],
    },
    ScheduleConfiguration: {
        StartTime: new Date(Number(start) * 1000),
        EndTime: new Date(Number(end) * 1000),
    },
    Destination: {
        S3Destination: {
            BucketName: bucket,
            DestinationPath: manifest,
        },
    },
    ClientToken: UUID,
    HarvestJobName: UUID,
};

const createHarvestJobCommand = new CreateHarvestJobCommand(input);
const createHarvestResponse: CreateHarvestJobCommandOutput =
    await mediapackageClient.send(createHarvestJobCommand);

// After creating the harvest job, you can retrieve its details using GetHarvestJobCommand
const getHarvestJobInput = {
    ChannelGroupName: channelGroupName,
    ChannelName: channelName,
    OriginEndpointName: originEndpointName,
    HarvestJobName: createHarvestResponse.HarvestJob.HarvestJobName,
};
const getHarvestJobCommand = new GetHarvestJobCommand(getHarvestJobInput);
const getHarvestJobResponse: GetHarvestJobCommandOutput = await mediapackageClient.send(getHarvestJobCommand);

Hope it helps!
Best,
John

@aBurmeseDev aBurmeseDev added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Nov 7, 2024
@kannansamynathan
Copy link
Author

Thanks John. I have used the exact same code - the issue I am facing is, when I try this code in my local connecting to AWS its working as expected - it is generating the harvest job and I was able to get the status as well. But when I deploy (via git pipeline) the same code to the lambda, then I am getting the error 'te.GetHarvestJobCommand is not a constructor'. (I tried disable minify as well - but getting the same error)

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Nov 8, 2024
@kuhe
Copy link
Contributor

kuhe commented Nov 11, 2024

Depending on how you deploy your code, the process may remove the AWS SDK packages to use the Lambda-provided copy. For example, the AWS CDK may do this (configurable).

In such cases, the version on Lambda is older than the latest version and may not have as many operations implemented.

@kannansamynathan
Copy link
Author

kannansamynathan commented Nov 12, 2024

Thanks Kuhe, It worked finally using the lamda layer and I was able to create the objects in the S3.

But now I am facing a different issue say, how to set the owner of the *.m3u8 objects in the S3?

In the previous version of EMP Params we had an optoin to set the rolearn in the S3Destination as shown below

const params = {
        EndTime: end,
        Id: UUID,
        OriginEndpointId: channel,
        S3Destination: {
            BucketName: bucket,
            ManifestKey: manifest,
            RoleArn: arn,
        },
        StartTime: start,
    };

mediapackage.createHarvestJob(params, function (err, data) {
        if (err) {...}...}`

But in the latest version I dont have that option to set in the S3Destination as shown below.

const input = {
    ChannelGroupName: channelGroupName,
    ChannelName: channelName,
    OriginEndpointName: originEndpointName,
    Description: description,
    HarvestedManifests: {
        HlsManifests: [
            {
                ManifestName: manifestName,
            },
        ],
    },
    ScheduleConfiguration: {
        StartTime: new Date(Number(start) * 1000),
        EndTime: new Date(Number(end) * 1000),
    },
    Destination: {
        S3Destination: {
            BucketName: bucket,
            DestinationPath: manifest,
        },
    },
    ClientToken: UUID,
    HarvestJobName: UUID,
};

As a result I am seeing weird S3 Object (*.m3u8) owner names - and when I try to read these objects in other lambdas getting access denied.

Any view/recommendation please share.

@kuhe kuhe added the needs-triage This issue or PR still needs to be triaged. label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants