AWS-InternetGateway(인터넷게이트웨이)

1. internet gatway에 대한 이야기

조금 쉽게 설명하면

VPC : 전체 네트워크 IP 구성

subnet : 지역 네트워크 IP 구성

internet gatway : 인터넷과 연결을 선언

내부의 네트워크가 연결되어있다면 내부 통신이 가능합니다.

하지만 우리는 외부 인터넷이 연결되어야 서비스를 할 수 있음으로

인터넷 게이트웨이를 생성해줘야합니다.

  AWSInternetGateway:
    Type: AWS::EC2::InternetGateway
    Properties:
      Tags:
        - Key: Name
          Value: AWSinternetgateway
  AWSVPCGatewayAttachment:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref AWSVPC
      InternetGatewayId: !Ref AWSInternetGateway

이전 했던 방식에서 핵심만 스피드하게 가보겠습니다.

2. Internet Gatway - Console(콘솔)

이전 생성했던 vpc와 subnet을 생성한 상태에서 시작합니다.

인터넷게이트웨이를 만들고 이를 VPC와 연결해줍니다.

vpc의 internet gateway 메뉴에서 인터넷게이트웨이를 생성해줍니다.

이름은 AWSInternetGateway tag중 name key의 value를 AWSinternetgateway로 설정합니다.

생성이 완료되면 작업버튼을 눌러 VPC와 연결해줍니다.

기존에 생성한 AWSVPC를 선택해서 인터넷게이트웨이를 연결해줍니다.

클라우드포메이션 실습을 위해 해당 작업버튼에서 VPC 분리인터넷 게이트웨이 삭제를 진행해줍니다.

3. Internet Gatway - cloud formation(클라우드포메이션)

클라우드포메이션 템플릿을 이용해 인프라 컴포저를 들어갑니다.

Resources:
  AWSVPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/16
      Tags:
        - Key: Name
          Value: AWSVPC
  AWSPublicSubnet1:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId: !Ref AWSVPC
      CidrBlock: 10.0.1.0/24
      AvailabilityZone: ap-northeast-2a
      Tags:
        - Key: Name
          Value: AWSpublicsubnet1

좌측 리스트에서 InternetGateway를 찾아서 추가하고

콘솔과 같이 우측 특성에

Logical ID
AWSInternetGateway


Reesource configuration
Tags:
  - Key: Name
    Value: AWSinternetgateway

을 입력하여 저장하고

VPCGatewayAttachment를 추가합니다.

인터넷게이트웨이를 콘솔에서 설정할땐 별도로 이름을 정하진 않았지만

다른 서비스와의 구분을 위해 Logical ID도 지정해줍니다.

Logical ID
AWSVPCGatewayAttachment


Reesource configuration
VpcId: !Ref AWSVPC
InternetGatewayId: !Ref AWSInternetGateway

!Ref (Reference)를 이용해서 참조하여 가져옵니다.

VpcID는 VPC를 AWSVPC로 만들었기에 그걸 연결시키고

마찬가지로 InternetGatewayId 인 AWSInternetGateway 연결시켜줍니다.

이 후 캔버스에서 AWSVPC가 그룹화 된것이 확인가능합니다.

이제 update templte버튼을 이용하여 업데이트를 해줍니다.

그럼 자동으로 업데이트가 진행되고 VPC메뉴에서 VPC와 인터넷게이트웨이 메뉴를 통해 연결이 확인가능합니다.

Next

  • RouteTable

© 2024 Coding Stairs. All rights reserved.