Amazon VPC Lattice
  • Amazon VPC Lattice
  • Amazon VPC Lattice 소개
  • 01. 사전 준비 및 소개
    • 1. LAB 소개
    • 2. 사전준비
  • 02. Service to Service 연결
    • 1. Target Group 생성
    • 2. Service 생성
    • 3. Service Network 생성
    • 4. 연결 테스트
  • 03. Security
    • 1. 사전 준비
    • 2. 서비스 네트워크 보호
    • 3. 인증정책 기반 서비스 보호
    • 4. AWS SigV4
  • 04. Observability
    • 1. Access Log 구성
  • 05.Gateway API Controller
    • AWS Gateway API Controller 설치
    • 기본 구성하기
    • MultiCluster 구성
Powered by GitBook
On this page
  • 1.연결 테스트
  • Step1. 연결 테스트를 위한 준비
  • Step2. Service 연결 시험
  • Step3. Client VPC에서 확인
  1. 02. Service to Service 연결

4. 연결 테스트

Update : 2024.06.07

Previous3. Service Network 생성Next03. Security

Last updated 11 months ago

이제 Client에서 "reservation", "parking" 서비스에 접근하기 위한 준비와 테스트를 수행해 봅니다.

아래와 같은 구성으로 시험할 것입니다.

1.연결 테스트

Step1. 연결 테스트를 위한 준비

"2.Service 생성"에서 만든 "reservation", "parking"은 private dns가 자동으로 생성되어 있습니다.

Client VPC의 Client EC2들이 해당 DNS 이름으로 연결할 것입니다.

해당 DNS들에 대한 정보를 아래 Shell을 실행해서 Cloud9에서 저장해 둡니다.

#service domain name 확인
aws vpc-lattice list-services
aws vpc-lattice list-services | jq -r '.items[].dnsEntry.domainName' | grep 'reservation'
aws vpc-lattice list-services | jq -r '.items[].dnsEntry.domainName' | grep 'parking'
export reservation_svc_dns=$(aws vpc-lattice list-services | jq -r '.items[].dnsEntry.domainName' | grep 'reservation')
export parking_svc_dns=$(aws vpc-lattice list-services | jq -r '.items[].dnsEntry.domainName' | grep 'parking')
echo "export reservation_svc_dns=${reservation_svc_dns}" | tee -a ~/.bash_profile
echo "export parking_svc_dns=${parking_svc_dns}" | tee -a ~/.bash_profile

#service arn 확인
#parking service arn
aws vpc-lattice list-services | jq -r '.items[]| select(.name=="parking") | .arn'
echo "export parking_svc_arn=$(aws vpc-lattice list-services | jq -r '.items[]| select(.name=="parking") | .arn')" | tee -a ~/.bash_profile

#reservation service arn
aws vpc-lattice list-services | jq -r '.items[]| select(.name=="reservation") | .arn'
echo "export reservation_svc_arn=$(aws vpc-lattice list-services | jq -r '.items[]| select(.name=="reservation") | .arn')" | tee -a ~/.bash_profile

source ~/.bash_profile

아래 명령을 통해 , 현재 parking,reservation의 VPC Lattice Service ARN 고유의 값과 DNS 주소를 확인 할 수 있습니다. 이것을 별도로 복사 해 둡니다.

cat ~/.bash_profile

결과 예제

reservation_svc_dns=reservation-040b9760ff9d4e498.7d67968.vpc-lattice-svcs.ap-northeast-2.on.aws
parking_svc_dns=parking-0b79a8f8d6d6a2e00.7d67968.vpc-lattice-svcs.ap-northeast-2.on.aws
parking_svc_arn=arn:aws:vpc-lattice:ap-northeast-2:504410361335:service/svc-0b79a8f8d6d6a2e00
reservation_svc_arn=arn:aws:vpc-lattice:ap-northeast-2:504410361335:service/svc-040b9760ff9d4e498

VPC Lattice 콘솔에서도 Service Domain 이름을 확인할 수 있습니다.

  • VPC Lattice - Service - Service 선택 - Associated resource summary - Domain name

아래 Shell을 실행해서, Cloud9 Session Manager에서 Client VPC의 Client들의 EC2 id를 연결하기 쉽게 준비해 둡니다.

#Cloud9 에서 Session Manager를 통해서 Client에 연결
~/environment/vpclattice/cloud9/client_export.sh
source ~/.bash_profile

Step2. Service 연결 시험

Cloud9 콘솔에서 새로운 terminal 을 실행하고, 아래와 같이 Shell을 실행해서 Client VPC의 Client1에 접속합니다.

source ~/.bash_profile
aws ssm start-session --target $InstanceClient1

InstanceClient1 터미널에서 아래와 같이 reservation 서비스에 연결해 봅니다. Lambda 자원이 배치된 서비스 입니다.

# 앞서 확인한 reservation dns name을 InstanceClietn1 터미널에서 입력합니다.
export reservation_svc_dns='reservation-xxxx.xxxx.vpc-lattice-svcs.us-west-2.on.aws'
echo "export reservation_svc_dns=${reservation_svc_dns}" | tee -a ~/.bash_profile
curl https://${reservation_svc_dns}

아래와 같이 "reservation" 서비스에 대한 응답이 결과로 출력 됩니다.

    <html>
    <head>
    <title>Hello From Lattice Reservations!</title>
    <style>
    html, body {
    margin: 0; padding: 0;
    font-family: arial; font-weight: 700; font-size: 3em;
    text-align: center;
    }
    </style>
    </head>
    <body>
    <p>Hello From Lattice Reservations!</p>
    </body>
    </html> 

InstanaceClient1 에서 아래와 같이 parking 서비스 /rates에 연결해 봅니다. EC2 자원이 배치된 서비스 입니다.

# 앞서 확인한 parking dns name을 입력하고, /rates 를 추가합니다.
export parking_svc_dns='parking-xxxx.xxxx.vpc-lattice-svcs.us-west-2.on.aws'
echo "export parking_svc_dns=${parking_svc_dns}" | tee -a ~/.bash_profile
source ~/.bash_profile
curl http://${parking_svc_dns}/rates

아래와 같이 "rates" 서비스에서 응답을 합니다.

Hello from "rates"

InstanceClient1 에서 아래와 같이 parking 서비스 / payments에 연결해 봅니다. ALB 자원이 배치된 서비스 입니다.

# 앞서 확인한 reservation dns name을 입력하고, /payments 를 추가합니다.
curl http://${parking_svc_dns}/payments

아래와 같이 "payments" 서비스에서 응답을 합니다.

Hello from "payments"

Step3. Client VPC에서 확인

LAB에 배포된 모든 VPC는 동일한 CIDR 주소를 가지고 있습니다. (CIDR 주소 : 10.0.0.0/16)

어떻게 트래픽 처리가 가능한지를 확인해 봅니다.

Session Manager로 연결되어 있는 "InstanceClient1" 에서 name service 주소를 확인해 봅니다.

dig ${reservation_svc_dns} +short
dig ${parking_svc_dns} +short

아래와 같은 결과를 확인할 수 있습니다.

$ dig ${reservation_svc_dns} +short
169.254.171.1
$ dig ${parking_svc_dns} +short
169.254.171.1

VPC lattice는 Link-Local IP 주소대역을 사용하는 것을 확인 할 수 있습니다.

  • Link-Local 주소 대역 : 169.254.1.0/24 ~ 169.254.254.0/24

  • VPC Lattice가 사용하는 주소 대역 : 169.254.17.0/24

  • VPC Lattice Service Network 단위당 1개의 169.254.17.x/32 로 IP 한개를 할당받게 됩니다.

  • VPC Lattice Service Network 당 1개의 IP 주소를 부여 받게 되므로, Service들은 동일한 IP 주소를 갖게 되며 DNS 로 구분짓게 됩니다.

Client VPC에서는 VPC Lattice의 Link-Local IP 대역으로 자동으로 Route Table이 추가 되어 있습니다.

  • "VPC" - "Virtual private cloud" - "Route tables" 선택

  • filter : client

아래에서 처럼 Client VPC의 Public, Private Route Table을 확인해 봅니다.

Service Network에서 Client VPC를 Association 할때 자동으로 Routing Table이 추가 됩니다.