使用网络管理器示例 AWS CLI - AWS Command Line Interface

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用网络管理器示例 AWS CLI

以下代码示例向您展示了如何通过 AWS Command Line Interface 与网络管理器一起使用来执行操作和实现常见场景。

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

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

主题

操作

以下代码示例显示了如何使用associate-customer-gateway

AWS CLI

关联客户网关

以下associate-customer-gateway示例将指定全球网络cgw-11223344556677889中的客户网关与设备相关联device-07f6fd08867abc123

aws networkmanager associate-customer-gateway \ --customer-gateway-arn arn:aws:ec2:us-west-2:123456789012:customer-gateway/cgw-11223344556677889 \ --global-network-id global-network-01231231231231231 \ --device-id device-07f6fd08867abc123 \ --region us-west-2

输出:

{ "CustomerGatewayAssociation": { "CustomerGatewayArn": "arn:aws:ec2:us-west-2:123456789012:customer-gateway/cgw-11223344556677889", "GlobalNetworkId": "global-network-01231231231231231", "DeviceId": "device-07f6fd08867abc123", "State": "PENDING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的客户网关关

以下代码示例显示了如何使用associate-link

AWS CLI

关联链接

以下associate-link示例将链接link-11112222aaaabbbb1与设备关联起来device-07f6fd08867abc123。链路和设备位于指定的全局网络中。

aws networkmanager associate-link \ --global-network-id global-network-01231231231231231 \ --device-id device-07f6fd08867abc123 \ --link-id link-11112222aaaabbbb1 \ --region us-west-2

输出:

{ "LinkAssociation": { "GlobalNetworkId": "global-network-01231231231231231", "DeviceId": "device-07f6fd08867abc123", "LinkId": "link-11112222aaaabbbb1", "LinkAssociationState": "PENDING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的设备和链路关

以下代码示例显示了如何使用create-core-network

AWS CLI

创建核心网络

以下create-core-network示例使用可选描述和标签在 AWS Cloud WAN 全球网络中创建核心网络。

aws networkmanager create-core-network \ --global-network-id global-network-cdef-EXAMPLE22222 \ --description "Main headquarters location" \ --tags Key=Name,Value="New York City office"

输出:

{ "CoreNetwork": { "GlobalNetworkId": "global-network-cdef-EXAMPLE22222", "CoreNetworkId": "core-network-cdef-EXAMPLE33333", "CoreNetworkArn": "arn:aws:networkmanager::987654321012:core-network/core-network-cdef-EXAMPLE33333", "Description": "Main headquarters location", "CreatedAt": "2022-01-10T19:53:59+00:00", "State": "AVAILABLE", "Tags": [ { "Key": "Name", "Value": "New York City office" } ] } }

有关更多信息,请参阅《AWS 云WAN用户指南》中的全球和核心网络

以下代码示例显示了如何使用create-device

AWS CLI

创建设备

以下create-device示例在指定的全局网络中创建设备。设备详细信息包括描述、类型、供应商、型号和序列号。

aws networkmanager create-device --global-network-id global-network-01231231231231231 \ --description "New York office device" \ --type "office device" \ --vendor "anycompany" \ --model "abcabc" \ --serial-number "1234" \ --region us-west-2

输出:

{ "Device": { "DeviceId": "device-07f6fd08867abc123", "DeviceArn": "arn:aws:networkmanager::123456789012:device/global-network-01231231231231231/device-07f6fd08867abc123", "GlobalNetworkId": "global-network-01231231231231231", "Description": "New York office device", "Type": "office device", "Vendor": "anycompany", "Model": "abcabc", "SerialNumber": "1234", "CreatedAt": 1575554005.0, "State": "PENDING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的使用设备

以下代码示例显示了如何使用create-global-network

AWS CLI

创建全球网络

以下create-global-network示例创建了一个新的全球网络。创建时的初始状态为PENDING

aws networkmanager create-global-network

输出:

{ "GlobalNetwork": { "GlobalNetworkId": "global-network-00a77fc0f722dae74", "GlobalNetworkArn": "arn:aws:networkmanager::987654321012:global-network/global-network-00a77fc0f722dae74", "CreatedAt": "2022-03-14T20:31:56+00:00", "State": "PENDING" } }

以下代码示例显示了如何使用create-link

AWS CLI

创建链接

以下create-link示例在指定的全球网络中创建链接。该链接包括有关链路类型、带宽和提供商的描述和详细信息。站点 ID 表示与该链接关联的站点。

aws networkmanager create-link \ --global-network-id global-network-01231231231231231 \ --description "VPN Link" \ --type "broadband" \ --bandwidth UploadSpeed=10,DownloadSpeed=20 \ --provider "AnyCompany" \ --site-id site-444555aaabbb11223 \ --region us-west-2

输出:

{ "Link": { "LinkId": "link-11112222aaaabbbb1", "LinkArn": "arn:aws:networkmanager::123456789012:link/global-network-01231231231231231/link-11112222aaaabbbb1", "GlobalNetworkId": "global-network-01231231231231231", "SiteId": "site-444555aaabbb11223", "Description": "VPN Link", "Type": "broadband", "Bandwidth": { "UploadSpeed": 10, "DownloadSpeed": 20 }, "Provider": "AnyCompany", "CreatedAt": 1575555811.0, "State": "PENDING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的使用链接

以下代码示例显示了如何使用create-site

AWS CLI

创建网站

以下create-site示例在指定的全球网络中创建一个站点。网站详细信息包括描述和位置信息。

aws networkmanager create-site \ --global-network-id global-network-01231231231231231 \ --description "New York head office" \ --location Latitude=40.7128,Longitude=-74.0060 \ --region us-west-2

输出:

{ "Site": { "SiteId": "site-444555aaabbb11223", "SiteArn": "arn:aws:networkmanager::123456789012:site/global-network-01231231231231231/site-444555aaabbb11223", "GlobalNetworkId": "global-network-01231231231231231", "Description": "New York head office", "Location": { "Latitude": "40.7128", "Longitude": "-74.0060" }, "CreatedAt": 1575554300.0, "State": "PENDING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的使用站点

以下代码示例显示了如何使用create-vpc-attachment

AWS CLI

创建VPC附件

以下create-vpc-attachment示例创建了一个IPv6支持核心网络的VPC附件。

aws networkmanager create-vpc-attachment \ --core-network-id core-network-0fab62fe438d94db6 \ --vpc-arn arn:aws:ec2:us-east-1:987654321012:vpc/vpc-09f37f69e2786eeb8 \ --subnet-arns arn:aws:ec2:us-east-1:987654321012:subnet/subnet-04ca4e010857e7bb7 \ --Ipv6Support=true

输出:

{ "VpcAttachment": { "Attachment": { "CoreNetworkId": "core-network-0fab62fe438d94db6", "AttachmentId": "attachment-05e1da6eba87a06e6", "OwnerAccountId": "987654321012", "AttachmentType": "VPC", "State": "CREATING", "EdgeLocation": "us-east-1", "ResourceArn": "arn:aws:ec2:us-east-1:987654321012:vpc/vpc-09f37f69e2786eeb8", "Tags": [], "CreatedAt": "2022-03-10T20:59:14+00:00", "UpdatedAt": "2022-03-10T20:59:14+00:00" }, "SubnetArns": [ "arn:aws:ec2:us-east-1:987654321012:subnet/subnet-04ca4e010857e7bb7" ], "Options": { "Ipv6Support": true } } }

有关更多信息,请参阅 Cloud WAN 用户指南中的创建附件

以下代码示例显示了如何使用delete-attachment

AWS CLI

删除附件

以下delete-attachment示例删除了 Connect 附件。

aws networkmanager delete-attachment \ --attachment-id attachment-01feddaeae26ab68c

输出:

{ "Attachment": { "CoreNetworkId": "core-network-0f4b0a9d5ee7761d1", "AttachmentId": "attachment-01feddaeae26ab68c", "OwnerAccountId": "987654321012", "AttachmentType": "CONNECT", "State": "DELETING", "EdgeLocation": "us-east-1", "ResourceArn": "arn:aws:networkmanager::987654321012:attachment/attachment-02c3964448fedf5aa", "CreatedAt": "2022-03-15T19:18:41+00:00", "UpdatedAt": "2022-03-15T19:28:59+00:00" } }

有关更多信息,请参阅 Cloud WAN 用户指南中的删除附件

以下代码示例显示了如何使用delete-bucket-analytics-configuration

AWS CLI

删除存储桶的分析配置

以下 delete-bucket-analytics-configuration 示例移除指定存储桶和 ID 的分析配置。

aws s3api delete-bucket-analytics-configuration \ --bucket my-bucket \ --id 1

此命令不生成任何输出。

以下代码示例显示了如何使用delete-bucket-metrics-configuration

AWS CLI

删除存储桶的指标配置

以下 delete-bucket-metrics-configuration 示例移除指定存储桶和 ID 的指标配置。

aws s3api delete-bucket-metrics-configuration \ --bucket my-bucket \ --id 123

此命令不生成任何输出。

以下代码示例显示了如何使用delete-core-network

AWS CLI

删除核心网络

以下delete-core-network示例从 Cloud WAN 全球网络中删除核心网络。

aws networkmanager delete-core-network \ --core-network-id core-network-0fab62fe438d94db6

输出:

{ "CoreNetwork": { "GlobalNetworkId": "global-network-0d59060f16a73bc41", "CoreNetworkId": "core-network-0fab62fe438d94db6", "Description": "Main headquarters location", "CreatedAt": "2021-12-09T18:31:11+00:00", "State": "DELETING", "Segments": [ { "Name": "dev", "EdgeLocations": [ "us-east-1" ], "SharedSegments": [] } ], "Edges": [ { "EdgeLocation": "us-east-1", "Asn": 64512, "InsideCidrBlocks": [] } ] } }

有关更多信息,请参阅《云WAN用户指南》中的核心网络

以下代码示例显示了如何使用delete-device

AWS CLI

删除设备

以下delete-device示例从指定的全局网络中删除指定设备。

aws networkmanager delete-device \ --global-network-id global-network-01231231231231231 \ --device-id device-07f6fd08867abc123 \ --region us-west-2

输出:

{ "Device": { "DeviceId": "device-07f6fd08867abc123", "DeviceArn": "arn:aws:networkmanager::123456789012:device/global-network-01231231231231231/device-07f6fd08867abc123", "GlobalNetworkId": "global-network-01231231231231231", "Description": "New York office device", "Type": "office device", "Vendor": "anycompany", "Model": "abcabc", "SerialNumber": "1234", "SiteId": "site-444555aaabbb11223", "CreatedAt": 1575554005.0, "State": "DELETING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的使用设备

以下代码示例显示了如何使用delete-global-network

AWS CLI

删除全球网络

以下delete-global-network示例删除了一个全球网络。

aws networkmanager delete-global-network \ --global-network-id global-network-052bedddccb193b6b

输出:

{ "GlobalNetwork": { "GlobalNetworkId": "global-network-052bedddccb193b6b", "GlobalNetworkArn": "arn:aws:networkmanager::987654321012:global-network/global-network-052bedddccb193b6b", "CreatedAt": "2021-12-09T18:19:12+00:00", "State": "DELETING" } }

以下代码示例显示了如何使用delete-link

AWS CLI

删除链接

以下delete-link示例从指定的全局网络中删除指定的链接。

aws networkmanager delete-link \ --global-network-id global-network-01231231231231231 \ --link-id link-11112222aaaabbbb1 \ --region us-west-2

输出:

{ "Link": { "LinkId": "link-11112222aaaabbbb1", "LinkArn": "arn:aws:networkmanager::123456789012:link/global-network-01231231231231231/link-11112222aaaabbbb1", "GlobalNetworkId": "global-network-01231231231231231", "SiteId": "site-444555aaabbb11223", "Description": "VPN Link", "Type": "broadband", "Bandwidth": { "UploadSpeed": 20, "DownloadSpeed": 20 }, "Provider": "AnyCompany", "CreatedAt": 1575555811.0, "State": "DELETING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的使用链接

以下代码示例显示了如何使用delete-public-access-block

AWS CLI

删除存储桶的屏蔽公共访问权限配置

以下 delete-public-access-block 示例移除指定存储桶上的屏蔽公共访问权限配置。

aws s3api delete-public-access-block \ --bucket my-bucket

此命令不生成任何输出。

以下代码示例显示了如何使用delete-site

AWS CLI

删除网站

以下delete-site示例删除指定全球网络中的指定站点 (site-444555aaabbb11223)。

aws networkmanager delete-site \ --global-network-id global-network-01231231231231231 \ --site-id site-444555aaabbb11223 \ --region us-west-2

输出:

{ "Site": { "SiteId": "site-444555aaabbb11223", "SiteArn": "arn:aws:networkmanager::123456789012:site/global-network-01231231231231231/site-444555aaabbb11223", "GlobalNetworkId": "global-network-01231231231231231", "Description": "New York head office", "Location": { "Latitude": "40.7128", "Longitude": "-74.0060" }, "CreatedAt": 1575554300.0, "State": "DELETING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的使用站点

以下代码示例显示了如何使用deregister-transit-gateway

AWS CLI

从全球网络中注销公交网关

以下deregister-transit-gateway示例从指定的全球网络取消注册指定的传输网关。

aws networkmanager deregister-transit-gateway \ --global-network-id global-network-01231231231231231 \ --transit-gateway-arn arn:aws:ec2:us-west-2:123456789012:transit-gateway/tgw-123abc05e04123abc \ --region us-west-2

输出:

{ "TransitGatewayRegistration": { "GlobalNetworkId": "global-network-01231231231231231", "TransitGatewayArn": "arn:aws:ec2:us-west-2:123456789012:transit-gateway/tgw-123abc05e04123abc", "State": { "Code": "DELETING" } } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的 Transit Gateway 注册

以下代码示例显示了如何使用describe-global-networks

AWS CLI

描述您的全球网络

以下describe-global-networks示例描述了您账户中的所有全球网络。

aws networkmanager describe-global-networks \ --region us-west-2

输出:

{ "GlobalNetworks": [ { "GlobalNetworkId": "global-network-01231231231231231", "GlobalNetworkArn": "arn:aws:networkmanager::123456789012:global-network/global-network-01231231231231231", "Description": "Company 1 global network", "CreatedAt": 1575553525.0, "State": "AVAILABLE" } ] }

以下代码示例显示了如何使用disassociate-customer-gateway

AWS CLI

取消与客户网关的关联

以下disassociate-customer-gateway示例取消指定客户网关 (cgw-11223344556677889) 与指定全球网络的关联。

aws networkmanager disassociate-customer-gateway \ --global-network-id global-network-01231231231231231 \ --customer-gateway-arn arn:aws:ec2:us-west-2:123456789012:customer-gateway/cgw-11223344556677889 \ --region us-west-2

输出:

{ "CustomerGatewayAssociation": { "CustomerGatewayArn": "arn:aws:ec2:us-west-2:123456789012:customer-gateway/cgw-11223344556677889", "GlobalNetworkId": "global-network-01231231231231231", "DeviceId": "device-07f6fd08867abc123", "State": "DELETING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的客户网关关

以下代码示例显示了如何使用disassociate-link

AWS CLI

取消关联链接

以下disassociate-link示例取消指定链接与指定全局网络device-07f6fd08867abc123中设备的关联。

aws networkmanager disassociate-link \ --global-network-id global-network-01231231231231231 \ --device-id device-07f6fd08867abc123 \ --link-id link-11112222aaaabbbb1 \ --region us-west-2

输出:

{ "LinkAssociation": { "GlobalNetworkId": "global-network-01231231231231231", "DeviceId": "device-07f6fd08867abc123", "LinkId": "link-11112222aaaabbbb1", "LinkAssociationState": "DELETING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的设备和链路关

以下代码示例显示了如何使用get-bucket-analytics-configuration

AWS CLI

检索具有特定 ID 的存储桶的分析配置

以下 get-bucket-analytics-configuration 示例显示了指定存储桶和 ID 的分析配置。

aws s3api get-bucket-analytics-configuration \ --bucket my-bucket \ --id 1

输出:

{ "AnalyticsConfiguration": { "StorageClassAnalysis": {}, "Id": "1" } }

以下代码示例显示了如何使用get-bucket-metrics-configuration

AWS CLI

检索具有特定 ID 的存储桶的指标配置

以下 get-bucket-metrics-configuration 示例显示了指定存储桶和 ID 的指标配置。

aws s3api get-bucket-metrics-configuration \ --bucket my-bucket \ --id 123

输出:

{ "MetricsConfiguration": { "Filter": { "Prefix": "logs" }, "Id": "123" } }

以下代码示例显示了如何使用get-customer-gateway-associations

AWS CLI

获取您的客户网关关联

以下get-customer-gateway-associations示例获取指定全球网络的客户网关关联。

aws networkmanager get-customer-gateway-associations \ --global-network-id global-network-01231231231231231 \ --region us-west-2

输出:

{ "CustomerGatewayAssociations": [ { "CustomerGatewayArn": "arn:aws:ec2:us-west-2:123456789012:customer-gateway/cgw-11223344556677889", "GlobalNetworkId": "global-network-01231231231231231", "DeviceId": "device-07f6fd08867abc123", "State": "AVAILABLE" } ] }

以下代码示例显示了如何使用get-devices

AWS CLI

要获取您的设备

以下get-devices示例获取指定全球网络中的设备。

aws networkmanager get-devices \ --global-network-id global-network-01231231231231231 \ --region us-west-2

输出:

{ "Devices": [ { "DeviceId": "device-07f6fd08867abc123", "DeviceArn": "arn:aws:networkmanager::123456789012:device/global-network-01231231231231231/device-07f6fd08867abc123", "GlobalNetworkId": "global-network-01231231231231231", "Description": "NY office device", "Type": "office device", "Vendor": "anycompany", "Model": "abcabc", "SerialNumber": "1234", "CreatedAt": 1575554005.0, "State": "AVAILABLE" } ] }

以下代码示例显示了如何使用get-link-associations

AWS CLI

获取您的链接关联

以下get-link-associations示例获取指定全球网络中的链接关联。

aws networkmanager get-link-associations \ --global-network-id global-network-01231231231231231 \ --region us-west-2

输出:

{ "LinkAssociations": [ { "GlobalNetworkId": "global-network-01231231231231231", "DeviceId": "device-07f6fd08867abc123", "LinkId": "link-11112222aaaabbbb1", "LinkAssociationState": "AVAILABLE" } ] }

以下代码示例显示了如何使用get-links

AWS CLI

获取您的链接

以下get-links示例获取指定全球网络中的链接。

aws networkmanager get-links \ --global-network-id global-network-01231231231231231 \ --region us-west-2

输出:

{ "Links": [ { "LinkId": "link-11112222aaaabbbb1", "LinkArn": "arn:aws:networkmanager::123456789012:link/global-network-01231231231231231/link-11112222aaaabbbb1", "GlobalNetworkId": "global-network-01231231231231231", "SiteId": "site-444555aaabbb11223", "Description": "VPN Link", "Type": "broadband", "Bandwidth": { "UploadSpeed": 10, "DownloadSpeed": 20 }, "Provider": "AnyCompany", "CreatedAt": 1575555811.0, "State": "AVAILABLE" } ] }

以下代码示例显示了如何使用get-object-retention

AWS CLI

检索对象的对象保留配置

以下 get-object-retention 示例检索指定对象的对象保留配置。

aws s3api get-object-retention \ --bucket my-bucket-with-object-lock \ --key doc1.rtf

输出:

{ "Retention": { "Mode": "GOVERNANCE", "RetainUntilDate": "2025-01-01T00:00:00.000Z" } }

以下代码示例显示了如何使用get-public-access-block

AWS CLI

设置或修改存储桶的屏蔽公共访问权限配置

以下 get-public-access-block 示例显示了指定存储桶的屏蔽公共访问权限配置。

aws s3api get-public-access-block --bucket my-bucket

输出:

{ "PublicAccessBlockConfiguration": { "IgnorePublicAcls": true, "BlockPublicPolicy": true, "BlockPublicAcls": true, "RestrictPublicBuckets": true } }

以下代码示例显示了如何使用get-sites

AWS CLI

获取您的网站

以下get-sites示例获取指定全球网络中的站点。

aws networkmanager get-sites \ --global-network-id global-network-01231231231231231 \ --region us-west-2

输出:

{ "Sites": [ { "SiteId": "site-444555aaabbb11223", "SiteArn": "arn:aws:networkmanager::123456789012:site/global-network-01231231231231231/site-444555aaabbb11223", "GlobalNetworkId": "global-network-01231231231231231", "Description": "NY head office", "Location": { "Latitude": "40.7128", "Longitude": "-74.0060" }, "CreatedAt": 1575554528.0, "State": "AVAILABLE" } ] }

以下代码示例显示了如何使用get-transit-gateway-registrations

AWS CLI

获取您的公交网关登记

以下get-transit-gateway-registrations示例获取注册到指定全球网络的传输网关。

aws networkmanager get-transit-gateway-registrations \ --global-network-id global-network-01231231231231231 \ --region us-west-2

输出:

{ "TransitGatewayRegistrations": [ { "GlobalNetworkId": "global-network-01231231231231231", "TransitGatewayArn": "arn:aws:ec2:us-west-2:123456789012:transit-gateway/tgw-123abc05e04123abc", "State": { "Code": "AVAILABLE" } } ] }

以下代码示例显示了如何使用get-vpc-attachment

AWS CLI

获取附VPC件

以下get-vpc-attachment示例返回有关VPC附件的信息。

aws networkmanager get-vpc-attachment \ --attachment-id attachment-03b7ea450134787da

输出:

{ "VpcAttachment": { "Attachment": { "CoreNetworkId": "core-network-0522de1b226a5d7b3", "AttachmentId": "attachment-03b7ea450134787da", "OwnerAccountId": "987654321012", "AttachmentType": "VPC", "State": "CREATING", "EdgeLocation": "us-east-1", "ResourceArn": "arn:aws:ec2:us-east-1:987654321012:vpc/vpc-a7c4bbda", "Tags": [ { "Key": "Name", "Value": "DevVPC" } ], "CreatedAt": "2022-03-11T17:48:58+00:00", "UpdatedAt": "2022-03-11T17:48:58+00:00" }, "SubnetArns": [ "arn:aws:ec2:us-east-1:987654321012:subnet/subnet-202cde6c", "arn:aws:ec2:us-east-1:987654321012:subnet/subnet-e5022dba", "arn:aws:ec2:us-east-1:987654321012:subnet/subnet-2387ae02", "arn:aws:ec2:us-east-1:987654321012:subnet/subnet-cda9dffc" ], "Options": { "Ipv6Support": false } } }

有关更多信息,请参阅 Cloud WAN 用户指南中的附件

以下代码示例显示了如何使用list-bucket-analytics-configurations

AWS CLI

检索存储桶的分析配置列表

下面的 list-bucket-analytics-configurations 检索指定存储桶的分析配置列表。

aws s3api list-bucket-analytics-configurations \ --bucket my-bucket

输出:

{ "AnalyticsConfigurationList": [ { "StorageClassAnalysis": {}, "Id": "1" } ], "IsTruncated": false }

以下代码示例显示了如何使用list-bucket-metrics-configurations

AWS CLI

检索存储桶的指标配置列表

以下list-bucket-metrics-configurations示例检索指定存储桶的指标配置列表。

aws s3api list-bucket-metrics-configurations \ --bucket my-bucket

输出:

{ "IsTruncated": false, "MetricsConfigurationList": [ { "Filter": { "Prefix": "logs" }, "Id": "123" }, { "Filter": { "Prefix": "tmp" }, "Id": "234" } ] }

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

AWS CLI

列出资源的标签

以下list-tags-for-resource示例列出了指定设备资源 (device-07f6fd08867abc123) 的标签。

aws networkmanager list-tags-for-resource \ --resource-arn arn:aws:networkmanager::123456789012:device/global-network-01231231231231231/device-07f6fd08867abc123 \ --region us-west-2

输出:

{ "TagList": [ { "Key": "Network", "Value": "Northeast" } ] }

以下代码示例显示了如何使用put-bucket-metrics-configuration

AWS CLI

为存储桶设置指标配置

以下put-bucket-metrics-configuration示例为指定存储桶设置 ID 为 123 的指标配置。

aws s3api put-bucket-metrics-configuration \ --bucket my-bucket \ --id 123 \ --metrics-configuration '{"Id": "123", "Filter": {"Prefix": "logs"}}'

此命令不生成任何输出。

以下代码示例显示了如何使用put-object-retention

AWS CLI

为对象设置对象保留配置

以下 put-object-retention 示例为指定对象设置直到 2025 年 1 月 1 日的对象保留配置。

aws s3api put-object-retention \ --bucket my-bucket-with-object-lock \ --key doc1.rtf \ --retention '{ "Mode": "GOVERNANCE", "RetainUntilDate": "2025-01-01T00:00:00" }'

此命令不生成任何输出。

以下代码示例显示了如何使用put-public-access-block

AWS CLI

为存储桶设置阻止公有访问配置

以下put-public-access-block示例为指定存储桶设置限制性封禁公共访问配置。

aws s3api put-public-access-block \ --bucket my-bucket \ --public-access-block-configuration "BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true"

此命令不生成任何输出。

以下代码示例显示了如何使用register-transit-gateway

AWS CLI

在全球网络中注册传输网关

以下register-transit-gateway示例在指定的全球网络tgw-123abc05e04123abc中注册传输网关。

aws networkmanager register-transit-gateway \ --global-network-id global-network-01231231231231231 \ --transit-gateway-arn arn:aws:ec2:us-west-2:123456789012:transit-gateway/tgw-123abc05e04123abc \ --region us-west-2

输出:

{ "TransitGatewayRegistration": { "GlobalNetworkId": "global-network-01231231231231231", "TransitGatewayArn": "arn:aws:ec2:us-west-2:123456789012:transit-gateway/tgw-123abc05e04123abc", "State": { "Code": "PENDING" } } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的 Transit Gateway 注册

以下代码示例显示了如何使用reject-attachment

AWS CLI

拒绝附件

以下reject-attachment示例拒绝了VPC附件请求。

aws networkmanager reject-attachment \ --attachment-id attachment-03b7ea450134787da

输出:

{ "Attachment": { "CoreNetworkId": "core-network-0522de1b226a5d7b3", "AttachmentId": "attachment-03b7ea450134787da", "OwnerAccountId": "987654321012", "AttachmentType": "VPC", "State": "AVAILABLE", "EdgeLocation": "us-east-1", "ResourceArn": "arn:aws:ec2:us-east-1:987654321012:vpc/vpc-a7c4bbda", "CreatedAt": "2022-03-11T17:48:58+00:00", "UpdatedAt": "2022-03-11T17:51:25+00:00" } }

有关更多信息,请参阅 Cloud WAN 用户指南中的附件接受

以下代码示例显示了如何使用start-route-analysis

AWS CLI

开始路径分析

以下start-route-analysis示例启动源和目标之间的分析,包括可选的include-return-path

aws networkmanager start-route-analysis \ --global-network-id global-network-00aa0aaa0b0aaa000 \ --source TransitGatewayAttachmentArn=arn:aws:ec2:us-east-1:503089527312:transit-gateway-attachment/tgw-attach-0d4a2d491bf68c093,IpAddress=10.0.0.0 \ --destination TransitGatewayAttachmentArn=arn:aws:ec2:us-west-1:503089527312:transit-gateway-attachment/tgw-attach-002577f30bb181742,IpAddress=11.0.0.0 \ --include-return-path

输出:

{ "RouteAnalysis": { "GlobalNetworkId": "global-network-00aa0aaa0b0aaa000 "OwnerAccountId": "1111222233333", "RouteAnalysisId": "a1873de1-273c-470c-1a2bc2345678", "StartTimestamp": 1695760154.0, "Status": "RUNNING", "Source": { "TransitGatewayAttachmentArn": "arn:aws:ec2:us-east-1:111122223333:transit-gateway-attachment/tgw-attach-1234567890abcdef0, "TransitGatewayArn": "arn:aws:ec2:us-east-1:111122223333:transit-gateway/tgw-abcdef01234567890", "IpAddress": "10.0.0.0" }, "Destination": { "TransitGatewayAttachmentArn": "arn:aws:ec2:us-west-1:555555555555:transit-gateway-attachment/tgw-attach-021345abcdef6789", "TransitGatewayArn": "arn:aws:ec2:us-west-1:111122223333:transit-gateway/tgw-09876543210fedcba0", "IpAddress": "11.0.0.0" }, "IncludeReturnPath": true, "UseMiddleboxes": false } }

有关更多信息,请参阅《AWS 全球公交网关用户指南》中的路由分析器

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

AWS CLI

对资源应用标签

以下tag-resource示例将标签应用Network=Northeast于设备device-07f6fd08867abc123

aws networkmanager tag-resource \ --resource-arn arn:aws:networkmanager::123456789012:device/global-network-01231231231231231/device-07f6fd08867abc123 \ --tags Key=Network,Value=Northeast \ --region us-west-2

此命令不生成任何输出。

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

AWS CLI

要从资源中删除标签

以下untag-resource示例Network从设备上删除带有密钥的标签device-07f6fd08867abc123

aws networkmanager untag-resource \ --resource-arn arn:aws:networkmanager::123456789012:device/global-network-01231231231231231/device-07f6fd08867abc123 ] --tag-keys Network \ --region us-west-2

此命令不生成任何输出。

以下代码示例显示了如何使用update-device

AWS CLI

更新设备

以下update-device示例device-07f6fd08867abc123通过为设备指定站点 ID 来更新设备。

aws networkmanager update-device \ --global-network-id global-network-01231231231231231 \ --device-id device-07f6fd08867abc123 \ --site-id site-444555aaabbb11223 \ --region us-west-2

输出:

{ "Device": { "DeviceId": "device-07f6fd08867abc123", "DeviceArn": "arn:aws:networkmanager::123456789012:device/global-network-01231231231231231/device-07f6fd08867abc123", "GlobalNetworkId": "global-network-01231231231231231", "Description": "NY office device", "Type": "Office device", "Vendor": "anycompany", "Model": "abcabc", "SerialNumber": "1234", "SiteId": "site-444555aaabbb11223", "CreatedAt": 1575554005.0, "State": "UPDATING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的使用设备

以下代码示例显示了如何使用update-global-network

AWS CLI

更新全球网络

以下update-global-network示例更新了全球网络的描述global-network-01231231231231231

aws networkmanager update-global-network \ --global-network-id global-network-01231231231231231 \ --description "Head offices" \ --region us-west-2

输出:

{ "GlobalNetwork": { "GlobalNetworkId": "global-network-01231231231231231", "GlobalNetworkArn": "arn:aws:networkmanager::123456789012:global-network/global-network-01231231231231231", "Description": "Head offices", "CreatedAt": 1575553525.0, "State": "UPDATING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的全球网络。

以下代码示例显示了如何使用update-link

AWS CLI

更新链接

以下update-link示例更新了链路的带宽信息link-11112222aaaabbbb1

aws networkmanager update-link \ --global-network-id global-network-01231231231231231 \ --link-id link-11112222aaaabbbb1 \ --bandwidth UploadSpeed=20,DownloadSpeed=20 \ --region us-west-2

输出:

{ "Link": { "LinkId": "link-11112222aaaabbbb1", "LinkArn": "arn:aws:networkmanager::123456789012:link/global-network-01231231231231231/link-11112222aaaabbbb1", "GlobalNetworkId": "global-network-01231231231231231", "SiteId": "site-444555aaabbb11223", "Description": "VPN Link", "Type": "broadband", "Bandwidth": { "UploadSpeed": 20, "DownloadSpeed": 20 }, "Provider": "AnyCompany", "CreatedAt": 1575555811.0, "State": "UPDATING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的使用链接

以下代码示例显示了如何使用update-site

AWS CLI

更新网站

以下update-site示例更新了指定全球网络site-444555aaabbb11223中站点的描述。

aws networkmanager update-site \ --global-network-id global-network-01231231231231231 \ --site-id site-444555aaabbb11223 \ --description "New York Office site" \ --region us-west-2

输出:

{ "Site": { "SiteId": "site-444555aaabbb11223", "SiteArn": "arn:aws:networkmanager::123456789012:site/global-network-01231231231231231/site-444555aaabbb11223", "GlobalNetworkId": "global-network-01231231231231231", "Description": "New York Office site", "Location": { "Latitude": "40.7128", "Longitude": "-74.0060" }, "CreatedAt": 1575554528.0, "State": "UPDATING" } }

有关更多信息,请参阅 T ransit Gateway 网络管理器指南中的使用站点