기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
를 사용하여 리전 간 피어링 설정 자동화 AWS Transit Gateway
Ram Kandaswamy, Amazon Web Services
요약
AWS Transit Gateway는 중앙 허브를 통해 Virtual Private Cloud(VPCs)와 온프레미스 네트워크를 연결합니다. Transit Gateway 트래픽은 퍼블릭 인터넷을 통과하지 않으므로 일반적인 악용 및 분산 서비스 거부(DDoS) 공격과 같은 위협 벡터가 줄어듭니다.
둘 이상의 간에 통신해야 하는 경우 리전 간 Transit Gateway 피어링을 사용하여 서로 다른 리전의 전송 게이트웨이 간에 피어링 연결을 설정할 AWS 리전수 있습니다. 그러나 Transit Gateway를 사용하여 리전 간 피어링을 수동으로 구성하는 것은 복잡하고 시간이 많이 걸릴 수 있습니다. 이 패턴은 코드형 인프라(IaC)를 사용하여 피어링을 설정하는 지침을 제공합니다. 여러 리전을 반복적으로 구성해야 하고 다중 리전 조직 설정을 AWS 계정 위해이 접근 방식을 사용할 수 있습니다.
이 패턴은 Amazon CloudWatch Logs에 an AWS Step Functions workflow, AWS Lambda functions, AWS Identity and Access Management (IAM) 역할 및 로그 그룹을 포함하는 AWS CloudFormation스택을 설정합니다. 그런 다음 Step Functions 워크플로를 실행하여 전송 게이트웨이에 대한 리전 간 피어링 연결을 생성합니다.
사전 조건 및 제한 사항
사전 조건
활성. AWS 계정
Kiro와 같은 코드 생성 기능이 있는 IDE입니다.
Amazon Simple Storage Service(Amazon S3) 버킷 및 객체를 업로드할 수 있는 권한.
요청 및 수락 리전에서 생성된 전송 게이트웨이입니다.
요청 및 수락 리전에서 생성된 VPCs. 값이 인 addToTransitGateway 키로 VPCs에 태그를 지정합니다true.
요구 사항에 따라 VPCs에 대해 구성된 보안 그룹입니다.
요구 사항에 따라 VPCs에 대해 구성된 네트워크 액세스 제어 목록(ACLs)입니다.
제한 사항
아키텍처
이 패턴에 설명된 에이전트 AI 개발 접근 방식에는 다음 단계가 포함됩니다.
자동화 프롬프트 정의 - Kiro는 피어링 요구 사항을 자세히 설명하는 자연어 프롬프트를 수신합니다.
자동화 스크립트 생성 - Kiro는 제공된 프롬프트를 기반으로 CloudFormation 및 Lambda 스크립트를 생성합니다.
스택 배포 - Kiro는 CloudFormation을 사용하여 필요한 리소스를 배포합니다.
피어링 설정 - Kiro는 Lambda 함수를 호출하여 피어링 연결을 생성하고 라우팅 테이블을 수정하는 Step Functions 워크플로를 실행합니다.
다음 다이어그램은 Step Functions 워크플로를 보여줍니다.
워크플로우는 다음 단계로 구성됩니다.
Step Functions 워크플로는 Transit Gateway 피어링을 위해 Lambda 함수를 호출합니다.
워크플로는 1분 동안 기다립니다.
워크플로는 피어링 상태를 검색하여 조건 블록으로 전송합니다. 블록은 루핑을 담당합니다.
성공 조건이 충족되지 않으면 워크플로가 타이머 단계에 들어가도록 코딩됩니다.
성공 조건이 충족되면 Lambda 함수가 라우팅 테이블을 수정합니다.
Step Functions 워크플로가 종료됩니다.
AWS CloudFormation를 사용하면 AWS 리소스를 설정하고, 빠르고 일관되게 프로비저닝하고, AWS 계정 및의 수명 주기 동안 리소스를 관리할 수 있습니다 AWS 리전.
Amazon CloudWatch Logs를 사용하면 모든 시스템, 애플리케이션 및의 로그를 중앙 집중화 AWS 서비스 하여 모니터링하고 안전하게 보관할 수 있습니다.
AWS Identity and Access Management (IAM)는 AWS 리소스에 대한 액세스를 인증하고 사용할 수 있는 권한을 부여받은 사용자를 제어하여 리소스에 대한 액세스를 안전하게 관리하는 데 도움이 됩니다.
Kiro는 사양 기반 개발을 통해 프로덕션 지원 애플리케이션을 구축하는 데 도움이 되는 에이전트 AI 개발 도구입니다.
AWS Lambda는 서버를 프로비저닝하거나 관리할 필요 없이 코드를 실행하는 데 도움이 되는 컴퓨팅 서비스입니다. 필요할 때만 코드를 실행하며 자동으로 확장이 가능하므로 사용한 컴퓨팅 시간만큼만 비용을 지불합니다.
AWS Step Functions는 AWS Lambda 함수 및 기타를 결합하여 비즈니스 크리티컬 애플리케이션을 구축하는 AWS 서비스 데 도움이 되는 서버리스 오케스트레이션 서비스입니다.
에픽
| 작업 | 설명 | 필요한 기술 |
|---|
프롬프트 자리 표시자를 특정 세부 정보로 채우기 | AWS 리전 및 버킷 이름을 바꾸어 다음 프롬프트를 업데이트합니다. - Active region: ACTIVE_REGION
- Passive region: PASSIVE_REGION
- S3_BUCKET : my-lambda-packages-bucket
- STACK_NAME : transit-gateway-peering
- All Lambda functions use two boto3 EC2 clients at module level (one per region), each with signature_version v4 and retries max_attempts=1 mode=standard.
- Print all API responses for CloudWatch logging.
이를 마크다운 파일로 저장합니다. 컨텍스트를 위해이 마크다운 파일을 Kiro 프로젝트에 추가합니다.
또는 컨텍스트용 파일을 연결하지 않고 위의 변수를 참조하는 인라인 프롬프트로 추가할 수 있습니다. | 일반 AWS, 네트워크 관리자 |
피어링 연결을 생성하는 Lambda 함수를 생성합니다. | Kiro 프로젝트에 다음 프롬프트를 입력합니다. Write a Python Lambda that creates a transit gateway peering attachment from active region to passive region. Both of these regions will be read as environment variables of the Lambda function. Use two boto3 EC2 clients at the module level, one per Region. The handler should describe available transit gateways in both Regions. Then check if a peering attachment already exists on the active side by filtering describe_transit_gateway_attachments for resource-type "peering" and states: available, initiatingRequest, modifying, pendingAcceptance, pending, rejected, and rejecting. Only if zero results, create the peering attachment with tags for both Transit Gateway IDs, then wait 60 seconds (AWS needs this before the passive side can accept), then call accept_transit_gateway_peering_attachment on the passive client. Print all API responses.
이 파일을 저장하고 이름을 peer-transit-gateway.py로 지정합니다.
| 일반 AWS, 네트워크 관리자, 프롬프트 엔지니어링 |
피어링 연결 상태를 폴링하는 Lambda 함수를 생성합니다. | Kiro 프로젝트에 다음 프롬프트를 입력합니다. Using the shared context above, write a Python Lambda that polls peering attachment status. Describe available transit gateways in both regions, then call describe_transit_gateway_attachments on the active client filtered by the active Transit Gateway ID only (no resource-type filter). Return exactly `{'status': status}` where status is the State field from the first attachment. Do not return statusCode or body — the Step Function Choice state reads `$.Payload.status` and compares to "available".
이 파일을 저장하고 이름을 get-transit-gateway-peering-status.py로 지정합니다.
| 일반 AWS, 네트워크 관리자, 프롬프트 엔지니어링 |
두 리전 모두에 정적 경로를 추가하는 Lambda 함수를 생성합니다. | Kiro 프로젝트에 다음 프롬프트를 입력합니다. Using the shared context, write a Python Lambda that adds static routes to both regions' TGW route tables. Describe available transit gateways in both Regions, extract each transit gateway's AssociationDefaultRouteTableId. Discover routable VPCs by filtering describe_vpcs with tag `addtotransitgateway=true` in each region, collecting their CIDRs. Get the peering attachment ID from the active side by filtering on the active route table ID. For each passive CIDR, search the active route table using `route-search.exact-match` — only create the route if none found. For each active CIDR, search the passive route table using `route-search.supernet-of-match` (not exact-match — passive side may have supernet routes) — only create if none found. Both sides use the same peering attachment ID.
이 파일을 로 저장하고 이름을 지정합니다modify-transit-gateway-routes.py.
| 일반 AWS, 네트워크 관리자 |
CloudFormation 템플릿을 생성합니다. | CloudFormation 템플릿을 생성하는 다음 오케스트레이션 프롬프트를 입력합니다. Write a CloudFormation JSON template that deploys: three Lambda functions (peer-transit-gateway with 600s timeout, get-transit-gateway-peering-status with 30s timeout, modify-transit-gateway-routes with 600s timeout), Lambda code from an S3 bucket parameter (no default value — user must supply the bucket name at deploy time), a Step Functions state machine, and CloudWatch log groups with 90-day retention. The state machine flow is:
1. Invoke peer-transit-gateway
2. Wait 20 seconds (attachment needs time after the Lambda's internal 20s sleep + acceptance)
3. Invoke get-transit-gateway-peering-status
4. Choice: if `$.Payload.status` equals "available" → go to step 5, otherwise loop back to step 2
5. Invoke modify-transit-gateway-routes → End
Use `Fn::Sub` with Lambda ARN references like `${PeerTransitGateways.Arn}` in the DefinitionString. The polling loop has no max retry — it loops until "available" (typically 3-5 minutes total).
이 파일을 저장하고 이름을 transit-gateway-peering.json로 지정합니다.
| AWS DevOps, 일반 AWS, 프롬프트 엔지니어링 |
| 작업 | 설명 | 필요한 기술 |
|---|
프롬프트를 사용하여 CloudFormation 스택을 배포합니다. | 다음 프롬프트를 입력합니다. Using the outputs from Prompts 1-4, package and deploy the full stack. Steps:
1. For each of the three Python files from Prompts 1-3, create a zip named after the file (e.g. peer-transit-gateway.zip that contains peer-transit-gateway.py).
2. Upload all three zips to S3_BUCKET.
3. Deploy the CloudFormation template from Prompt 4 to ACTIVE_REGION with S3BucketName=S3_BUCKET and CAPABILITY_NAMED_IAM.
4. Initiate the Step Function from the deployed stack.
Zip file names must match the S3Key values in the template exactly.
| AWS DevOps, 클라우드 관리자, 일반 AWS, 프롬프트 엔지니어링 |
배포를 검증합니다. | | 일반 AWS |
관련 리소스