Sono disponibili altri esempi per SDK AWS nel repository GitHub della documentazione degli esempi per SDK AWS
Utilizzare DescribeVpcEndpoints con una CLI
Gli esempi di codice seguenti mostrano come utilizzare DescribeVpcEndpoints.
- CLI
-
- AWS CLI
-
Come descrivere gli endpoint VPC
L’esempio
describe-vpc-endpointsseguente visualizza i dettagli di tutti gli endpoint VPC.aws ec2 describe-vpc-endpointsOutput:
{ "VpcEndpoints": [ { "PolicyDocument": "{\"Version\":\"2008-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"*\",\"Resource\":\"*\"}]}", "VpcId": "vpc-aabb1122", "NetworkInterfaceIds": [], "SubnetIds": [], "PrivateDnsEnabled": true, "State": "available", "ServiceName": "com.amazonaws.us-east-1.dynamodb", "RouteTableIds": [ "rtb-3d560345" ], "Groups": [], "VpcEndpointId": "vpce-032a826a", "VpcEndpointType": "Gateway", "CreationTimestamp": "2017-09-05T20:41:28Z", "DnsEntries": [], "OwnerId": "123456789012" }, { "PolicyDocument": "{\n \"Statement\": [\n {\n \"Action\": \"*\", \n \"Effect\": \"Allow\", \n \"Principal\": \"*\", \n \"Resource\": \"*\"\n }\n ]\n}", "VpcId": "vpc-1a2b3c4d", "NetworkInterfaceIds": [ "eni-2ec2b084", "eni-1b4a65cf" ], "SubnetIds": [ "subnet-d6fcaa8d", "subnet-7b16de0c" ], "PrivateDnsEnabled": false, "State": "available", "ServiceName": "com.amazonaws.us-east-1.elasticloadbalancing", "RouteTableIds": [], "Groups": [ { "GroupName": "default", "GroupId": "sg-54e8bf31" } ], "VpcEndpointId": "vpce-0f89a33420c1931d7", "VpcEndpointType": "Interface", "CreationTimestamp": "2017-09-05T17:55:27.583Z", "DnsEntries": [ { "HostedZoneId": "Z7HUB22UULQXV", "DnsName": "vpce-0f89a33420c1931d7-bluzidnv.elasticloadbalancing.us-east-1.vpce.amazonaws.com" }, { "HostedZoneId": "Z7HUB22UULQXV", "DnsName": "vpce-0f89a33420c1931d7-bluzidnv-us-east-1b.elasticloadbalancing.us-east-1.vpce.amazonaws.com" }, { "HostedZoneId": "Z7HUB22UULQXV", "DnsName": "vpce-0f89a33420c1931d7-bluzidnv-us-east-1a.elasticloadbalancing.us-east-1.vpce.amazonaws.com" } ], "OwnerId": "123456789012" }, { "VpcEndpointId": "vpce-aabbaabbaabbaabba", "VpcEndpointType": "GatewayLoadBalancer", "VpcId": "vpc-111122223333aabbc", "ServiceName": "com.amazonaws.vpce.us-east-1.vpce-svc-123123a1c43abc123", "State": "available", "SubnetIds": [ "subnet-0011aabbcc2233445" ], "RequesterManaged": false, "NetworkInterfaceIds": [ "eni-01010120203030405" ], "CreationTimestamp": "2020-11-11T08:06:03.522Z", "Tags": [], "OwnerId": "123456789012" } ] }Per ulteriori informazioni, consulta Concetti nella Guida per l’utente di AWS PrivateLink.
-
Per informazioni dettagliate sull’API, consulta DescribeVpcEndpoints
in AWS CLI Command Reference.
-
- PowerShell
-
- Strumenti per PowerShell V4
-
Esempio 1: questo esempio descrive uno o più endpoint VPC per la Regione eu-west-1. Reindirizza quindi l’output al comando successivo, che seleziona la proprietà VpcEndpointId e restituisce l’ID VPC dell’array come array di stringhe
Get-EC2VpcEndpoint -Region eu-west-1 | Select-Object -ExpandProperty VpcEndpointIdOutput:
vpce-01a2ab3f4f5cc6f7d vpce-01d2b345a6787890b vpce-0012e34d567890e12 vpce-0c123db4567890123Esempio 2: questo esempio descrive tutti gli endpoint VPC per la Regione eu-west-1 e seleziona le proprietà VpcEndpointId, VpcId, ServiceName e PrivateDnsEnabled per la visualizzazione in formato tabella.
Get-EC2VpcEndpoint -Region eu-west-1 | Select-Object VpcEndpointId, VpcId, ServiceName, PrivateDnsEnabled | Format-Table -AutoSizeOutput:
VpcEndpointId VpcId ServiceName PrivateDnsEnabled ------------- ----- ----------- ----------------- vpce-02a2ab2f2f2cc2f2d vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ssm True vpce-01d1b111a1114561b vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ec2 True vpce-0011e23d45167e838 vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ec2messages True vpce-0c123db4567890123 vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ssmmessages TrueEsempio 3: questo esempio esporta il documento di policy per l’endpoint VPC vpce-01a2ab3f4f5cc6f7d into a json file.
Get-EC2VpcEndpoint -Region eu-west-1 -VpcEndpointId vpce-01a2ab3f4f5cc6f7d | Select-Object -expand PolicyDocument | Out-File vpce_policyDocument.json-
Per informazioni dettagliate sull’API, consulta DescribeVpcEndpoints nella documentazione di riferimento dei cmdlet di AWS Strumenti per PowerShell (V4).
-
- Strumenti per PowerShell V5
-
Esempio 1: questo esempio descrive uno o più endpoint VPC per la Regione eu-west-1. Reindirizza quindi l’output al comando successivo, che seleziona la proprietà VpcEndpointId e restituisce l’ID VPC dell’array come array di stringhe
Get-EC2VpcEndpoint -Region eu-west-1 | Select-Object -ExpandProperty VpcEndpointIdOutput:
vpce-01a2ab3f4f5cc6f7d vpce-01d2b345a6787890b vpce-0012e34d567890e12 vpce-0c123db4567890123Esempio 2: questo esempio descrive tutti gli endpoint VPC per la Regione eu-west-1 e seleziona le proprietà VpcEndpointId, VpcId, ServiceName e PrivateDnsEnabled per la visualizzazione in formato tabella.
Get-EC2VpcEndpoint -Region eu-west-1 | Select-Object VpcEndpointId, VpcId, ServiceName, PrivateDnsEnabled | Format-Table -AutoSizeOutput:
VpcEndpointId VpcId ServiceName PrivateDnsEnabled ------------- ----- ----------- ----------------- vpce-02a2ab2f2f2cc2f2d vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ssm True vpce-01d1b111a1114561b vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ec2 True vpce-0011e23d45167e838 vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ec2messages True vpce-0c123db4567890123 vpc-0fc6ff46f65b039eb com.amazonaws.eu-west-1.ssmmessages TrueEsempio 3: questo esempio esporta il documento di policy per l’endpoint VPC vpce-01a2ab3f4f5cc6f7d into a json file.
Get-EC2VpcEndpoint -Region eu-west-1 -VpcEndpointId vpce-01a2ab3f4f5cc6f7d | Select-Object -expand PolicyDocument | Out-File vpce_policyDocument.json-
Per informazioni dettagliate sull’API, consulta DescribeVpcEndpoints nella documentazione di riferimento dei cmdlet di AWS Strumenti per PowerShell (V5).
-