

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# CLI로 `AttachInternetGateway` 사용
<a name="example_ec2_AttachInternetGateway_section"></a>

다음 코드 예시는 `AttachInternetGateway`의 사용 방법을 보여 줍니다.

작업 예시는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서는 컨텍스트 내에서 이 작업을 확인할 수 있습니다.
+  [프라이빗 서브넷과 NAT 게이트웨이가 포함된 VPC 생성](example_vpc_GettingStartedPrivate_section.md) 
+  [Amazon VPC 시작하기](example_vpc_GettingStartedCLI_section.md) 

------
#### [ CLI ]

**AWS CLI**  
**VPC에 인터넷 게이트웨이 연결**  
다음 `attach-internet-gateway` 예시에서는 지정된 인터넷 게이트웨이를 특정 VPC에 연결합니다.  

```
aws ec2 attach-internet-gateway \
    --internet-gateway-id igw-0d0fb496b3EXAMPLE \
    --vpc-id vpc-0a60eb65b4EXAMPLE
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *Amazon VPC 사용 설명서*의 [인터넷 게이트웨이](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [AttachInternetGateway](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/attach-internet-gateway.html) 섹션을 참조하세요.

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**예제 1: 이 예제에서는 지정된 인터넷 게이트웨이를 특정 VPC에 연결합니다.**  

```
Add-EC2InternetGateway -InternetGatewayId igw-1a2b3c4d -VpcId vpc-12345678
```
**예제 2: 이 예제에서는 VPC와 인터넷 게이트웨이를 생성한 다음 인터넷 게이트웨이를 VPC에 연결합니다.**  

```
$vpc = New-EC2Vpc -CidrBlock 10.0.0.0/16
New-EC2InternetGateway | Add-EC2InternetGateway -VpcId $vpc.VpcId
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V4)*의 [AttachInternetGateway](https://docs.aws.amazon.com/powershell/v4/reference)를 참조하세요.

**Tools for PowerShell V5**  
**예제 1: 이 예제에서는 지정된 인터넷 게이트웨이를 특정 VPC에 연결합니다.**  

```
Add-EC2InternetGateway -InternetGatewayId igw-1a2b3c4d -VpcId vpc-12345678
```
**예제 2: 이 예제에서는 VPC와 인터넷 게이트웨이를 생성한 다음 인터넷 게이트웨이를 VPC에 연결합니다.**  

```
$vpc = New-EC2Vpc -CidrBlock 10.0.0.0/16
New-EC2InternetGateway | Add-EC2InternetGateway -VpcId $vpc.VpcId
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [AttachInternetGateway](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

------

 AWS SDK 개발자 안내서 및 코드 예제의 전체 목록은 섹션을 참조하세요[AWS SDK를 사용하여 Amazon EC2 리소스 생성](sdk-general-information-section.md). 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.