使用 AWS CLI 的 MediaConnect 示例 - AWS Command Line Interface

本文档仅适用于 AWS CLI 版本 1。有关 AWS CLI 版本 2 的相关文档,请参阅版本 2 用户指南

使用 AWS CLI 的 MediaConnect 示例

以下代码示例演示了如何通过将 AWS Command Line Interface与 MediaConnect 结合使用,来执行操作和实现常见场景。

操作 是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以从中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例演示了如何使用 add-flow-outputs

AWS CLI

向流程中添加输出

以下 add-flow-outputs 示例向指定流程中添加输出。

aws mediaconnect add-flow-outputs \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --outputs Description='NYC stream',Destination=192.0.2.12,Name=NYC,Port=3333,Protocol=rtp-fec,SmoothingLatency=100 Description='LA stream',Destination=203.0.113.9,Name=LA,Port=4444,Protocol=rtp-fec,SmoothingLatency=100

输出:

{ "Outputs": [ { "Port": 3333, "OutputArn": "arn:aws:mediaconnect:us-east-1:111122223333:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC", "Name": "NYC", "Description": "NYC stream", "Destination": "192.0.2.12", "Transport": { "Protocol": "rtp-fec", "SmoothingLatency": 100 } }, { "Port": 4444, "OutputArn": "arn:aws:mediaconnect:us-east-1:111122223333:output:2-987655dEF67hiJ89-c34de5fG678h:LA", "Name": "LA", "Description": "LA stream", "Destination": "203.0.113.9", "Transport": { "Protocol": "rtp-fec", "SmoothingLatency": 100 } } ], "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame" }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的向流程中添加输出

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 AddFlowOutputs

以下代码示例演示了如何使用 create-flow

AWS CLI

创建流程

以下 create-flow 示例使用指定配置创建了一个流程。

aws mediaconnect create-flow \ --availability-zone us-west-2c \ --name ExampleFlow \ --source Description='Example source, backup',IngestPort=1055,Name=BackupSource,Protocol=rtp,WhitelistCidr=10.24.34.0/23

输出:

{ "Flow": { "FlowArn": "arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:ExampleFlow", "AvailabilityZone": "us-west-2c", "EgressIp": "54.245.71.21", "Source": { "IngestPort": 1055, "SourceArn": "arn:aws:mediaconnect:us-east-1:123456789012:source:2-3aBC45dEF67hiJ89-c34de5fG678h:BackupSource", "Transport": { "Protocol": "rtp", "MaxBitrate": 80000000 }, "Description": "Example source, backup", "IngestIp": "54.245.71.21", "WhitelistCidr": "10.24.34.0/23", "Name": "mySource" }, "Entitlements": [], "Name": "ExampleFlow", "Outputs": [], "Status": "STANDBY", "Description": "Example source, backup" } }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的创建流程

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 CreateFlow

以下代码示例演示了如何使用 delete-flow

AWS CLI

删除流程

以下 delete-flow 示例删除指定流程。

aws mediaconnect delete-flow \ --flow-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow", "Status": "DELETING" }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的删除流程

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DeleteFlow

以下代码示例演示了如何使用 describe-flow

AWS CLI

查看流程的详细信息

以下 describe-flow 示例显示指定流程的详细信息,如 ARN、可用区、状态、源、授权和输出。

aws mediaconnect describe-flow \ --flow-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow

输出:

{ "Flow": { "EgressIp": "54.201.4.39", "AvailabilityZone": "us-west-2c", "Status": "ACTIVE", "FlowArn": "arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow", "Entitlements": [ { "EntitlementArn": "arn:aws:mediaconnect:us-west-2:123456789012:entitlement:1-AaBb11CcDd22EeFf-34DE5fG12AbC:MyEntitlement", "Description": "Assign to this account", "Name": "MyEntitlement", "Subscribers": [ "444455556666" ] } ], "Description": "NYC awards show", "Name": "AwardsShow", "Outputs": [ { "Port": 2355, "Name": "NYC", "Transport": { "SmoothingLatency": 0, "Protocol": "rtp-fec" }, "OutputArn": "arn:aws:mediaconnect:us-east-1:123456789012:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC", "Destination": "192.0.2.0" }, { "Port": 3025, "Name": "LA", "Transport": { "SmoothingLatency": 0, "Protocol": "rtp-fec" }, "OutputArn": "arn:aws:mediaconnect:us-east-1:123456789012:output:2-987655dEF67hiJ89-c34de5fG678h:LA", "Destination": "192.0.2.0" } ], "Source": { "IngestIp": "54.201.4.39", "SourceArn": "arn:aws:mediaconnect:us-east-1:123456789012:source:3-4aBC56dEF78hiJ90-4de5fG6Hi78Jk:ShowSource", "Transport": { "MaxBitrate": 80000000, "Protocol": "rtp" }, "IngestPort": 1069, "Description": "Saturday night show", "Name": "ShowSource", "WhitelistCidr": "10.24.34.0/23" } } }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的查看流程的详细信息

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DescribeFlow

以下代码示例演示了如何使用 grant-flow-entitlements

AWS CLI

授予对于流程的权利

以下 grant-flow-entitlements 示例授予对于指定现有流程的权利,以便您可以将您的内容与其他 AWS 账户分享。

aws mediaconnect grant-flow-entitlements \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --entitlements Description='For AnyCompany',Encryption={"Algorithm=aes128,KeyType=static-key,RoleArn=arn:aws:iam::111122223333:role/MediaConnect-ASM,SecretArn=arn:aws:secretsmanager:us-west-2:111122223333:secret:mySecret1"},Name=AnyCompany_Entitlement,Subscribers=444455556666 Description='For Example Corp',Name=ExampleCorp,Subscribers=777788889999

输出:

{ "Entitlements": [ { "Name": "AnyCompany_Entitlement", "EntitlementArn": "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:AnyCompany_Entitlement", "Subscribers": [ "444455556666" ], "Description": "For AnyCompany", "Encryption": { "SecretArn": "arn:aws:secretsmanager:us-west-2:111122223333:secret:mySecret1", "Algorithm": "aes128", "RoleArn": "arn:aws:iam::111122223333:role/MediaConnect-ASM", "KeyType": "static-key" } }, { "Name": "ExampleCorp", "EntitlementArn": "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-3333cccc4444dddd-1111aaaa2222:ExampleCorp", "Subscribers": [ "777788889999" ], "Description": "For Example Corp" } ], "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame" }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的授予对于流程的权利

以下代码示例演示了如何使用 list-entitlements

AWS CLI

查看权利列表

以下 list-entitlements 示例显示授予账户的所有权利的列表。

aws mediaconnect list-entitlements

输出:

{ "Entitlements": [ { "EntitlementArn": "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:MyEntitlement", "EntitlementName": "MyEntitlement" } ] }

有关更多信息,请参阅《AWS Elemental MediaConnect API 参考》中的 ListEntitlements

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ListEntitlements

以下代码示例演示了如何使用 list-flows

AWS CLI

查看流程列表

以下 list-flows 示例显示流程的列表。

aws mediaconnect list-flows

输出:

{ "Flows": [ { "Status": "STANDBY", "SourceType": "OWNED", "AvailabilityZone": "us-west-2a", "Description": "NYC awards show", "Name": "AwardsShow", "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow" }, { "Status": "STANDBY", "SourceType": "OWNED", "AvailabilityZone": "us-west-2c", "Description": "LA basketball game", "Name": "BasketballGame", "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BasketballGame" } ] }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的查看流程列表

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ListFlows

以下代码示例演示了如何使用 list-tags-for-resource

AWS CLI

列出 MediaConnect 资源的标签

以下 list-tags-for-resource 示例显示与指定 MediaConnect 资源关联的标签键和值。

aws mediaconnect list-tags-for-resource \ --resource-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BasketballGame

输出:

{ "Tags": { "region": "west", "stage": "prod" } }

有关更多信息,请参阅《AWS Elemental MediaConnect API 参考》中的 ListTagsForResource,TagResource,UntagResource

以下代码示例演示了如何使用 remove-flow-output

AWS CLI

从流程中移除输出

以下 remove-flow-output 示例从指定流程中移除输出。

aws mediaconnect remove-flow-output \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --output-arn arn:aws:mediaconnect:us-east-1:111122223333:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame", "OutputArn": "arn:aws:mediaconnect:us-east-1:111122223333:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC" }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的从流程中移除输出

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 RemoveFlowOutput

以下代码示例演示了如何使用 revoke-flow-entitlement

AWS CLI

撤销权利

以下 revoke-flow-entitlement 示例撤销对于指定流程的权利。

aws mediaconnect revoke-flow-entitlement \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --entitlement-arn arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:AnyCompany_Entitlement

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame", "EntitlementArn": "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:AnyCompany_Entitlement" }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的撤销权利

以下代码示例演示了如何使用 start-flow

AWS CLI

启动流程

以下 start-flow 示例启动指定流程。

aws mediaconnect start-flow \ --flow-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow

此命令不生成任何输出。输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow", "Status": "STARTING" }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的启动流程

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 StartFlow

以下代码示例演示了如何使用 stop-flow

AWS CLI

停止流程

以下 stop-flow 示例停止指定流程。

aws mediaconnect stop-flow \ --flow-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow

输出:

{ "Status": "STOPPING", "FlowArn": "arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow" }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的停止流程

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 StopFlow

以下代码示例演示了如何使用 tag-resource

AWS CLI

为 MediaConnect 资源添加标签

以下 tag-resource 示例为指定的 MediaConnect 资源添加一个带有键名称和值的标签。

aws mediaconnect tag-resource \ --resource-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BasketballGame --tags region=west

此命令不生成任何输出。

有关更多信息,请参阅《AWS Elemental MediaConnect API 参考》中的 ListTagsForResource,TagResource,UntagResource

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 TagResource

以下代码示例演示了如何使用 untag-resource

AWS CLI

从 MediaConnect 资源移除标签

以下 untag-resource 示例从 MediaConnect 资源移除具有指定键名和值的标签及其关联值。

aws mediaconnect untag-resource \ --resource-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BasketballGame \ --tag-keys region

此命令不生成任何输出。

有关更多信息,请参阅《AWS Elemental MediaConnect API 参考》中的 ListTagsForResource,TagResource,UntagResource

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 UntagResource

以下代码示例演示了如何使用 update-flow-entitlement

AWS CLI

更新权利

以下 update-flow-entitlement 示例使用新的描述和订阅用户更新了指定的权利。

aws mediaconnect update-flow-entitlement \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --entitlement-arn arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:AnyCompany_Entitlement \ --description 'For AnyCompany Affiliate' \ --subscribers 777788889999

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame", "Entitlement": { "Name": "AnyCompany_Entitlement", "Description": "For AnyCompany Affiliate", "EntitlementArn": "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:AnyCompany_Entitlement", "Encryption": { "KeyType": "static-key", "Algorithm": "aes128", "RoleArn": "arn:aws:iam::111122223333:role/MediaConnect-ASM", "SecretArn": "arn:aws:secretsmanager:us-west-2:111122223333:secret:mySecret1" }, "Subscribers": [ "777788889999" ] } }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的更新权利

以下代码示例演示了如何使用 update-flow-output

AWS CLI

更新流程上的输出

以下 update-flow-output 示例更新指定流程上的输出。

aws mediaconnect update-flow-output \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --output-arn arn:aws:mediaconnect:us-east-1:111122223333:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC \ --port 3331

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame", "Output": { "Name": "NYC", "Port": 3331, "Description": "NYC stream", "Transport": { "Protocol": "rtp-fec", "SmoothingLatency": 100 }, "OutputArn": "arn:aws:mediaconnect:us-east-1:111122223333:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC", "Destination": "192.0.2.12" } }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的更新流程上的输出

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 UpdateFlowOutput

以下代码示例演示了如何使用 update-flow-source

AWS CLI

更新现有流程的来源

以下 update-flow-source 示例更新现有流程的来源。

aws mediaconnect update-flow-source \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow \ --source-arn arn:aws:mediaconnect:us-east-1:111122223333:source:3-4aBC56dEF78hiJ90-4de5fG6Hi78Jk:ShowSource \ --description 'Friday night show' \ --ingest-port 3344 \ --protocol rtp-fec \ --whitelist-cidr 10.24.34.0/23

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow", "Source": { "IngestIp": "34.210.136.56", "WhitelistCidr": "10.24.34.0/23", "Transport": { "Protocol": "rtp-fec" }, "IngestPort": 3344, "Name": "ShowSource", "Description": "Friday night show", "SourceArn": "arn:aws:mediaconnect:us-east-1:111122223333:source:3-4aBC56dEF78hiJ90-4de5fG6Hi78Jk:ShowSource" } }

有关更多信息,请参阅《AWS Elemental MediaConnect 用户指南》中的更新流程的来源

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 UpdateFlowSource