Kanji
・클라우드 엔지니어 / 프리랜서 ・1993년생 ・에히메현 출신 / 도쿄도 시부야구 거주 ・AWS 경력 5년 프로필 상세
목차
botocore
curl
사내 업무 자동화를 위해 Antigravity, Claude Code, Amazon Bedrock AgentCore 같은 자율형 AI 코딩 에이전트가 사내 고객 데이터베이스 검색 API나 재고 조회 마이크로서비스를 직접 호출하도록 하는 PoC(개념 증명)를 진행하던 때였습니다.
인프라·보안 담당 엔지니어로서 제가 가장 먼저 마주한 벽은 “비결정론적으로 동작하는 AI 에이전트와 내부 핵심 마이크로서비스를 어느 네트워크 계층에서 안전하게 연결해야 하는가” 였습니다.
기존의 AWS 멀티 계정·멀티 VPC 환경에서는 다음과 같은 L3/L4(IP 주소 및 포트) 기반 접근 제어가 표준이었습니다.
하지만 스스로 코드를 생성하고 도구를 실행하는 AI 에이전트를 이 구성에 연결한 순간 치명적인 위험이 드러났습니다.
[ Autonomous AI Agent (EC2 / ECS / AgentCore) ] │ ▼ (L3/L4 Traffic Allowed: Reaching destination at IP/Port level) [ Internal Core API Server (ALB + Private ECS) ] ├── GET /api/v1/customers/search (Intended safe read-only operation) ├── POST /api/v1/customers/update (Unintended data modification risk) └── DELETE /api/v1/customers/purge (Catastrophic data deletion risk)
에이전트가 프롬프트 해석 오류나 도구 인자 할루시네이션(또는 간접 프롬프트 인젝션 공격)으로 인해 실수로 DELETE /api/v1/customers/purge 를 호출하더라도, IP 주소와 443 포트가 보안 그룹에서 허용되어 있는 이상 네트워크 계층은 이를 전혀 차단하지 못합니다 .
DELETE /api/v1/customers/purge
’사내 프라이빗 네트워크 안에 있으니 안전하다’는 경계 방어 전제는 예측 불가능한 행동을 할 수 있는 AI 에이전트 앞에서는 완전히 무너집니다. 정적 IP 라우팅에 의존하지 않고, 개별 HTTP 요청마다 ’어느 IAM 역할을 가진 에이전트가 어떤 URL 경로와 HTTP 메서드를 호출하고 있는가’를 L7 계층에서 암호학적으로 검증할 방법이 필요했습니다. 이 과제를 가장 깔끔하게 해결해 준 것이 바로 Amazon VPC Lattice 와 AWS IAM SigV4(Signature Version 4) 의 조합이었습니다.
▲ 전체 아키텍처: Amazon VPC Lattice의 Service Network와 개별 Service에 2단계 IAM SigV4 인가를 적용하여 에이전트 권한을 L7 수준에서 최소화
Amazon VPC Lattice는 AWS가 제공하는 애플리케이션 계층(L7) 완전관리형 네트워킹 서비스입니다. 기존의 Transit Gateway나 PrivateLink와 달리 복잡한 CIDR 설계, 라우팅 테이블 관리, VPC 피어링 메시 구성이 전혀 필요 없으며 , 무엇보다 AWS IAM 암호화 서명(SigV4) 기반의 인증·인가를 개별 HTTP 요청 단위로 강제 할 수 있습니다.
VPC Lattice에서 Service의 인증 유형( authType )을 AWS_IAM 으로 지정하면, 모든 수신 HTTP/HTTPS 트래픽에 IAM SigV4 서명 헤더( Authorization: AWS4-HMAC-SHA256 ... )가 필수가 됩니다. 서명이 없는 요청이나 정책에서 허용되지 않은 에이전트의 호출은 백엔드 마이크로서비스에 도달하기 전에 Lattice 인프라 계층에서 즉시 403 Forbidden( AccessDeniedException )으로 차단 됩니다.
authType
AWS_IAM
Authorization: AWS4-HMAC-SHA256 ...
AccessDeniedException
VPC Lattice 설계에서 가장 중요한 핵심은 Service Network 레벨 과 Service 레벨 양쪽에서 동시에 평가되는 2단계 Auth Policy(논리 AND 조건) 입니다. 요청이 성공하려면 두 정책 모두에서 명시적으로 Allow 되어야 합니다.
Allow
[ Calling AI Agent ] │ (HTTP Request signed with AWS SigV4) ▼ [ Tier 1 Evaluation ] Service Network Auth Policy ──> [ Org Guardrails: Allow? ] │ (Yes) ▼ [ Tier 2 Evaluation ] Service Auth Policy ──> [ Method/Path Least Privilege: Allow? ] │ (Yes) ▼ [ Backend Target Group (Private ECS / ALB) ]
조직 전체의 보안 팀이 관리하는 Service Network에는 ’신뢰할 수 있는 AWS Organizations 소속 주체이며 익명 접근이 아닐 것’을 일괄 강제하는 가드레일 정책을 배치합니다.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "EnforceOrgBoundaryAndSigV4", "Effect": "Allow", "Principal": "*", "Action": "vpc-lattice-svcs:Invoke", "Resource": "*", "Condition": { "StringNotEqualsIgnoreCase": { "aws:PrincipalType": "Anonymous" }, "StringEquals": { "aws:PrincipalOrgID": "o-xxxxxxxxxx" } } } ] }
개별 마이크로서비스(예: 고객 검색 서비스) 측에서는 호출 에이전트의 IAM 역할을 지정하고, 허용할 HTTP 메서드( vpc-lattice-svcs:RequestMethod ), URL 경로( vpc-lattice-svcs:RequestPath ), 발신원 VPC( vpc-lattice-svcs:SourceVpc ) 를 극한까지 좁힙니다.
vpc-lattice-svcs:RequestMethod
vpc-lattice-svcs:RequestPath
vpc-lattice-svcs:SourceVpc
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowOnlyAgentReadOnlySearch", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:role/ResearchAgentExecutionRole" }, "Action": "vpc-lattice-svcs:Invoke", "Resource": "*", "Condition": { "StringEquals": { "vpc-lattice-svcs:RequestMethod": "GET", "vpc-lattice-svcs:SourceVpc": "vpc-0a1b2c3d4e5f6g7h8" }, "StringLike": { "vpc-lattice-svcs:RequestPath": "/api/v1/customers/search*" } } } ] }
이 정책이 적용되면 리서치 에이전트( ResearchAgentExecutionRole )가 할루시네이션으로 인해 POST /api/v1/customers 나 DELETE 를 전송하더라도 Lattice L7 계층에서 즉시 차단되어 백엔드에는 단 1바이트의 트래픽도 도달하지 않습니다 .
ResearchAgentExecutionRole
POST /api/v1/customers
DELETE
authType = AWS_IAM 을 활성화하면 일반 curl 이나 기본 HTTP 클라이언트 요청은 즉시 403 에러를 반환합니다.
authType = AWS_IAM
$ curl -i https://customer-search-service-0a1b2c3d4e5f.7g8h9i.vpc-lattice-svcs.ap-northeast-1.on.aws/api/v1/customers/search HTTP/2 403 date: Wed, 26 Nov 2026 06:15:20 GMT content-type: application/json content-length: 98 x-amzn-errortype: AccessDeniedException {"message":"Access denied: Request is missing required AWS Signature Version 4 authentication."}
AI 에이전트 런타임(Python)에서 투명하게 VPC Lattice 서비스를 호출할 수 있도록 botocore.auth.SigV4Auth 를 내장한 래퍼 클라이언트를 구현했습니다(서비스 이름은 "vpc-lattice-svcs" 로 지정).
botocore.auth.SigV4Auth
"vpc-lattice-svcs"
import os import requests from urllib.parse import urlparse from botocore.auth import SigV4Auth from botocore.awsrequest import AWSRequest from botocore.session import Session class VPCLatticeSigV4Client: def __init__(self, region_name: str = "ap-northeast-1"): self.session = Session() self.credentials = self.session.get_credentials() self.region_name = region_name self.service_name = "vpc-lattice-svcs" def request(self, method: str, url: str, headers: dict = None, data: str = None): headers = headers or {} parsed = urlparse(url) headers["Host"] = parsed.netloc aws_request = AWSRequest( method=method.upper(), url=url, headers=headers, data=data ) auth = SigV4Auth(self.credentials, self.service_name, self.region_name) auth.add_auth(aws_request) response = requests.request( method=method.upper(), url=url, headers=dict(aws_request.headers), data=data, timeout=10.0 ) return response if __name__ == "__main__": client = VPCLatticeSigV4Client() endpoint = "https://customer-search-service-0a1b2c3d4e5f.7g8h9i.vpc-lattice-svcs.ap-northeast-1.on.aws/api/v1/customers/search?query=test" print("[*] Sending SigV4 signed GET request to VPC Lattice...") res = client.request("GET", endpoint) print(f"[*] Response Status Code: {res.status_code}") print(f"[*] Response Body: {res.text[:200]}")
▲ 실기 터미널 검증 화면: 미서명 요청 및 허용되지 않은 DELETE 메서드의 즉각적인 403 차단과 SigV4 서명 주입 시 200 OK 응답(평균 RTT 7.7ms)
운영 환경에서 수동 설정 실수를 방지하기 위해 Service Network, Service, 연결 리소스 및 2단계 Auth Policy를 Terraform으로 코드화했습니다.
# 1. Organization-wide Service Network resource "aws_vpclattice_service_network" "ai_core" { name = "ai-agent-core-network" auth_type = "AWS_IAM" } # 2. Service Network Auth Policy (Organizational Guardrail) resource "aws_vpclattice_auth_policy" "network_policy" { resource_identifier = aws_vpclattice_service_network.ai_core.arn policy = jsonencode({ Version = "2012-10-17" Statement = [ { Sid = "OrgBoundaryGuardrail" Effect = "Allow" Principal = "*" Action = "vpc-lattice-svcs:Invoke" Resource = "*" Condition = { StringNotEqualsIgnoreCase = { "aws:PrincipalType" = "Anonymous" } StringEquals = { "aws:PrincipalOrgID" = var.aws_org_id } } } ] }) } # 3. Lattice Service Definition resource "aws_vpclattice_service" "customer_search" { name = "customer-search-service" auth_type = "AWS_IAM" } # 4. Associate Service with Service Network resource "aws_vpclattice_service_network_service_association" "search_assoc" { service_identifier = aws_vpclattice_service.customer_search.id service_network_identifier = aws_vpclattice_service_network.ai_core.id } # 5. Service-Level Auth Policy (Granular Least Privilege) resource "aws_vpclattice_auth_policy" "service_policy" { resource_identifier = aws_vpclattice_service.customer_search.arn policy = jsonencode({ Version = "2012-10-17" Statement = [ { Sid = "ReadOnlyAgentSearchOnly" Effect = "Allow" Principal = { AWS = var.agent_role_arn } Action = "vpc-lattice-svcs:Invoke" Resource = "*" Condition = { StringEquals = { "vpc-lattice-svcs:RequestMethod" = "GET" "vpc-lattice-svcs:SourceVpc" = var.agent_vpc_id } StringLike = { "vpc-lattice-svcs:RequestPath" = "/api/v1/customers/search*" } } } ] }) }
▲ AWS 콘솔 및 CLI 검증 화면: Service Network에서 Auth Type이 AWS_IAM으로 활성화되고 세분화된 Service Auth Policy가 적용된 모습
vpc-lattice-svcs:Invoke
VPC Lattice의 Auth Policy(리소스 기반 정책)에 Allow 를 작성했더라도, 호출 에이전트의 IAM 역할 자체(자격 증명 기반 정책)에도 vpc-lattice-svcs:Invoke 권한이 부여되어 있어야 합니다 .
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowLatticeInvoke", "Effect": "Allow", "Action": "vpc-lattice-svcs:Invoke", "Resource": "arn:aws:vpc-lattice:ap-northeast-1:123456789012:service/*" } ] }
로컬 Mac이나 Docker 컨테이너가 절전 모드에서 깨어난 직후 테스트할 때 403 Signature expired 가 발생하는 경우가 있습니다. AWS SigV4는 요청 헤더의 x-amz-date 와 AWS 서버 시각 차이가 5분 이상 벌어지면 서명을 무효화하므로, 에이전트 실행 환경에서 NTP 동기화( chrony 등)를 반드시 유지해야 합니다.
403 Signature expired
x-amz-date
chrony
도쿄 리전 내에서 ECS 에이전트 컨테이너가 VPC Lattice를 경유해 백엔드 API를 1,000회 호출했을 때의 왕복 지연 시간(RTT)을 측정했습니다.
SigV4 암호화 서명 계산과 2단계 L7 정책 평가가 추가됨에도 오버헤드는 약 +3.5ms 에 불과합니다. LLM 추론 시간(수백 ms~수 초)과 비교하면 사실상 무시할 수 있는 수준입니다.
Amazon VPC Lattice 과금 체계와 비용 효율성 : VPC Lattice 요금은 ① 프로비저닝된 서비스 시간($0.025/서비스·시간, 월 약 $18.25), ② 데이터 처리량($0.025/GB, AZ 간 데이터 전송 요금 별도 없음), ③ HTTP/HTTPS 요청 수(100만 요청당 $0.10, 단 각 서비스당 매시간 처음 300,000건 요청까지는 무료 )의 3가지 축으로 구성됩니다. 사내 AI 에이전트의 도구 호출 빈도라면 요청 요금은 사실상 무료 한도 내에 수렴합니다.
자율형 AI 에이전트를 프로덕션에 도입할 때 시스템 프롬프트 제약이나 애플리케이션 코드의 if 분기만으로는 할루시네이션과 프롬프트 인젝션 위협을 완벽히 막을 수 없습니다. Amazon VPC Lattice × IAM SigV4 아키텍처를 도입함으로써 에이전트가 오작동하더라도 허용된 메서드와 경로 외의 트래픽을 L7 네트워크 계층에서 물리적으로 차단하고, 복잡한 VPC 피어링 관리 없이 CloudTrail에 완벽한 감사 로그를 남기는 제로트러스트 기반을 확립할 수 있습니다.
if
Real-time AI quant analysis of corporate earnings reports.
실전 같은 AI 음성 모의 통화와 5축 정밀 피드백. 16강 인터랙티브 강의와 스튜디오급 AI 프로필 생성 지원.
영수증 촬영 즉시 Gemini AI가 품목과 금액을 자동 인식. 모임 및 여행 경비를 손쉽게 더치페이하고 정산합니다.
점술사, 집사, 바텐더 AI 캐릭터가 직접 게임을 진행하고 대화 주제를 던져 모임을 흥미진진하게 만듭니다.
人工甘味料や添加物のNG除外と有効成分あたりの実質単価比較データベース。