DescribeVpcEndpointServices 搭配 CLI 使用 - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

DescribeVpcEndpointServices 搭配 CLI 使用

下列程式碼範例示範如何使用 DescribeVpcEndpointServices

CLI
AWS CLI

範例 1:描述所有 VPC 端點服務

下列「describe-vpc-endpoint-services」範例會列出 AWS 區域的所有 VPC 端點服務。

aws ec2 describe-vpc-endpoint-services

輸出:

{ "ServiceDetails": [ { "ServiceType": [ { "ServiceType": "Gateway" } ], "AcceptanceRequired": false, "ServiceName": "com.amazonaws.us-east-1.dynamodb", "VpcEndpointPolicySupported": true, "Owner": "amazon", "AvailabilityZones": [ "us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e", "us-east-1f" ], "BaseEndpointDnsNames": [ "dynamodb.us-east-1.amazonaws.com" ] }, { "ServiceType": [ { "ServiceType": "Interface" } ], "PrivateDnsName": "ec2.us-east-1.amazonaws.com", "ServiceName": "com.amazonaws.us-east-1.ec2", "VpcEndpointPolicySupported": false, "Owner": "amazon", "AvailabilityZones": [ "us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e", "us-east-1f" ], "AcceptanceRequired": false, "BaseEndpointDnsNames": [ "ec2.us-east-1.vpce.amazonaws.com" ] }, { "ServiceType": [ { "ServiceType": "Interface" } ], "PrivateDnsName": "ssm.us-east-1.amazonaws.com", "ServiceName": "com.amazonaws.us-east-1.ssm", "VpcEndpointPolicySupported": true, "Owner": "amazon", "AvailabilityZones": [ "us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e" ], "AcceptanceRequired": false, "BaseEndpointDnsNames": [ "ssm.us-east-1.vpce.amazonaws.com" ] } ], "ServiceNames": [ "com.amazonaws.us-east-1.dynamodb", "com.amazonaws.us-east-1.ec2", "com.amazonaws.us-east-1.ec2messages", "com.amazonaws.us-east-1.elasticloadbalancing", "com.amazonaws.us-east-1.kinesis-streams", "com.amazonaws.us-east-1.s3", "com.amazonaws.us-east-1.ssm" ] }

如需詳細資訊,請參閱 使用者指南 for AWS PrivateLink 中的檢視可用的 AWS 服務名稱

範例 2:描述端點服務的詳細資訊

下列「describe-vpc-endpoint-services」範例列出 Amazon S3 介面端點服務的詳細資訊

aws ec2 describe-vpc-endpoint-services \ --filter "Name=service-type,Values=Interface" Name=service-name,Values=com.amazonaws.us-east-1.s3

輸出:

{ "ServiceDetails": [ { "ServiceName": "com.amazonaws.us-east-1.s3", "ServiceId": "vpce-svc-081d84efcdEXAMPLE", "ServiceType": [ { "ServiceType": "Interface" } ], "AvailabilityZones": [ "us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d", "us-east-1e", "us-east-1f" ], "Owner": "amazon", "BaseEndpointDnsNames": [ "s3.us-east-1.vpce.amazonaws.com" ], "VpcEndpointPolicySupported": true, "AcceptanceRequired": false, "ManagesVpcEndpoints": false, "Tags": [] } ], "ServiceNames": [ "com.amazonaws.us-east-1.s3" ] }

如需詳細資訊,請參閱 使用者指南 for AWS PrivateLink 中的檢視可用的 AWS 服務名稱

PowerShell
for PowerShell 工具

範例 1:此範例說明具有指定篩選條件的 EC2 VPC端點服務,在此情況下為 com.amazonaws.eu-west-1.ecs。此外,它還會展開 ServiceDetails 屬性並顯示詳細資訊

Get-EC2VpcEndpointService -Region eu-west-1 -MaxResult 5 -Filter @{Name="service-name";Values="com.amazonaws.eu-west-1.ecs"} | Select-Object -ExpandProperty ServiceDetails

輸出:

AcceptanceRequired : False AvailabilityZones : {eu-west-1a, eu-west-1b, eu-west-1c} BaseEndpointDnsNames : {ecs.eu-west-1.vpce.amazonaws.com} Owner : amazon PrivateDnsName : ecs.eu-west-1.amazonaws.com ServiceName : com.amazonaws.eu-west-1.ecs ServiceType : {Amazon.EC2.Model.ServiceTypeDetail} VpcEndpointPolicySupported : False

範例 2:此範例會擷取所有 EC2 VPC端點服務,並傳回符合「ssm」的 ServiceNames

Get-EC2VpcEndpointService -Region eu-west-1 | Select-Object -ExpandProperty Servicenames | Where-Object { -match "ssm"}

輸出:

com.amazonaws.eu-west-1.ssm com.amazonaws.eu-west-1.ssmmessages