1. Using aws cur with mediapackage

    TypeScript

    AWS Cost and Usage Report (CUR) provides comprehensive data about your AWS costs and usage. It's often used for analyzing and understanding your AWS spending. On the other hand, AWS MediaPackage is a service that makes it easy to prepare and protect your video for delivery over the Internet.

    While CUR and MediaPackage are both AWS services, they serve different purposes. CUR doesn't integrate directly with services at the operation level, instead, it provides data for the services you use. However, if you want to keep track of your MediaPackage costs, you can do so through the CUR by analyzing the costs associated with the MediaPackage.

    To use AWS MediaPackage with Pulumi, you would typically define resources for channels, origin endpoints, and other components necessary for video streaming.

    Below is a program written in TypeScript that demonstrates how you can set up an AWS MediaPackage channel using Pulumi. This doesn't integrate with CUR directly but shows how you would use Pulumi to define a MediaPackage resource.

    import * as aws from "@pulumi/aws"; import * as pulumi from "@pulumi/pulumi"; // Create an AWS MediaPackage Channel. // For more information, visit https://www.pulumi.com/registry/packages/aws/api-docs/mediapackage/channel/ const channel = new aws.mediapackage.Channel("myChannel", { channelId: "my-channel", description: "My MediaPackage Channel", }); // Typically, you would create an OriginEndpoint that points to this channel. // For more information, visit https://www.pulumi.com/registry/packages/aws/api-docs/mediapackage/originendpoint/ const originEndpoint = new aws.mediapackage.OriginEndpoint("myOriginEndpoint", { channelId: channel.id, // HLS (HTTP Live Streaming) specific configuration hlsPackage: { // Define how you want to deal with encryption encryption: { spekeKeyProvider: { roleArn: "arn:aws:iam::123456789012:role/SpekeKeyProviderRole", systemIds: ["system-id"], url: "https://key-provider-url" } }, segmentDurationSeconds: 5, }, startoverWindowSeconds: 86400, // How long the content is available for playback, in seconds, after it’s live. timeDelaySeconds: 30, // Time delay for the live content, in seconds. }); // Output the endpoints that can be used to access the live streaming content. export const hlsEndpointUrl = originEndpoint.hlsIngest.ingestEndpoints.apply(endpoints => endpoints[0].url);

    In this program:

    • A MediaPackage Channel is created using aws.mediapackage.Channel. This acts as an input to the MediaPackage workflow.
    • An OriginEndpoint (aws.mediapackage.OriginEndpoint) is defined and linked to the channel. This is the URL that audiences can use to watch the live stream. It's configured here for HLS (HTTP Live Streaming).
    • The HLS package configuration includes details on encryption with a SPEKE key provider, along with the stream segment duration.
    • We export the URL for the HLS endpoint, which can be used by clients to access the stream.

    Please note, this code assumes that you have the SPEKE key provider set up and accessible. The role ARN (arn:aws:iam::123456789012:role/SpekeKeyProviderRole) and key provider URL (https://key-provider-url) are just placeholders and you will need to replace them with your actual service details.

    To analyze costs through CUR reports, you will want to use AWS Cost Exploration tools or AWS Budgets to create reports and alarms based on the data provided by CUR. Costs related to MediaPackage can then be analyzed for patterns like usage peaks, and you could possibly identify cost-saving opportunities.