Sono disponibili altri esempi AWS SDK nel repository AWS Doc SDK
Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Utilizzare AttachInternetGateway
con una CLI
Gli esempi di codice seguenti mostrano come utilizzare AttachInternetGateway
.
- CLI
-
- AWS CLI
-
Per collegare un gateway Internet al tuo VPC
L'
attach-internet-gateway
esempio seguente collega il gateway Internet specificato al VPC specifico.aws ec2 attach-internet-gateway \ --internet-gateway-id
igw-0d0fb496b3EXAMPLE
\ --vpc-idvpc-0a60eb65b4EXAMPLE
Questo comando non produce alcun output.
Per ulteriori informazioni, consulta la sezione Gateway Internet nella Guida per l'utente di Amazon VPC.
-
Per i dettagli sull'API, vedere AttachInternetGateway
in AWS CLI Command Reference.
-
- PowerShell
-
- Strumenti per PowerShell V4
-
Esempio 1: questo esempio collega il gateway Internet specificato al VPC specificato.
Add-EC2InternetGateway -InternetGatewayId igw-1a2b3c4d -VpcId vpc-12345678
Esempio 2: questo esempio crea un VPC e un gateway Internet, quindi collega il gateway Internet al VPC.
$vpc = New-EC2Vpc -CidrBlock 10.0.0.0/16 New-EC2InternetGateway | Add-EC2InternetGateway -VpcId $vpc.VpcId
-
Per i dettagli sull'API, vedere AttachInternetGatewayin AWS Strumenti per PowerShell Cmdlet Reference (V4).
-
- Strumenti per V5 PowerShell
-
Esempio 1: questo esempio collega il gateway Internet specificato al VPC specificato.
Add-EC2InternetGateway -InternetGatewayId igw-1a2b3c4d -VpcId vpc-12345678
Esempio 2: questo esempio crea un VPC e un gateway Internet, quindi collega il gateway Internet al VPC.
$vpc = New-EC2Vpc -CidrBlock 10.0.0.0/16 New-EC2InternetGateway | Add-EC2InternetGateway -VpcId $vpc.VpcId
-
Per i dettagli sull'API, vedere AttachInternetGatewayin AWS Strumenti per PowerShell Cmdlet Reference (V5).
-