This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.
MediaPackage examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with MediaPackage.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use create-channel.
- Amazon CLI
-
To create a channel
The following
create-channelcommand creates a channel namedsportschannelin the current account.aws mediapackage create-channel --idsportschannelOutput:
{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0", "HlsIngest": { "IngestEndpoints": [ { "Id": "6d345804ec3f46c9b454a91d4a80d0e0", "Password": "generatedwebdavpassword1", "Url": "https://f31c86aed53b815a.mediapackage.us-west-2.amazonaws.com/in/v2/6d345804ec3f46c9b454a91d4a80d0e0/6d345804ec3f46c9b454a91d4a80d0e0/channel", "Username": "generatedwebdavusername1" }, { "Id": "2daa32878af24803b24183727211b8ff", "Password": "generatedwebdavpassword2", "Url": "https://6ebbe7e04c4b0afa.mediapackage.us-west-2.amazonaws.com/in/v2/6d345804ec3f46c9b454a91d4a80d0e0/2daa32878af24803b24183727211b8ff/channel", "Username": "generatedwebdavusername2" } ] }, "Id": "sportschannel", "Tags": { "region": "west" } }For more information, see Creating a Channel
in the Amazon Elemental MediaPackage User Guide. -
For API details, see CreateChannel
in Amazon CLI Command Reference.
-
The following code example shows how to use create-origin-endpoint.
- Amazon CLI
-
To create an origin endpoint
The following
create-origin-endpointcommand creates an origin endpoint namedcmafsportswith the package settings provided in a JSON file and specified endpoint settings.aws mediapackage create-origin-endpoint \ --channel-idsportschannel\ --idcmafsports\ --cmaf-packagefile://file/path/cmafpkg.json--description"cmaf output of sports"\ --idcmaf_sports\ --manifest-namesports_channel\ --startover-window-seconds300\ --tagsregion=west,media=sports\ --time-delay-seconds10Output:
{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:origin_endpoints/1dc6718be36f4f34bb9cd86bc50925e6", "ChannelId": "sportschannel", "CmafPackage": { "HlsManifests": [ { "AdMarkers": "PASSTHROUGH", "Id": "cmaf_sports_endpoint", "IncludeIframeOnlyStream": true, "ManifestName": "index", "PlaylistType": "EVENT", "PlaylistWindowSeconds": 300, "ProgramDateTimeIntervalSeconds": 300, "Url": "https://c4af3793bf76b33c.mediapackage.us-west-2.amazonaws.com/out/v1/1dc6718be36f4f34bb9cd86bc50925e6/cmaf_sports_endpoint/index.m3u8" } ], "SegmentDurationSeconds": 2, "SegmentPrefix": "sportschannel" }, "Description": "cmaf output of sports", "Id": "cmaf_sports", "ManifestName": "sports_channel", "StartoverWindowSeconds": 300, "Tags": { "region": "west", "media": "sports" }, "TimeDelaySeconds": 10, "Url": "", "Whitelist": [] }For more information, see Creating an Endpoint
in the Amazon Elemental MediaPackage User Guide. -
For API details, see CreateOriginEndpoint
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-channel.
- Amazon CLI
-
To delete a channel
The following
delete-channelcommand deletes the channel namedtest.aws mediapackage delete-channel \ --idtestThis command produces no output.
For more information, see Deleting a Channel
in the Amazon Elemental MediaPackage User Guide. -
For API details, see DeleteChannel
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-origin-endpoint.
- Amazon CLI
-
To delete an origin endpoint
The following
delete-origin-endpointcommand deletes the origin endpoint namedtester2.aws mediapackage delete-origin-endpoint \ --idtester2For more information, see Deleting an Endpoint
in the Amazon Elemental MediaPackage User Guide. -
For API details, see DeleteOriginEndpoint
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-channel.
- Amazon CLI
-
To describe a channel
The following
describe-channelcommand displays all of the details of the channel namedtest.aws mediapackage describe-channel \ --idtestOutput:
{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:channels/584797f1740548c389a273585dd22a63", "HlsIngest": { "IngestEndpoints": [ { "Id": "584797f1740548c389a273585dd22a63", "Password": "webdavgeneratedpassword1", "Url": "https://9be9c4405c474882.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/584797f1740548c389a273585dd22a63/channel", "Username": "webdavgeneratedusername1" }, { "Id": "7d187c8616fd455f88aaa5a9fcf74442", "Password": "webdavgeneratedpassword2", "Url": "https://7bf454c57220328d.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/7d187c8616fd455f88aaa5a9fcf74442/channel", "Username": "webdavgeneratedusername2" } ] }, "Id": "test", "Tags": {} }For more information, see Viewing Channel Details<https://docs.aws.amazon.com/mediapackage/latest/ug/channels-view.html> in the Amazon Elemental MediaPackage User Guide
-
For API details, see DescribeChannel
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-origin-endpoint.
- Amazon CLI
-
To describe an origin endpoint
The following
describe-origin-endpointcommand displays all of the details of the origin endpoint namedcmaf_sports.aws mediapackage describe-origin-endpoint \ --idcmaf_sportsOutput:
{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:origin_endpoints/1dc6718be36f4f34bb9cd86bc50925e6", "ChannelId": "sportschannel", "CmafPackage": { "HlsManifests": [ { "AdMarkers": "NONE", "Id": "cmaf_sports_endpoint", "IncludeIframeOnlyStream": false, "PlaylistType": "EVENT", "PlaylistWindowSeconds": 60, "ProgramDateTimeIntervalSeconds": 0, "Url": "https://c4af3793bf76b33c.mediapackage.us-west-2.amazonaws.com/out/v1/1dc6718be36f4f34bb9cd86bc50925e6/cmaf_sports_endpoint/index.m3u8" } ], "SegmentDurationSeconds": 2, "SegmentPrefix": "sportschannel" }, "Id": "cmaf_sports", "ManifestName": "index", "StartoverWindowSeconds": 0, "Tags": { "region": "west", "media": "sports" }, "TimeDelaySeconds": 0, "Url": "", "Whitelist": [] }For more information, see Viewing a Single Endpoint
in the Amazon Elemental MediaPackage User Guide. -
For API details, see DescribeOriginEndpoint
in Amazon CLI Command Reference.
-
The following code example shows how to use list-channels.
- Amazon CLI
-
To list all channels
The following
list-channelscommand lists all of the channels that are configured on the current Amazon account.aws mediapackage list-channelsOutput:
{ "Channels": [ { "Arn": "arn:aws:mediapackage:us-west-2:111222333:channels/584797f1740548c389a273585dd22a63", "HlsIngest": { "IngestEndpoints": [ { "Id": "584797f1740548c389a273585dd22a63", "Password": "webdavgeneratedpassword1", "Url": "https://9be9c4405c474882.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/584797f1740548c389a273585dd22a63/channel", "Username": "webdavgeneratedusername1" }, { "Id": "7d187c8616fd455f88aaa5a9fcf74442", "Password": "webdavgeneratedpassword2", "Url": "https://7bf454c57220328d.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/7d187c8616fd455f88aaa5a9fcf74442/channel", "Username": "webdavgeneratedusername2" } ] }, "Id": "test", "Tags": {} } ] }For more information, see Viewing Channel Details
in the Amazon Elemental MediaPackage User Guide. -
For API details, see ListChannels
in Amazon CLI Command Reference.
-
The following code example shows how to use list-origin-endpoints.
- Amazon CLI
-
To list all origin-endpoints on a channel
The following
list-origin-endpointscommand lists all of the origin endpoints that are configured on the channel namedtest.aws mediapackage list-origin-endpoints \ --channel-idtestOutput:
{ "OriginEndpoints": [ { "Arn": "arn:aws:mediapackage:us-west-2:111222333:origin_endpoints/247cff871f2845d3805129be22f2c0a2", "ChannelId": "test", "DashPackage": { "ManifestLayout": "FULL", "ManifestWindowSeconds": 60, "MinBufferTimeSeconds": 30, "MinUpdatePeriodSeconds": 15, "PeriodTriggers": [], "Profile": "NONE", "SegmentDurationSeconds": 2, "SegmentTemplateFormat": "NUMBER_WITH_TIMELINE", "StreamSelection": { "MaxVideoBitsPerSecond": 2147483647, "MinVideoBitsPerSecond": 0, "StreamOrder": "ORIGINAL" }, "SuggestedPresentationDelaySeconds": 25 }, "Id": "tester2", "ManifestName": "index", "StartoverWindowSeconds": 0, "Tags": {}, "TimeDelaySeconds": 0, "Url": "https://8343f7014c0ea438.mediapackage.us-west-2.amazonaws.com/out/v1/247cff871f2845d3805129be22f2c0a2/index.mpd", "Whitelist": [] }, { "Arn": "arn:aws:mediapackage:us-west-2:111222333:origin_endpoints/869e237f851549e9bcf10e3bc2830839", "ChannelId": "test", "HlsPackage": { "AdMarkers": "NONE", "IncludeIframeOnlyStream": false, "PlaylistType": "EVENT", "PlaylistWindowSeconds": 60, "ProgramDateTimeIntervalSeconds": 0, "SegmentDurationSeconds": 6, "StreamSelection": { "MaxVideoBitsPerSecond": 2147483647, "MinVideoBitsPerSecond": 0, "StreamOrder": "ORIGINAL" }, "UseAudioRenditionGroup": false }, "Id": "tester", "ManifestName": "index", "StartoverWindowSeconds": 0, "Tags": {}, "TimeDelaySeconds": 0, "Url": "https://8343f7014c0ea438.mediapackage.us-west-2.amazonaws.com/out/v1/869e237f851549e9bcf10e3bc2830839/index.m3u8", "Whitelist": [] } ] }For more information, see Viewing all Endpoints Associated with a Channel
in the Amazon Elemental MediaPackage User Guide. -
For API details, see ListOriginEndpoints
in Amazon CLI Command Reference.
-
The following code example shows how to use list-tags-for-resource.
- Amazon CLI
-
To list the tags assigned to a resource
The following
list-tags-for-resourcecommand lists the tags that are assigned to the specified resource.aws mediapackage list-tags-for-resource \ --resource-arnarn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0Output:
{ "Tags": { "region": "west" } }For more information, see Tagging Resources in Amazon Elemental MediaPackage
in the Amazon Elemental MediaPackage User Guide. -
For API details, see ListTagsForResource
in Amazon CLI Command Reference.
-
The following code example shows how to use rotate-ingest-endpoint-credentials.
- Amazon CLI
-
To rotate ingest credentials
The following
rotate-ingest-endpoint-credentialscommand rotates the WebDAV username and password for the specified ingest endpoint.aws mediapackage rotate-ingest-endpoint-credentials \ --idtest\ --ingest-endpoint-id584797f1740548c389a273585dd22a63Output:
{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:channels/584797f1740548c389a273585dd22a63", "HlsIngest": { "IngestEndpoints": [ { "Id": "584797f1740548c389a273585dd22a63", "Password": "webdavregeneratedpassword1", "Url": "https://9be9c4405c474882.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/584797f1740548c389a273585dd22a63/channel", "Username": "webdavregeneratedusername1" }, { "Id": "7d187c8616fd455f88aaa5a9fcf74442", "Password": "webdavgeneratedpassword2", "Url": "https://7bf454c57220328d.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/7d187c8616fd455f88aaa5a9fcf74442/channel", "Username": "webdavgeneratedusername2" } ] }, "Id": "test", "Tags": {} }For more information, see Rotating Credentials on an Input URL
in the Amazon Elemental MediaPackage User Guide. -
For API details, see RotateIngestEndpointCredentials
in Amazon CLI Command Reference.
-
The following code example shows how to use tag-resource.
- Amazon CLI
-
To add a tag to a resource
The following
tag-resourcecommands adds aregion=westkey and value pair to the specified resource.aws mediapackage tag-resource \ --resource-arnarn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0\ --tagsregion=westThis command produces no output.
For more information, see Tagging Resources in Amazon Elemental MediaPackage
in the Amazon Elemental MediaPackage User Guide. -
For API details, see TagResource
in Amazon CLI Command Reference.
-
The following code example shows how to use untag-resource.
- Amazon CLI
-
To remove a tag from a resource
The following
untag-resourcecommand removes the tag with the keyregionfrom the specified channel.aws mediapackage untag-resource \ --resource-arnarn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0\ --tag-keysregionFor more information, see Tagging Resources in Amazon Elemental MediaPackage
in the Amazon Elemental MediaPackage User Guide. -
For API details, see UntagResource
in Amazon CLI Command Reference.
-
The following code example shows how to use update-channel.
- Amazon CLI
-
To update a channel
The following
update-channelcommand updates the channel namedsportschannelto include the description24x7 sports.aws mediapackage update-channel \ --idsportschannel\ --description"24x7 sports"Output:
{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0", "Description": "24x7 sports", "HlsIngest": { "IngestEndpoints": [ { "Id": "6d345804ec3f46c9b454a91d4a80d0e0", "Password": "generatedwebdavpassword1", "Url": "https://f31c86aed53b815a.mediapackage.us-west-2.amazonaws.com/in/v2/6d345804ec3f46c9b454a91d4a80d0e0/6d345804ec3f46c9b454a91d4a80d0e0/channel", "Username": "generatedwebdavusername1" }, { "Id": "2daa32878af24803b24183727211b8ff", "Password": "generatedwebdavpassword2", "Url": "https://6ebbe7e04c4b0afa.mediapackage.us-west-2.amazonaws.com/in/v2/6d345804ec3f46c9b454a91d4a80d0e0/2daa32878af24803b24183727211b8ff/channel", "Username": "generatedwebdavusername2" } ] }, "Id": "sportschannel", "Tags": {} }For more information, see Editing a Channel
in the Amazon Elemental MediaPackage User Guide. -
For API details, see UpdateChannel
in Amazon CLI Command Reference.
-
The following code example shows how to use update-origin-endpoint.
- Amazon CLI
-
To update an origin endpoint
The following
update-origin-endpointcommand updates the origin endpoint namedcmaf_sports. It changes the time delay to0seconds.aws mediapackage update-origin-endpoint \ --idcmaf_sports\ --time-delay-seconds0Output:
{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:origin_endpoints/1dc6718be36f4f34bb9cd86bc50925e6", "ChannelId": "sportschannel", "CmafPackage": { "HlsManifests": [ { "AdMarkers": "NONE", "Id": "cmaf_sports_endpoint", "IncludeIframeOnlyStream": false, "PlaylistType": "EVENT", "PlaylistWindowSeconds": 60, "ProgramDateTimeIntervalSeconds": 0, "Url": "https://c4af3793bf76b33c.mediapackage.us-west-2.amazonaws.com/out/v1/1dc6718be36f4f34bb9cd86bc50925e6/cmaf_sports_endpoint/index.m3u8" } ], "SegmentDurationSeconds": 2, "SegmentPrefix": "sportschannel" }, "Id": "cmaf_sports", "ManifestName": "index", "StartoverWindowSeconds": 0, "Tags": { "region": "west", "media": "sports" }, "TimeDelaySeconds": 0, "Url": "", "Whitelist": [] }For more information, see Editing an Endpoint
in the Amazon Elemental MediaPackage User Guide. -
For API details, see UpdateOriginEndpoint
in Amazon CLI Command Reference.
-